New global attributes in HTML5.
Attribute | Value | Description |
---|---|---|
accesskey | character | Specifies a shortcut key to access an element |
class | classname | Refers to a class specified in a style sheet |
contenteditableNew | true false inherit | Specifies whether a user can edit the content of an element or not |
contextmenuNew | menu_id | Specifies a context menu for an element. The value must be the id of a <menu> element |
dir | ltr rtl auto | Specifies the text direction for the content in an element |
draggableNew | true false auto | Specifies whether a user is allowed to drag an element or not |
dropzoneNew | copy move link | Specifies what happens when dragged items/data is dropped in the element |
hiddenNew | hidden | Specifies that an element should be hidden |
id | id | Specifies a unique id for an element |
lang | language_code | Specifies the language of the element's content |
spellcheckNew | true false | Specifies if the element must have its spelling and grammar checked |
style | style_definitions | Specifies an inline style for an element |
tabindex | number | Specifies the tab order of an element |
title | text | Specifies extra information about an element |
HTML5 Global Event Attributes
HTML 4 added the ability to let events trigger actions in a browser, like starting a JavaScript when a user clicks on an element.
Below are the global event attributes that can be added to HTML5 elements to define event actions
Window Event Attributes
Events triggered for the window object (applies to the <body> tag):Attribute | Value | Description |
---|---|---|
onafterprintNew | script | Script to be run after the document is printed |
onbeforeprintNew | script | Script to be run before the document is printed |
onbeforeonloadNew | script | Script to be run before the document loads |
onblur | script | Script to be run when the window loses focus |
onerrorNew | script | Script to be run when an error occur |
onfocus | script | Script to be run when the window gets focus |
onhaschangeNew | script | Script to be run when the document has changed |
onload | script | Script to be run when the document loads |
onmessageNew | script | Script to be run when the message is triggered |
onofflineNew | script | Script to be run when the document goes offline |
ononlineNew | script | Script to be run when the document comes online |
onpagehideNew | script | Script to be run when the window is hidden |
onpageshowNew | script | Script to be run when the window becomes visible |
onpopstateNew | script | Script to be run when the window's history changes |
onredoNew | script | Script to be run when the document performs a redo |
onresizeNew | script | Script to be run when the window is resized |
onstorageNew | script | Script to be run when the document loads |
onundoNew | script | Script to be run when the document performs an undo |
onunloadNew | script | Script to be run when the user leaves the document |
Form Events
Events triggered by actions inside a HTML form (applies to all HTML5 elements, but is most common in form elements):Attribute | Value | Description |
---|---|---|
onblur | script | Script to be run when an element loses focus |
onchange | script | Script to be run when an element changes |
oncontextmenuNew | script | Script to be run when a context menu is triggered |
onfocus | script | Script to be run when an element gets focus |
onformchangeNew | script | Script to be run when a form changes |
onforminputNew | script | Script to be run when a form gets user input |
oninputNew | script | Script to be run when an element gets user input |
oninvalidNew | script | Script to be run when an element is invalid |
onreset | script | Script to be run when a form is reset Not supported in HTML5 |
onselect | script | Script to be run when an element is selected |
onsubmit | script | Script to be run when a form is submitted |
No comments:
Post a Comment