Cursor Images

The cursor property can be used to change and control the appearance of the mouse cursor.

selector { cursor: value; }
- value - specifies the type of cursor to be displayed when pointing on an elemen.
In this table there are diferent types of values that you can use for cursor property (bellow you can see some code examples):

CSS Cursors

Example, three DIVs with diferent cursor type for each one.
<style type="text/css"><!--
#ex1 div {
 float: left;
 width: 30%;
 height: 35px;
 margin: 2px;
 border: 2px solid blue;
 text-align: center;
#idiv1 { cursor: pointer; }
#idiv2 { cursor: wait; }
#idiv3 { cursor: move; }

<div id="ex1">
 <div id="idiv1">Value - pointer</div>
 <div id="idiv2">Value - wait</div>
 <div id="idiv3">Value - move</div>
 <br style="clear:left;" />

- Demo (move the mouse over each cell).
Value - pointer
Value - wait
Value - move

Cursor Images

If you want a custom cursor, you can use an image for the mouse cursor appearance. The standard image type that can be used for cursor is the ".cur" format.
To create a .cur file, you need specialized imagery software. A freely available cursor editor is the JustCursors, you can use this software to edit /create static or animated cursors. To download it, click: Download JustCursors.
Once you have the ".cur" file, use this syntax in your style sheet:
selector { cursor: url('image.cur'), default; }
<style type="text/css"><!--
#ex2 {
 height: 89px;
 border: 2px solid blue;
 cursor: url('bluearrow.cur'), default;

<div id="ex2">Cursor Image, ".cur"</div>

Demo (place your mouse over the text bellow):
Cursor Image, ".cur"

• Internet Explorer can also use ".ani" files for cursor images.
• Modern browsers, like Mozilla Firefox, Google Chrome, can use PNG images for cursor.
You can find on the net various web sites with free ".ani" images, search for: "free download ani cursor images".
Once you have an image in ".ani" format, you can conver it in ".png", then use both files in "cursor" property to make your CSS style work cross-browsers. Just look on the net for: "free convert ani png online".
To add two image files (ANI and PNG) in "cursor" property, use this syntax:
selector { cursor: url('image.ani'), url('image.png'), default; }

Example, a cursor rose:
<style type="text/css"><!--
#ex3 {
 height: 89px;
 border: 2px solid blue;
 cursor: url('rosecursor.ani'), url('rosecursor.png'), default;

<div id="ex3">Cursor Images, ".ani" (for IE), and ".png" (for modern browsers).</div>

Demo (place your mouse over the text bellow):
Cursor Images, ".ani" (for IE), and ".png" (for modern browsers).

• Click: Cursor Images to download an archive with some ".cur" and ".ani" files that you can use to test the examples presented in this tutorial.

Path to the image file

If you add the CSS code into an external ".css" file, take into account the fact that Internet Explorer interprets relative URLs as relative to the HTML document, but modern browsers (Mozilla Firefox, Google Chrome) interpret relative URLs as relative to the ".css". So, in the code in ".css" add two "url" paths for ".cur" file, one relative to the ".css" file, and other "url" relative to the HTML document in which the ".css" file is included.
For example, if the ".cur" and ".css" files are in the same folder, named "styles", and the HTML document is in a directory above this CSS file, we'll use this code in the ".css" file:
  The CUR and CSS files are in the same folder, the HTML is in a directory above this CSS file

#id {
  cursor: url('bluearrow.cur'),             /* Modern browsers    */
          url('styles/bluearrow.cur'),      /* Internet Explorer  */
In this way, the style will work in all major browsers.

Daily Test with Code Example

Which HTML5 tag is indicated to be used as container for menu with navigation links in Web site?
<section> <nav> <article>
 <li><a href="" title="CSS Course">CSS Course</a></li>
 <li><a href="" title="Flash Games">Flash Games</a></li>
Which CSS property shifts an item horizontally to the left or right of where it was?
text-align clear float
.some_class {
  width: 30%;
  float: left;
Click on the Math object method which returns x, rounded downwards to the nearest integer.
Math.ceil(x) Math.abs(x) Math.floor(x)
var num = 12.34567;
num = Math.floor(num);
alert(num);       // 12
Indicate the PHP function which returns the number of characters in string.
mb_strlen() count() stristr()
$str = "string with utf-8 chars åèö";
$nrchr = mb_strlen($str);
echo $nrchr;        // 30
CSS cursor property - Custom Cursors

Last accessed pages

  1. PHP MySQL - using MySQLi (8250)
  2. Get Duration of Audio /Video file before Upload (5808)
  3. Insert, Select and Update NULL value in MySQL (26455)
  4. Ajax-PHP Rating Stars Script (12967)
  5. Read Excel file data in PHP - PhpExcelReader (56584)

Popular pages this month

  1. Read Excel file data in PHP - PhpExcelReader (321)
  2. PhpSpreadsheet - Read, Write Excel and LibreOffice Calc files (265)
  3. Register and show online users and visitors (253)
  4. Courses Web: PHP-MySQL JavaScript Ajax HTML CSS Flash-AS3 (244)
  5. Insert, Select and Update NULL value in MySQL (157)