Elements
HTML
Attributes
Sample
<html>
<head>
<title>Attributes</title>
</head>
<body>
<p style="color:red">Attributes</p>
<img alt="Happy Face" src="/assets/jpg/HappyFace.jpg" width="200px">
</body>
</html>
| Name: | Value: |
| style | color:red |
| alt | Happy Face |
| src | /assets/jpg/HappyFace.jpg |
| width | 200px |
Example
List
Attributes may be specific to an HTML element or common to all HTML elements.
| Specific: | ||
| Name: | Value: | Description: |
| accept | mime-type list | Provides the UA with a hint of what file types the server is able to accept |
| accept-charset | character-encoding name list | Specifies the character encodings used for form submission |
| action | URI | Submission action for the form |
| alt | normal character data | Fallback content for the image map |
| async | async | empty | Specifies that the script should be executed asynchronously, as soon as it becomes available - HTML5 |
| autocomplete | on | off | Specifies whether the element represents an input control for which a UA is meant to store the value entered by the user (so that the UA can prefill the form later) - HTML5 |
| autofocus | autofocus | empty | Specifies that the element represents a control to which a UA is meant to give focus as soon as the document is loaded - HTML5 |
| autoplay | autoplay | empty | Instructs the UA to automatically begin playback of the audio stream as soon as it can do so without stopping |
| challenge | string | Challenge string that is submitted along with the public key |
| charset | character encoding name | Specifies a character encoding name - HTML5 |
| charset | character encoding name | Character encoding of the external script |
| checked | checked | empty | Specifies that the element represents a selected control |
| cite | URI | URL referencing the original source for the quoted material |
| cols | positive integer | Expected maximum number of characters per line of text for the UA to show |
| colspan | positive integer | Specifies the number of adjacent columns "spanned" by its td element |
| content | string | Specifies the value part of a name/value pair |
| controls | controls | empty | Instructs the UA to expose a user interface for controlling playback of the audio stream |
| coords | circle | polygon | rectangle | Coordinates for the shape on the image map |
| data | URI | Address of the content |
| datetime | date-time | Time and date when the text was added/deleted |
| datetime | date or time | Specifies the date or time that the element represents |
| defer | defer | empty | Specifies that script should be executed after the document has been parsed |
| disabled | disabled | empty | Specifies that the element represents a disabled control |
| enctype | application/x-www-form-urlencoded | multipart/form-data | text/plain | MIME type with which a UA is meant to associate the form contents for form submission |
| for | IDREF | Identifies a form control for which the label is a caption |
| for | IDREFS | Identifies one or more elements associated with the calculation whose result this output element represents |
| form | IDREF | Identifies a form with which to associate the element - HTML5 |
| formaction | URI | Form-submission action for the element - HTML5 |
| formenctype | application/x-www-form-urlencoded | multipart/form-data | text/plain | MIME type with which a UA is meant to associate this element for form submission - HTML5 |
| formmethod | get | post | put | delete | HTTP method with which a UA is meant to associate this element for form submission - HTML5 |
| formnovalidate | formnovalidate | empty | Specifies that the element represents a control whose value is not meant to be validated during form submission - HTML5 |
| formtarget | browsing-context name or keyword | Browsing context or keyword that represents the target of the control - HTML5 |
| headers | IDREFS | Identifies one or more th elements that apply to its td |
| height | non-negative integer | Height of the canvas in CSS pixels |
| high | float | Point that marks the lower boundary of the "high" segment of the meter |
| href | URI | URL that provides the destination of the hyperlink |
| href | URI | Base URL for the document |
| hreflang | language tag | Language of the destination of the hyperlink |
| http-equiv | refresh | Indicates that the meta element is a pragma directive that specifies either a number of seconds after which to reload the current page, or a number of seconds after which to load a different page in place of the current page, and the URL for the replacement page |
| icon | URI | URL for an image that represents the command |
| ismap | ismap | empty | Specifies that its img element provides access to a server-side image map |
| keytype | rsa | Type of key generated |
| label | string | Specifies the label of the element |
| list | IDREF | Identifies a datalist with which to associate the element - HTML5 |
| loop | loop | empty | Instructs the UA to seek back to the start of the audio stream upon reaching the end |
| low | float | Point that marks the upper boundary of the "low" segment of the meter |
| manifest | URI | Address of the document's application cache manifest (which controls caching of content for offline use) - HTML5 |
| max | date-time | local date-time | date | month | time | week | float | Expected upper bound for the element's value - HTML5 |
| max | float | Upper bound of the range |
| maxlength | positive integer | Maximum allowed value length of the element |
| media | media query list | Media for which the destination of the hyperlink was designed - HTML5 |
| method | get | post | put | delete | HTTP method with which a UA is meant to associate this element for form submission |
| min | date-time | local date-time | date | month | time | week | float | Expected lower bound for the element's value - HTML5 |
| min | float | Lower bound of the range |
| multiple | multiple | empty | Specifies that the element allows multiple values - HTML5 |
| name | string | Name part of the name/value pair associated with this element for the purposes of form submission |
| name | browsing-context name | Valid browsing context name |
| name | name | Name by which the map can be referenced |
| name | string | Specifies the name part of a name/value pair |
| name | string | Name of the parameter |
| novalidate | novalidate | empty | Specifies that the element represents a form that is not meant to be validated during form submission - HTML5 |
| onafterprint | string | Handles the event after printing |
| onbeforeprint | string | Handles the event before printing |
| onbeforeunload | string | Handles the event when the page is about to be unloaded, in case the page would like to show a warning prompt |
| onhashchange | string | Handles the event when the fragment identifier part of the document's current address changes |
| onmessage | string | Handles the event when the object receives a message |
| onoffline | string | Handles the event when the network connections fails |
| ononline | string | Handles the event when the network connections returns |
| onpagehide | string | Handles the event when the page's entry in the session history stops being the current entry |
| onpageshow | string | Handles the event when the page's entry in the session history becomes the current entry |
| onpopstate | string | Handles the event when the user navigates the session history |
| onredo | string | Handles the event when the user goes forward in the undo transaction history |
| onresize | string | Handles the event when the page is resized |
| onstorage | string | Handles the event when storage occurs |
| onundo | string | Handles the event when the user goes backward in the undo transaction history |
| onunload | string | Handles the event when the page is going away |
| open | open | empty | Specifies that the contents of the details element should be shown to the user |
| optimum | float | Point that marks the "optimum" position for the meter |
| pattern | pattern | Specifies a regular expression against which a UA is meant to check the value of the control represented by its element - HTML5 |
| ping | list of URIs | List of URLs to notify if a user follows the hyperlink - HTML5 |
| placeholder | string | Short hint (one word or a short phrase) intended to aid the user when entering data into the control represented by its element - HTML5 |
| poster | URI | Address of an image file for the UA to show while no video data is available |
| preload | preload | empty | Instructs the UA that downloading the entire audio stream optimistically is considered worthwhile |
| pubdate | pubdate | empty | Indicates that the date and time given by the element is the publication date and time of the nearest ancestor article element - or, if the element has no ancestor article element, of the document as a whole |
| radiogroup | string | Name of the group of commands that will be toggled when the command itself is toggled |
| readonly | readonly | empty | Specifies that element represents a control whose value is not meant to be edited |
| rel | tokens | List of tokens that specify the relationship between the document containing the hyperlink and the destination indicated by the hyperlink |
| required | required | empty | Specifies that the element is a required part of form submission - HTML5 |
| reversed | reversed | empty | Descending list if present, ascending list if not present - HTML5 |
| rows | positive integer | Number of lines of text for the UA to show |
| rowspan | non-negative integer | Specifies the number of following rows "spanned" by its td element |
| sandbox | sandbox allow list | Instructs the UA to enable a set of extra restrictions on any content hosted by the iframe - HTML5 |
| scope | row | col | rowgroup | colgroup | Specifies what set of cells the th element applies to |
| scoped | scoped | empty | Indicates that the specified style information is meant to apply only to the style element's parent element, and that element's child nodes. Otherwise, the specified styles are meant to apply to the entire document - HTML5 |
| seamless | seamless | empty | Instructs the UA that the iframe element's browsing context is to be rendered in a manner that makes it appear to be part of the containing document (seamlessly included in the parent document) - HTML5 |
| selected | selected | empty | Specifies that this option is pre-selected |
| shape | circle | polygon | rectangle | default | Specifies the shape of the area for the hyperlink on the image map |
| size | positive integer | Number of options meant to be shown by the control represented by its element |
| sizes | any | sizes | Sizes of icons for visual media - HTML5 |
| span | positive integer | Number of columns in the group |
| src | URI | URL for the audio stream |
| srcdoc | iframe srcdoc | Content of the page that the nested browsing context is to contain - HTML5 |
| start | integer | Ordinal value of the first list item |
| step | any | positive float | positive integer | Specifies the value granularity of the element's value - HTML5 |
| summary | string | Prose description of the structure of the table |
| target | browsing-context name or keyword | Name or keyword giving a browsing context for UAs to use when following the hyperlink |
| target | browsing-context name or keyword | Browsing context name or keyword for use in following hyperlinks - HTML5 |
| target | browsing-context name or keyword | Browsing context or keyword that represents the target of the form |
| type | MIME type | MIME type of the destination of the hyperlink |
| type | submit | reset | button | Specifies that its button element is a button for submitting a form, for resetting a form, or with no additional semantics |
| type | button | checkbox | color | date | datetime | datetime-local | email | file | hidden | image | month | number | password | radio | range | reset | search | submit | tel | text | time | url | week | Specifies that its input element is a one-line plain-text edit control for the input element's value |
| type | command | radio | checkbox | Specifies that its command element is a command with an associated action, represents a selection of one item from a list of items, or represents a state or option that can be toggled |
| type | MIME type | MIME type of the content |
| type | toolbar | context | Kind of menu being declared |
| usemap | hash-name reference | Hash-name reference to a map element with which to associate the image |
| value | string | Specifies a value |
| value | string | Specifies a value for this input element |
| value | integer | Ordinal value of the list item. Permitted only if the li element is a child of an ol element |
| value | float | Measured value shown by meter |
| value | string | Value of the parameter |
| width | non-negative integer | Width of the canvas in CSS pixels |
| wrap | hard | soft | Instructs the UA to insert line breaks, or no line breaks, into the submitted value of the textarea, such that each line has no more characters than the value specified by the cols attribute |
| Common: | ||
| Name: | Value: | Description: |
| accesskey | key label list | Key label or list of key labels with which to associate the element; each key label represents a keyboard shortcut which UAs can use to activate the element or give focus to the element |
| class | tokens | Name of a classification, or list of names of classifications, to which the element belongs |
| contenteditable | true | false | empty | Specifies whether the contents of the element are editable - HTML5 |
| contextmenu | IDREF | Identifies a menu with which to associate the element as a context menu - HTML5 |
| dir | ltr | rtl | Specifies the element's text directionality |
| draggable | true | false | Specifies whether the element is draggable - HTML5 |
| hidden | hidden | empty | Specifies that the element represents an element that is not yet, or is no longer, relevant - HTML5 |
| id | ID | Unique identifier for the element |
| lang | language tag | Specifies the primary language for the contents of the element and for any of the element's attributes that contain text |
| onabort | string | Handles the event when the download is aborted by the user |
| onblur | string | Handles the event losing focus |
| oncanplay | string | Handles the event when the user agent can resume playback of the media data, but estimates that if playback were to be started now, the media resource could not be rendered at the current playback rate up to its end without having to stop for further buffering of content |
| oncanplaythrough | string | Handles the event when the user agent estimates that if playback were to be started now, the media resource could be rendered at the current playback rate all the way to its end without having to stop for further buffering |
| onchange | string | Handles the event when the user commits a value change |
| onclick | string | Handles the event when the user clicks the mouse |
| oncontextmenu | string | Handles the event when the user requests their context menu |
| ondblclick | string | Handles the event when the user double-clicks the mouse |
| ondrag | string | Handles the event when the drag is in progress |
| ondragend | string | Handles the event when the drag is completed |
| ondragenter | string | Handles the event when the drag object enters an area |
| ondragleave | string | Handles the event when the drag object leaves an area |
| ondragover | string | Handles the event when the drag object is over an area |
| ondragstart | string | Handles the event when the drag is initiated |
| ondrop | string | Handles the event when the drag object is released |
| ondurationchange | string | Handles the event when the duration attribute has just been updated |
| onemptied | string | Handles the event when a media element whose networkState was previously not in the NETWORK_EMPTY state has just switched to that state (either because of a fatal error during load that's about to be reported, or because the load() method was invoked while the resource selection algorithm was already running) |
| onended | string | Handles the event when playback has stopped because the end of the media resource was reached |
| onerror | string | Handles the event when network and script errors occur |
| onfocus | string | Handles the event gaining focus |
| onformchange | string | Handles the event when the user commits a value change to a control on the form |
| onforminput | string | Handles the event when the user changes the value of a control on the form |
| oninput | string | Handles the event when the user changes the value |
| oninvalid | string | Handles the event during form validation if they do not satisfy their constraints |
| onkeydown | string | Handles the event when the key is down |
| onkeypress | string | Handles the event when the key is pressed |
| onkeyup | string | Handles the event when the key is up |
| onload | string | Handles the event when the document has finished loading; fired at an element containing a resource (e.g. img, embed) when its resource has finished loading |
| onloadeddata | string | Handles the event when the user agent can render the media data at the current playback position for the first time |
| onloadedmetadata | string | Handles the event when the user agent has just determined the duration and dimensions of the media resource |
| onloadstart | string | Handles the event when the user agent begins looking for media data, as part of the resource selection algorithm |
| onmousedown | string | Handles the event when the user presses the mouse button |
| onmousemove | string | Handles the event when the user moves the mouse |
| onmouseout | string | Handles the event when user moves the mouse icon outside the object |
| onmouseover | string | Handles the event when the user moves the mouse icon over the object |
| onmouseup | string | Handles the event when the user releases the mouse button |
| onmousewheel | string | Handles the event when the user moves the mouse wheel |
| onpause | string | Handles the event when playback has been paused. Fired after the pause method has returned |
| onplay | string | Handles the event when playback has begun. Fired after the play() method has returned |
| onplaying | string | Handles the event when playback has started |
| onprogress | string | Handles the event when the user agent is fetching media data |
| onratechange | string | Handles the event when either the defaultPlaybackRate or the playbackRate attribute has just been updated |
| onreadystatechange | string | Handles the event when it finishes parsing and again when all its subresources have finished loading |
| onscroll | string | Handles the event when it is scrolled |
| onseeked | string | Handles the event when the seeking IDL attribute changed to false |
| onseeking | string | Handles the event when the seeking IDL attribute changed to true and the seek operation is taking long enough that the user agent has time to fire the event |
| onselect | string | Handles the event when it is selected |
| onshow | string | Handles the event when it is shown as a context menu |
| onstalled | string | Handles the event when the user agent is trying to fetch media data, but data is unexpectedly not forthcoming |
| onsubmit | string | Handles the event when it is submitted |
| onsuspend | string | Handles the event when the user agent is intentionally not currently fetching media data, but does not have the entire media resource downloaded |
| ontimeupdate | string | Handles the event when the current playback position changed as part of normal playback or in an especially interesting way, for example discontinuously |
| onvolumechange | string | Handles the event when either the volume attribute or the muted attribute has changed. Fired after the relevant attribute's setter has returned |
| onwaiting | string | Handles the event when playback has stopped because the next frame is not available, but the user agent expects that frame to become available in due course |
| spellcheck | true | false | empty | Specifies whether the element represents an element whose contents are subject to spell checking and grammar checking - HTML5 |
| style | string | Specifies zero or more CSS declarations that apply to the element |
| tabindex | integer | Specifies whether the element represents an element that is is focusable (that is, an element which is part of the sequence of focusable elements in the document), and the relative order of the element in the sequence of focusable elements in the document |
| title | normal character data | Advisory information associated with the element |
