Cursor Images

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

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; }
--></style>

<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;" />
</div>

- 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; }
Example:
<style type="text/css"><!--
#ex2 {
 height: 89px;
 border: 2px solid blue;
 cursor: url('bluearrow.cur'), default;
}
--></style>

<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;
}
--></style>

<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  */
          default;
}
In this way, the style will work in all major browsers.

Daily Test with Code Example

HTML
CSS
JavaScript
PHP-MySQL
Which tag defines the clickable areas inside the image map?
<map> <img> <area>
<img src="image.jpg" usemap="#map1">
<map name="map1">
  <area shape="rect" coords="9, 120, 56, 149" href="#">
  <area shape="rect" coords="100, 200, 156, 249" href="#">
</map>
Which CSS property defines what is done if the content in a box is too big for its defined space?
display overflow position
#id {
  overflow: auto;
}
Click on the event which is triggered when the mouse is positioned over an object.
onclick onmouseover onmouseout
document.getElementById("id").onmouseover = function(){
  document.write("Have Good Life");
}
Indicate the PHP variable that contains data added in URL address after the "?" character.
$_SESSION $_GET $_POST
if(isset($_GET["id"])) {
  echo $_GET["id"];
}
CSS cursor property - Custom Cursors

Last accessed pages

  1. CSS Border (4663)
  2. innerHTML in PHP (3747)
  3. Add and Remove HTML elements and Content with jQuery (17347)
  4. CSS cursor property - Custom Cursors (3102)
  5. Remove / Get duplicate array values - Reset array keys in PHP (5853)

Top accessed pages

  1. Courses Web: PHP-MySQL JavaScript Ajax HTML CSS Flash-AS3 (45592)
  2. Read Excel file data in PHP - PhpExcelReader (34306)
  3. PHP-MySQL free course, online tutorials PHP MySQL code (34225)
  4. Get Attribute (ID, Class, Name, Title, Src) with jQuery (30806)
  5. PHP PDO - exec (INSERT, UPDATE, DELETE) MySQL (28062)