Producing web pages
* HTML CSS DHTML XHTML A to Z of tags        Accessibility          Design

cursor

The :cursor pseudo-class allows you to change the cursor that appears when you move the mouse over a tag on the page.

b {cursor: hand;}

This example turns the cursor into a hand when you move the mouse over bold text.

There are seventeen different cursor properties and some of them even work. The cursor look, though, depends a lot on the operating system and settings your user has made.

Here’s what the cursor options look like in Internet Explorer on my PC (you’ll have seen them all in Windows at some time or other):

auto

Your browser decides which cursor to display. This is whatever it thinks is most appropriate

crosshair

default

The cursor that the operating system uses

pointer

The item is a link. This is a hand in Internet Explorer

help

Help is available for the item. For example:

move

Shows that you are moving the item. For example:

text

Shows that you can select text. For example:

hand

wait

Shows that the browser is busy. For example:

n-resize
ne-resize
e-resize
se-resize
s-resize
sw-resize
w-resize
nw-resize

Shows that you are resizing the item and the direction. For example:

You should note:

  • Use auto if you want the browser to decide which cursor to display depending on the context
  • Use default if you want the default cursor used by your operating system. Usually appears as an arrow
  • The value hand is not part of the official CSS2 specification. I think it should be and you can use it with Internet Explorer
  • The values n-resize, ne-resize, e-resize, se-resize, se-resize, s-resize, sw-resize, w-resize, nw-resize indicate that an edge should move

You can also supply your own cursor. Just enter the url of the appropriate file:

p {cursor:url ("file.cur");}

If you have a number of files, you can use a different cursor for different types of link. You might use a question mark for a link to a help file or a globe for a link to external sites. You can include a single cursor, a list of alternative cursors separated by commas or a generic cursor.

 P { cursor : url("cursor1.cur"), url("cursor2.cur"), default }

If the browser cannot find or load the first cursor, it tries the others in the list until one works. Make the last cursor in the list a standard cursor.

Internet Explore doesn't support the use of urls for cursor files yet.

Be careful with cursors. Don't change them just for the sake of it. Users expect to see particular cursors in particular circumstances situations. If you change the cursor or change how you use a standard cursor (for example, using the help cursor over your hyperlinks, instead of the pointer cursor), you'll just confuse and annoy people.