CSS Property: cursor
The CSS cursor property, your mouse’s personal wardrobe, dictates the type of cursor displayed when the mouse pointer hovers over an element. It lets your users know what kind of action they can perform, kind of like a digital traffic signal. It’s a small detail, but one that can greatly enhance your site’s user experience!
Syntax
The syntax for our cursor property is a piece of cake.
1 |
cursor: value; |
By default, the cursor takes the auto value, which lets the browser decide what cursor to display based on the context.
This chameleon-like property can be applied to all HTML elements, except for (drumroll, please)… some elements in <head>. So, every visual HTML element is a playground for the cursor property.
While you might be hoping to make that cursor do a little jig across the screen, CSS animations can’t be applied to the cursor property. So, no dancing cursors, sadly.
The cursor property is inherited by child elements from their parent.
Cursory Example
Use the dropdown to switch the type of mouse cursor displayed when hovering over the div: