cursor
Sets the appearance of the mouse cursor over an element.
- Initial value
auto- Inherited
- Yes
- Animatable
- no
- Applies to
- all elements
- JavaScript
element.style.cursor = "pointer"
Example
#.card[role="button"] {
cursor: pointer;
}
button:disabled {
cursor: not-allowed;
}<div style="display: flex; gap: 10px;">
<button type="button" style="padding: 8px 14px; cursor: pointer;">Active</button>
<button type="button" disabled style="padding: 8px 14px; cursor: not-allowed;">Disabled</button>
</div>Definition and usage
#The cursor property changes the shape of the cursor when the pointer is over an element. The cursor is an important cue: a hand (pointer) says “you can click here”, an I-beam (text) says “you can select text here”, and a crossed-out circle (not-allowed) says “this action is unavailable”.
Buttons and links have the appropriate cursors by default. Set a custom cursor for elements that behave like buttons but aren’t, and for special zones such as dragging (grab, grabbing).
You can also use your own image: cursor: url(cursor.png) 4 4, auto. The numbers are the image’s hotspot, and after the comma you give a fallback cursor.
Syntax
#cursor: auto | default | pointer | text | move | grab | not-allowed | wait | help | … | url(…) x y, <cursor>;Values
#Values in practice
#pointer
.demo { cursor: pointer; }text
.demo { cursor: text; }grab
.demo { cursor: grab; }not-allowed
.demo { cursor: not-allowed; }wait
.demo { cursor: wait; }zoom-in
.demo { cursor: zoom-in; }Browser support
#Widely available
Works in all modern browsers, phones included. You can use it without worry.
- Chrome
- Edge
- Firefox
- Safari
Good practices
#- Don’t switch the cursor to
pointeron elements that do nothing when clicked. It is misleading. - Touch screens have no cursor, so don’t use it to convey important information.
Related entries
#Practise it in lessons
#Spotted a mistake or missing an example? Write to us.