CSS cursor Property

CSS cursor Property

CSS cursor Property

The cursor property in CSS controls the appearance of the mouse pointer when hovering over an element. It helps improve user experience and interactivity.

1. Syntax

selector { cursor: value; }
ValueDescription
auto (default)The browser decides the cursor type.
defaultStandard arrow pointer.
pointerHand cursor (for links & buttons).
textI-beam cursor (for text selection).
moveCrossed arrows (for moving elements).
not-allowedNo entry sign (disabled actions).
waitLoading spinner.
helpQuestion mark cursor.
grabOpen hand (for draggable items).
grabbingClosed hand (while dragging).
crosshairPrecision crosshair.
zoom-inMagnifying glass (zoom in).
zoom-outMagnifying glass (zoom out).

2. Example – Changing Cursor on Hover

button { cursor: pointer; }
<button>Click Me</button>

✅ The button shows a hand cursor on hover.

3. Example – Cursor for Text Selection

.text { cursor: text; }
<p class="text">Select this text.</p>

✅ The cursor changes to an I-beam.

4. Example – Disabled Cursor (not-allowed)

.disabled { cursor: not-allowed; opacity: 0.5; }
<button class="disabled" disabled>Disabled</button>

✅ Shows a blocked sign when hovering over the disabled button.

5. Example – Custom Cursor Using URL

.custom { cursor: url('cursor.png'), auto; }

✅ Uses a custom cursor image, falling back to auto if unavailable.

6. Best Practices

✔ Use cursor: pointer; for clickable elements (buttons, links).
✔ Use cursor: not-allowed; for disabled elements.
✔ Use cursor: grab; for drag-and-drop features.
✔ Avoid overusing custom cursors to maintain usability.

Soeng Souy

Soeng Souy

Website that learns and reads, PHP, Framework Laravel, How to and download Admin template sample source code free.

Post a Comment

CAN FEEDBACK
close