How to Change Cursor to Image on Hover using CSS?

To change the cursor to an image on hover you can simply use the cursor property. The cursor property allows you to change the default cursors and use your custom ones which can be an image also.

Any image that you want to use as your mouse cursor can be passed as a value to the cursor property. Which will replace the default cursor with the image whose URL you have passed.

The following example replaces the default cursor with droplet.svg when you hover over any of the paragraphs:

Example:

p{
    cursor: url(images/droplet.svg), auto;
}

Please note that the value auto is passed as a fallback. In case the image file is missing or corrupted, the browser will use the value auto for the cursor property.

Just like the paragraphs, you can change the cursor to an image for any element that you want.

In the following example, we are changing the cursor to an image(droplet.svg) when you hover over any of the buttons:

Example:

button{
    cursor: url(images/droplet.svg), auto;
}

Author

  • Manoj Kumar

    Hi, My name is Manoj Kumar. I am a full-stack developer with a passion for creating robust and efficient web applications. I have hands-on experience with a diverse set of technologies, including but not limited to HTML, CSS, JavaScript, TypeScript, Angular, Node.js, Express, React, and MongoDB.