Sobes.tech
Intern

How to change the cursor style on a web page?

sobes.tech AI

Answer from AI

Using the CSS cursor property.

Examples of values:

  • auto: Cursor is determined by the context.
  • default: Default cursor (usually an arrow).
  • pointer: Pointer finger (for interactive elements).
  • text: Text cursor (vertical line).
  • wait: Waiting cursor (hourglass or indicator).
  • help: Help cursor (question mark).
  • move: Move cursor.
  • not-allowed: "Not allowed" cursor (crossed circle).
  • <url>: Use of a custom image.

Example of usage:

/* Change cursor for all links */
a {
  cursor: pointer;
}

/* Use a custom image */
.custom-cursor {
  cursor: url('path/to/image.cur'), auto; /* Image URL and fallback */
}

Use .cur or .ani format for custom cursors, along with a fallback from standard values to ensure cross-browser compatibility.