CSS cursor Property
The cursor property specifies the appearance of the mouse pointer when it is positioned over an HTML element.
Different cursor values help communicate how users can interact with content. For example, pointer commonly indicates a clickable element, text indicates selectable text, and grab suggests that an item can be dragged.
The property supports predefined cursor keywords and custom cursor images. Its appearance depends on the browser, operating system, and pointing device.
cursor Syntax
The cursor property accepts a predefined keyword or one or more custom cursor images followed by a required keyword fallback.
selector {
cursor: keyword;
}
Default Cursor
.element {
cursor: auto;
}
Pointer Cursor
.button {
cursor: pointer;
}
Text Cursor
.text-area {
cursor: text;
}
Move Cursor
.draggable {
cursor: move;
}
Custom Cursor Image
.custom-cursor {
cursor: url("cursor.png"), pointer;
}
Custom Cursor with Hotspot
.custom-cursor {
cursor: url("cursor.png") 8 8, pointer;
}
Multiple Cursor Images
.custom-cursor {
cursor: url("cursor.svg"), url("cursor.png"), pointer;
}
CSS-Wide Keywords
.element {
cursor: inherit;
}
.element {
cursor: initial;
}
.element {
cursor: unset;
}
.element {
cursor: revert;
}
.element {
cursor: revert-layer;
}
When using custom cursor images, the declaration must end with a predefined cursor keyword. The browser uses this keyword if none of the supplied images can be used.
Property Values
The cursor property provides several groups of keywords for common interactions.
| Value | Description |
|---|---|
auto |
The browser determines the appropriate cursor based on the element and context. |
default |
Displays the platform's default pointer, commonly an arrow. |
none |
Hides the cursor while it is over the element. |
context-menu |
Indicates that a context menu is available. |
help |
Indicates that help or additional information is available. |
pointer |
Indicates an interactive element, commonly a link or button. |
progress |
Indicates background processing while interaction may remain possible. |
wait |
Indicates that the application is busy. |
cell |
Indicates that a cell or group of cells can be selected. |
crosshair |
Displays a crosshair pointer for precise selection. |
text |
Indicates selectable horizontal text. |
vertical-text |
Indicates selectable vertical text. |
alias |
Indicates that an alias or shortcut may be created. |
copy |
Indicates that an item can be copied. |
move |
Indicates that an item can be moved. |
no-drop |
Indicates that an item cannot be dropped at the current location. |
not-allowed |
Indicates that an action is not permitted. |
grab |
Indicates that an item can be grabbed or dragged. |
grabbing |
Indicates that an item is being grabbed or dragged. |
all-scroll |
Indicates scrolling or panning in multiple directions. |
col-resize |
Indicates horizontal column resizing. |
row-resize |
Indicates vertical row resizing. |
n-resize, s-resize, e-resize, w-resize |
Indicate resizing in a cardinal direction. |
ne-resize, nw-resize, se-resize, sw-resize |
Indicate resizing in a diagonal direction. |
ew-resize, ns-resize |
Indicate horizontal or vertical bidirectional resizing. |
nesw-resize, nwse-resize |
Indicate diagonal bidirectional resizing. |
zoom-in |
Indicates that content can be enlarged. |
zoom-out |
Indicates that content can be reduced. |
url() |
Specifies a custom cursor image, optionally including hotspot coordinates. |
Property Characteristics
| Characteristic | Value |
|---|---|
| Initial value | auto |
| Inherited | Yes |
| Applies to | All elements |
| Computed value | Specified keyword and cursor image list, with URLs made absolute |
| Animation type | Discrete |
| Percentages | Not applicable |
Cursor shapes are controlled by the browser and operating system. The same keyword may appear differently across platforms.
General Cursors
General cursor values control the default pointer appearance or whether the pointer is visible.
auto
.element {
cursor: auto;
}
The browser selects an appropriate cursor based on the element and its context.
default
.element {
cursor: default;
}
Displays the platform's default pointer, usually an arrow.
none
.element {
cursor: none;
}
Hides the cursor over the element without disabling mouse interaction.
Example
.static-label {
cursor: default;
}
.custom-pointer-area {
cursor: none;
}
Important Consideration
Use cursor: none carefully. Hiding the pointer can make navigation difficult, especially for users who depend on visual cursor feedback.
Link and Status Cursors
Link and status cursors communicate whether an element is interactive or whether an application is busy.
pointer
.button {
cursor: pointer;
}
Commonly displays a hand-shaped pointer for clickable elements.
help
.help-text {
cursor: help;
}
Indicates that help or additional information is available.
context-menu
.menu-item {
cursor: context-menu;
}
Indicates that a context menu may be available.
progress
.loading-content {
cursor: progress;
}
Indicates that processing is occurring while the user may still interact with the interface.
wait
.busy-area {
cursor: wait;
}
Indicates that an operation is in progress and the user may need to wait.
not-allowed
.unavailable-action {
cursor: not-allowed;
}
Indicates that an action is unavailable or prohibited.
Important Consideration
A cursor only communicates a visual state. It does not create an interactive element, disable controls, or manage loading behavior.
Selection Cursors
Selection cursors indicate that text, cells, or precise locations can be selected.
text
.editable-text {
cursor: text;
}
Displays a text-selection cursor, commonly an I-beam.
vertical-text
.vertical-content {
cursor: vertical-text;
}
Indicates selectable text arranged vertically.
cell
.spreadsheet-cell {
cursor: cell;
}
Indicates that a cell or group of cells can be selected.
crosshair
.drawing-area {
cursor: crosshair;
}
Displays a crosshair for precise positioning or selection.
Example
.code-editor {
cursor: text;
}
.image-selection {
cursor: crosshair;
}
Practical Consideration
Selection cursors should match the actual interaction. For example, cursor: text does not make an element editable.
Drag and Drop Cursors
Drag and drop cursors indicate whether content can be moved, copied, grabbed, or dropped.
move
.movable-item {
cursor: move;
}
grab
.draggable-item {
cursor: grab;
}
grabbing
.draggable-item.dragging {
cursor: grabbing;
}
copy
.copy-target {
cursor: copy;
}
alias
.shortcut-target {
cursor: alias;
}
no-drop
.invalid-drop-zone {
cursor: no-drop;
}
all-scroll
.pan-area {
cursor: all-scroll;
}
Dragging State Example
.draggable {
cursor: grab;
}
.draggable:active {
cursor: grabbing;
}
This changes the cursor while the element is active. Actual dragging functionality requires appropriate browser behavior or JavaScript.
Important Consideration
Setting a drag-related cursor does not automatically enable drag and drop. The interaction must be implemented separately.
Resize Cursors
Resize cursors indicate the direction in which an element or boundary can be resized.
Horizontal Resize
.horizontal-resize {
cursor: ew-resize;
}
Vertical Resize
.vertical-resize {
cursor: ns-resize;
}
Diagonal Resize
.diagonal-resize {
cursor: nwse-resize;
}
Opposite Diagonal Resize
.diagonal-resize-alt {
cursor: nesw-resize;
}
Column Resize
.column-divider {
cursor: col-resize;
}
Row Resize
.row-divider {
cursor: row-resize;
}
Directional Resize Keywords
| Keyword | Direction |
|---|---|
n-resize |
North |
s-resize |
South |
e-resize |
East |
w-resize |
West |
ne-resize |
Northeast |
nw-resize |
Northwest |
se-resize |
Southeast |
sw-resize |
Southwest |
Important Consideration
Resize cursors do not make an element resizable. Use the CSS resize property where appropriate or implement the resizing behavior separately.
Zoom Cursors
Zoom cursors indicate that an element can be enlarged or reduced.
zoom-in
.zoomable-image {
cursor: zoom-in;
}
zoom-out
.zoomed-image {
cursor: zoom-out;
}
Zoom State Example
.image-preview {
cursor: zoom-in;
}
.image-preview.zoomed {
cursor: zoom-out;
}
Practical Consideration
These cursor values provide visual feedback only. They do not automatically enlarge or reduce an image.
Custom Cursor Images
The cursor property supports custom images through the url() function.
PNG Cursor
.custom-cursor {
cursor: url("cursor.png"), pointer;
}
SVG Cursor
.custom-cursor {
cursor: url("cursor.svg"), pointer;
}
CUR Cursor
.custom-cursor {
cursor: url("cursor.cur"), pointer;
}
Multiple Image Formats
.custom-cursor {
cursor: url("cursor.svg"), url("cursor.png"), pointer;
}
Image Format Support
PNG and CUR files are commonly used for custom cursors. SVG support and restrictions vary by browser, particularly for animated or externally referenced SVG content.
Image Size
Small cursor images are generally preferable. Browsers may reject oversized images, and supported dimensions vary by browser and operating system.
Security Restrictions
Browsers may restrict custom cursors in certain interface areas to prevent misleading pointer behavior.
Important Consideration
Always include a keyword fallback after custom cursor images. A declaration containing only url() is invalid.
Cursor Hotspots
A cursor hotspot defines the exact point within a custom cursor image that corresponds to the pointer's active position.
Hotspot Syntax
.custom-cursor {
cursor: url("cursor.png") 8 8, pointer;
}
The two numbers specify the horizontal and vertical hotspot coordinates in image pixels, measured from the top-left corner.
Top-Left Hotspot
.custom-cursor {
cursor: url("cursor.png") 0 0, pointer;
}
Centered Hotspot
.custom-cursor {
cursor: url("cursor-32.png") 16 16, pointer;
}
Different Hotspots for Different Images
.custom-cursor {
cursor: url("cursor-a.png") 4 4, url("cursor-b.png") 8 8, pointer;
}
When Coordinates Are Omitted
The browser uses an intrinsic hotspot if the image format provides one. Otherwise, the top-left corner is generally used.
Important Consideration
Hotspot coordinates must be unitless numbers. They are not CSS lengths and should not include px.
Fallback Cursors
Custom cursor declarations can contain multiple images followed by a predefined cursor keyword.
Single Image with Fallback
.custom-cursor {
cursor: url("cursor.png"), pointer;
}
Multiple Images with Fallback
.custom-cursor {
cursor: url("cursor.svg"), url("cursor.png"), default;
}
Fallback Order
The browser attempts to use the first supported cursor image. If it cannot use that image, it tries the next image. If no image is usable, the browser displays the final keyword cursor.
Invalid Declaration
.custom-cursor {
cursor: url("cursor.png");
}
This declaration is invalid because it does not include the required keyword fallback.
Recommended Approach
.custom-cursor {
cursor: url("cursor.png") 4 4, pointer;
}
Use a recognizable fallback that communicates the intended interaction when the custom image is unavailable.
Interactive Elements
The cursor property is commonly used to communicate how users can interact with buttons, links, draggable items, and other controls.
Clickable Button
.action-button {
cursor: pointer;
}
Draggable Element
.drag-handle {
cursor: grab;
}
.drag-handle:active {
cursor: grabbing;
}
Help Indicator
.help-indicator {
cursor: help;
}
Unavailable Action
.unavailable {
cursor: not-allowed;
}
Zoomable Image
.image-preview {
cursor: zoom-in;
}
Important Consideration
A pointer cursor does not make an element clickable. Use appropriate HTML elements and event handling to provide the actual interaction.
cursor and pointer-events
The cursor and pointer-events properties control different aspects of pointer interaction.
cursor
.button {
cursor: pointer;
}
Changes the pointer's appearance without changing whether the element receives pointer events.
pointer-events
.overlay {
pointer-events: none;
}
Prevents the element itself from being the target of pointer events, allowing pointer targeting to pass through to eligible content underneath.
Combined Example
.disabled-overlay {
cursor: not-allowed;
pointer-events: none;
}
Because pointer-events: none removes the overlay from pointer hit testing, its not-allowed cursor may not appear. The cursor is typically determined by the element underneath.
Recommended Approach
For an unavailable button, use the native disabled attribute when appropriate. Cursor styling can provide additional visual feedback but should not replace the actual disabled state.
cursor and user-select
The cursor property changes pointer appearance, while user-select controls whether text can be selected.
Text Cursor
.text-content {
cursor: text;
}
Disable Text Selection
.drag-handle {
user-select: none;
}
Combined Example
.drag-handle {
cursor: grab;
user-select: none;
}
.drag-handle:active {
cursor: grabbing;
}
Selectable Text
.selectable-content {
cursor: text;
user-select: text;
}
Important Consideration
Setting cursor: text does not enable text selection if another style or browser behavior prevents it.
cursor Example
This example demonstrates several predefined cursor values. Move the mouse pointer over each box to see how the cursor changes.
The appearance of each cursor depends on your browser and operating system.
<div class="cursor-demo">
<div class="cursor-item cursor-pointer">pointer</div>
<div class="cursor-item cursor-help">help</div>
<div class="cursor-item cursor-text">text</div>
<div class="cursor-item cursor-move">move</div>
<div class="cursor-item cursor-grab">grab</div>
<div class="cursor-item cursor-crosshair">crosshair</div>
<div class="cursor-item cursor-not-allowed">not-allowed</div>
<div class="cursor-item cursor-wait">wait</div>
<div class="cursor-item cursor-zoom-in">zoom-in</div>
<div class="cursor-item cursor-ew-resize">ew-resize</div>
<div class="cursor-item cursor-ns-resize">ns-resize</div>
<div class="cursor-item cursor-copy">copy</div>
</div>
.cursor-demo {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
gap: 10px;
}
.cursor-demo .cursor-item {
padding: 18px 10px;
border: 1px solid #cccccc;
background-color: #f8f9fa;
text-align: center;
font-weight: bold;
}
.cursor-demo .cursor-item:hover {
border-color: #336699;
background-color: #eaf2f8;
}
.cursor-pointer {
cursor: pointer;
}
.cursor-help {
cursor: help;
}
.cursor-text {
cursor: text;
}
.cursor-move {
cursor: move;
}
.cursor-grab {
cursor: grab;
}
.cursor-crosshair {
cursor: crosshair;
}
.cursor-not-allowed {
cursor: not-allowed;
}
.cursor-wait {
cursor: wait;
}
.cursor-zoom-in {
cursor: zoom-in;
}
.cursor-ew-resize {
cursor: ew-resize;
}
.cursor-ns-resize {
cursor: ns-resize;
}
.cursor-copy {
cursor: copy;
}
Each box uses a different cursor value. The hover background provides additional visual feedback while the pointer is positioned over a box.
These boxes demonstrate cursor appearance only. They do not perform the actions suggested by their cursor shapes.
Try changing a cursor keyword to another supported value to compare its appearance.
Accessibility
Cursor styling can provide useful visual feedback, but it should not be the only way an interface communicates functionality.
Do Not Rely on Cursor Appearance Alone
Touchscreen users may not have a visible cursor, and keyboard users navigate without relying on pointer appearance.
Use Semantic Interactive Elements
Use HTML buttons for actions and links for navigation. Setting cursor: pointer on a noninteractive element does not make it accessible.
Provide Keyboard Access
Interactive controls should be operable using a keyboard, with visible focus indicators.
Avoid Hiding the Cursor
Using cursor: none can make it difficult for users to locate the pointer.
Avoid Misleading Cursor Shapes
Only use grab, zoom-in, pointer, and similar values when the corresponding interaction is available.
Disabled Controls
Use appropriate HTML states, such as disabled, rather than relying on not-allowed alone.
Custom Cursor Visibility
Custom cursor images should remain recognizable and visible against different background colors.
Important Considerations
Keep the following points in mind when using cursor:
- Purpose: Controls the appearance of the mouse pointer over an element.
- Initial value:
auto. - Inheritance: The property is inherited.
- Predefined keywords: Values include
pointer,text,grab,wait, and many others. - Custom images: The
url()function can specify cursor images. - Fallback requirement: Custom cursor declarations must end with a predefined keyword.
- Hotspots: Optional unitless coordinates identify the active point within a custom cursor image.
- Image formats: Support varies by browser and image format.
- Image dimensions: Browsers may reject oversized cursor images.
- Platform differences: Cursor appearance varies across browsers and operating systems.
- Touch devices: Devices without a conventional pointer may not display cursor changes.
- Interaction: Cursor styling does not create click, drag, resize, or zoom functionality.
- Disabled controls:
cursor: not-alloweddoes not disable an element. - Pointer events: The
pointer-eventsproperty controls pointer targeting separately from cursor appearance. - Text selection: The
user-selectproperty controls text selection separately from cursor appearance. - Animation: Cursor values change discretely rather than interpolating between shapes.
- Accessibility: Do not rely exclusively on cursor changes to communicate functionality.
Choose cursor values that accurately reflect available interactions. For most interfaces, predefined cursor keywords provide clearer and more consistent feedback than custom cursor images.
Browser Support
The CSS cursor property is widely supported in modern browsers, including Chrome, Edge, Firefox, and Safari.
Common cursor keywords such as auto, default, pointer, text, move, and wait have broad support.
Support for custom cursor formats, image dimensions, hotspot behavior, and certain cursor keywords may vary across browsers and operating systems.
Basic Example
.button {
cursor: pointer;
}
Custom Cursor with Fallback
.custom-cursor {
cursor: url("cursor.png"), pointer;
}
Feature Detection
@supports (cursor: grab) {
.draggable {
cursor: grab;
}
}
The @supports rule checks whether a browser recognizes a cursor declaration. It does not guarantee that every custom cursor image or platform-specific appearance will work as expected.
For current compatibility information, visit Can I Use? .
Specifications
The cursor property is defined in CSS Basic User Interface Module Level 4.
CSS Basic User Interface Module Level 4
The specification defines cursor keywords, custom cursor images, hotspot coordinates, fallback behavior, and how cursor appearance is determined.
