
- HTML Tutorial
- HTML - Home
- HTML - Overview
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Comments
- HTML - Images
- HTML - Tables
- HTML - Lists
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Frames
- HTML - Iframes
- HTML - Blocks
- HTML - Backgrounds
- HTML - Colors
- HTML - Fonts
- HTML - Forms
- HTML - Embed Multimedia
- HTML - Marquees
- HTML - Header
- HTML - Style Sheet
- HTML - Javascript
- HTML - Layouts
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- HTML - Fonts Ref
- HTML - Events Ref
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
HTML DOM Style cursor Property
The HTML DOM Style cursor property is used for setting or getting the cursor type while displaying the mouse pointer.
Following is the syntax for −
Setting the cursor property −
object.style.cursor=value
The following table demonstrates the value
Value | Description |
---|---|
alias | Thecursor indicates an alias of something is to be created |
all-scroll | Thecursor indicates that something can be scrolled in any direction |
auto | Default.The browser sets a cursor |
cell | Thecursor indicates that a cell (or set of cells) may be selected |
context-menu | Thecursor indicates that a context-menu is available |
col-resize | Thecursor indicates that the column can be resized horizontally |
copy | Thecursor indicates something is to be copied |
crosshair | Thecursor render as a crosshair |
default | Thedefault cursor |
e-resize | Thecursor indicates that an edge of a box is to be moved right (east) |
ew-resize | Indicatesa bidirectional resize cursor |
grab | Thecursor indicates that something can be grabbed |
grabbing | Thecursor indicates that something can be grabbed |
help | Thecursor indicates that help is available |
move | Thecursor indicates something is to be moved |
n-resize | Thecursor indicates that an edge of a box is to be moved up (north) |
ne-resize | Thecursor indicates that an edge of a box is to be moved up and right(north/east) |
nesw-resize | Indicatesa bidirectional resize cursor |
ns-resize | Indicatesa bidirectional resize cursor |
nw-resize | Thecursor indicates that an edge of a box is to be moved up and left(north/west) |
nwse-resize | Indicatesa bidirectional resize cursor |
no-drop | Thecursor indicates that the dragged item cannot be dropped here |
none | Nocursor is rendered for the element |
not-allowed | Thecursor indicates that the requested action will not be executed |
pointer | Thecursor is a pointer and indicates a link |
progress | Thecursor indicates that the program is busy (in progress) |
row-resize | Thecursor indicates that the row can be resized vertically |
s-resize | Thecursor indicates that an edge of a box is to be moved down (south) |
se-resize | Thecursor indicates that an edge of a box is to be moved down andright (south/east) |
sw-resize | Thecursor indicates that an edge of a box is to be moved down andleft (south/west) |
text | Thecursor indicates text that may be selected |
URL | Acomma separated list of URLs to custom cursors. Note: Alwaysspecify a generic cursor at the end of the list, in case none ofthe URL-defined cursors can be used |
vertical-text | Thecursor indicates vertical-text that may be selected |
w-resize | Thecursor indicates that an edge of a box is to be moved left (west) |
wait | Thecursor indicates that the program is busy |
zoom-in | Thecursor indicates that something can be zoomed in |
zoom-out | Thecursor indicates that something can be zoomed out |
initial | Setsthis property to its default value. |
inherit | Inheritsthis property from its parent element. |
Let us look at an example for the cursor property −
Example
<!DOCTYPE html> <html> <head> <style> #one { background-color: beige; } #two { background-color: lavender; } </style> <script> function changeCursor() { document.getElementById("one").style.cursor = "cell"; document.getElementById("two").style.cursor = "grab"; document.getElementById("Sample").innerHTML="Hover over the first paragraph to see cursor change to cell and on second to see it change to grab icon"; } </script> </head> <body> <p id="one">This is some sample text inside first paragraph.This is some sample text inside first paragraph.This is some sample text inside first paragraph.This is some sample text inside first paragraph.</p> <p id="two">This is some sample text inside second paragraph.This is some sample text inside second paragraph.This is some sample text inside second paragraph.This is some sample text inside second paragraph.</p> <p>Change the cursor property by clicking the below button</p> <button onclick="changeCursor()">Change Cursor</button> <p id="Sample"></p> </body> </html>
Output
On clicking the “Change Cursor” button, the cursor changed and the same is visible in the below screenshot −
- Related Articles
- HTML DOM Style paddingRight Property
- HTML DOM Style pageBreakAfter Property
- HTML DOM Style pageBreakInside Property
- HTML DOM Style lineHeight Property
- HTML DOM Style borderImageSlice Property
- HTML DOM Style borderImageSource Property
- HTML DOM Style borderImageWidth Property
- HTML DOM Style borderLeft Property
- HTML DOM Style borderLeftColor Property
- HTML DOM Style borderLeftStyle Property
- HTML DOM Style borderLeftWidth Property
- HTML DOM Style borderRadius Property
- HTML DOM Style borderRight Property
- HTML DOM Style borderRightColor Property
- HTML DOM Style borderRightStyle Property

Advertisements