While this tutorial has content that we believe is of great benefit to our community, we have not yet tested or
edited it to ensure you have an error-free learning experience. It’s on our list, and we’re working on it!
You can help us out by using the “report an issue” button at the bottom of the tutorial.
cursor is used to change the mouse cursor on specific elements. This is especially useful in web apps where different tasks can be done other than clicking. This obviously only works when there’s a pointing device:
.in-progress {
cursor: progress;
}
Available Cursors
Hover over the following to see the different cursors available if you’re on a desktop/laptop computer:
General/Default Cursors
Link Cursor
Scroll Cursor
Status Cursors
context-menu
help
wait
progress
Selection Cursors
crosshair
cell
text
vertical-text
Drag & Drop Cursors
alias
copy
move
no-drop
not-allowed
Zoom Cursors
Grab Cursors
Resizing Cursors
e-resize
n-resize
ne-resize
nw-resize
s-resize
se-resize
sw-resize
w-resize
ew-resize
ns-resize
nesw-resize
nwse-resize
col-resize
row-resize
Custom Cursors
You can define custom cursors. Note that not all browsers support svg files for cursors, and .cur files are supported across the board, so it can be a good idea to provide a .cur fallback if you want to use an svg cursor. You can also provide a fallback to one of the non-custom cursors.
You can define a custom position for the cursor hotspot by adding x & y coordinates for where the hotspot should be in the provided custom image.
Note that, when using svg cursors, it’s important that your svg has width & height values on the root svg element, or else your cursor won’t show. In the following example, our svg file (droplet.svg) starts like this:
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 42 42" width="42" height="42">...
.custom-cur {
cursor: url('/images/droplet.svg');
}
/* With a .cur fallback */
.custom-cur {
cursor: url('/images/droplet.svg'),
url('/images/droplet.cur');
}
/* With a custom hotspot */
.custom-cur {
cursor: url('/images/droplet.svg') 10 12;
}
/* With a non-custom fallback: */
.custom-cur {
cursor: url('/images/droplet.svg'),
move;
}
Here’s an example with a custom cursor:
Dino Sammy Cursor
Browser Support:
As of 2020, only 80% of browsers worldwide support custom cursors according to Can I Use css3-cursors?. But this isn’t surprising, many of the browsers that don’t support it are mobile-only browsers that have no use for cursors.
Conclusion:
Custom cursors are most commonly used to indicate that an HTML element that’s not already a link <a href="https://www.digitalocean.com/community/tutorials/...">
is clickable. But it provides a diverse set of additional configurability that could be useful to developers building rich web apps. Keep the following caveats in mind when using custom cursors:
- Your users spend most of their time on other sites, so use custom cursors in a way that is consistent with other sites.
- Touchscreen users (mobile and tablet) won’t see custom cursors.