Affiliate link
HTML Reference - Attributes
List of attributes to define in HTML element/tag.
HTML Attributes List
| Attribute | Element/tag | Description |
|---|---|---|
| accept | <input> | Type of file that <input type="file" /> can accept |
| accept-charset | <form> | <form> character encodings for submission |
| accesskey | Global Attributes | Shortcut key to activate/focus an element |
| action | <form> | Define the web url to send the form-data when a form is submitted |
| align | Not supported in HTML 5. | Use CSS alignment |
| alt | <area>, <img>, <input> | Shortcut key to activate/focus an element |
| async | <script> | Script is executed asynchronously (only for loading external script file) |
| autocomplete | <form>, <input> | Define whether <form> or the <input> element should have autocomplete enabled |
| autofocus | <button>, <input>, <select>, <textarea> | Automatic focus on the element when the page loaded |
| autoplay | <audio>, <video> | Autoplay audio/video when the resource is ready to play |
| bgcolor | Not supported in HTML 5. | Use CSS background color |
| border | Not supported in HTML 5. | Use CSS border |
| charset | <meta>, <script> | Define the character encoding for HTML document or JavaScript file |
| checked | <input> | Define <input type="checkbox"> and <input type="radio"> elements is checked/selected. |
| cite | <blockquote>, <del>, <ins>, <q> | Define <input type="checkbox"> and <input type="radio"> elements is checked/selected. |
| class | Global Attributes | Define the class name for HTML elements |
| color | Not supported in HTML 5. | Use CSS font color |
| cols | <textarea> | Width of textarea element |
| colspan | <td>, <th> | Number of columns a table cell spans |
| content | <meta> | The value of the meta tag |
| contenteditable | Global Attributes | Define whether the content of the element is editable |
| controls | <audio>, <video> | Define whether the controls (eg, play, pause, mute) of audio/video playback will be displayed |
| coords | <area> | Coordinates of the area |
| data | <object> | URL of resource to be loaded for object element |
| data-* | Global Attributes | Custom data attributes for web application |
| datetime | <del>, <ins>, <time> | Date time |
| default | <track> | Default track to be enabled |
| defer | <script> | Defer external script execution until page loaded |
| dir | Global Attributes | Text direction for the content in HTML element |
| dirname | <input>, <textarea> | Text direction for the content to be submitted in form |
| disabled | <button>, <fieldset>, <input>, <label>, <meter>, <object>, <output>, <select>, <textarea> | Define whether the element is disabled |
| download | <a>, <area> | Define whether the link is download targer url resource |
| draggable | Global Attributes | Define whether an element is draggable |
| enctype | <form> | Define the encoding type for HTML form |
| for | <label>, <output> | Define the HTML form element that the label/output element is bound to |
| form | <button>, <fieldset>, <input>, <label>, <meter>, <object>, <output>, <select>, <textarea> | Define the name of the HTML form element |
| formaction | <button>, <input> | Define the form action url for button/input type="submit" |
| headers | <td>, <th> | Define the headers cell a td/th cell is related to |
| height | <canvas>, <embed>, <iframe>, <img>, <input>, <object>, <video> | Define the height of the element |
| hidden | Global Attributes | Define whether the element is hidden from displaying |
| high | <meter> | Define the high range value |
| href | <a>, <area>, <base>, <link> | Define the url link to navigate to |
| hreflang | <a>, <area>, <link> | Define the language of the web page the url linked to |
| http-equiv | <meta> | Define the HTTP header for the content of meta element |
| id | Global Attributes | Define the unqiue id for an HTML element |
| ismap | <img> | Define image as a server-side image map |
| kind | <track> | Define the kind of the track |
| label | <track>, <option>, <optgroup> | Define the title of the track |
| lang | Global Attributes | Define the language for the content of an HTML element |
| list | <input> | Define the id of the datalist element which contains the list of input values |
| loop | <audio>, <video> | Define whether the audio/video element playback loop |
| low | <meter> | Define the low range value |
| max | <input>, <meter>, <progress> | Define the maximum value |
| maxlength | <input>, <textarea> | Define the maximum number of characters allowed |
| media | <a>, <area>, <link>, <source>, <style> | Define the type of media device targeted for the url link to be navigated to |
| method | <form> | Define the HTTP method for submitting form data |
| min | <input>, <meter> | Define the minimum value |
| multiple | <input>, <select> | Define the element can accept multiple values |
| muted | <audio>, <video> | Define the element can accept multiple values |
| name | <button>, <fieldset>, <form>, <iframe>, <input>, <map>, <meta>, <object>, <output>, <param>, <select>, <textarea> | Define the name of the element |
| novalidate | <form> | Define whether the form element require validation |
| onabort | <audio>, <embed>, <img>, <object>, <video> | JavaScript function to be called when abort loading the element |
| onafterprint | <body> | JavaScript function to be called after the web page is printed |
| onbeforeprint | <body> | JavaScript function to be called before the web page start print |
| onbeforeunload | <body> | JavaScript function to be called before the web page unload |
| onblur | Displayed elements | JavaScript function to be called after the element lose focus |
| oncanplay | <audio>, <embed>, <object>, <video> | JavaScript function to be called when the resource is ready to play |
| oncanplaythrough | <audio>, <video> | JavaScript function to be called when the resource is loaded and can play until finished |
| onchange | HTML elements | JavaScript function to be called when the content/value of the element is changed |
| onclick | Displayed elements | JavaScript function to be called when mouse left button clicked on the element |
| oncontextmenu | Displayed elements | JavaScript function to be called when mouse right button clicked on the element to display context menu |
| oncopy | HTML elements | JavaScript function to be called when the content/value of the element is copied to clipboard |
| oncuechange | <track> | JavaScript function to be called when the cue of the track is changed |
| oncut | <track> | JavaScript function to be called when the cue of the track is changed |
| ondblclick | Displayed elements | JavaScript function to be called when mouse left button double-clicked on the element |
| ondrag | Displayed elements | JavaScript function to be called when the element is being dragged |
| ondragend | Displayed elements | JavaScript function to be called when the element end dragged |
| ondragenter | Displayed elements | JavaScript function to be called when the element dragged to a valid drop target element |
| ondragleave | Displayed elements | JavaScript function to be called when the element dragged out from a valid drop target element |
| ondragover | Displayed elements | JavaScript function to be called when the element dragged over a valid drop target element |
| ondragstart | Displayed elements | JavaScript function to be called when the element start dragging |
| ondrop | Displayed elements | JavaScript function to be called when the element is dropped |
| ondurationchange | <audio>, <video> | JavaScript function to be called when the media playback duration is changed |
| onemptied | <audio>, <video> | JavaScript function to be called when the media resource is unavailable or failed to load due to error |
| onended | <audio>, <video> | JavaScript function to be called when the media resource playback is ended |
| onerror | <audio>, <body>, <embed>, <img>, <object>, <script>,<style>, <video> | JavaScript function to be called when an error happens |
| onfocus | Displayed elements | JavaScript function to be called when an element is focused |
| onhashchange | <body> | JavaScript function to be called when the hash part of the url is changed |
| oninput | Displayed elements | JavaScript function to be called when the element gets keyboard input |
| oninvalid | Form elements | JavaScript function to be called when the value of the element is invalid in form validation |
| onkeydown | Form elements | JavaScript function to be called when the user is pressing a key on the element |
| onkeypress | Form elements | JavaScript function to be called when the user presses a key on the element |
| onkeyup | Form elements | JavaScript function to be called when the user releases a key on the element |
| onload | <body>, <iframe>, <img>, <input>, <link>, <script>, <style> | JavaScript function to be called when the element or element"s resource is loaded |
| onloadeddata | <audio>, <video> | JavaScript function to be called when the media resource is loaded |
| onloadedmetadata | <audio>, <video> | JavaScript function to be called when the metadata of the media resource is loaded |
| onloadstart | <audio>, <video> | JavaScript function to be called when the media resource is starting to load |
| onmousedown | Displayed elements | JavaScript function to be called when mouse button pressed down on the element |
| onmousemove | Displayed elements | JavaScript function to be called when mouse pointer is moving on the element |
| onmouseout | Displayed elements | JavaScript function to be called when mouse pointer move out of the element |
| onmouseover | Displayed elements | JavaScript function to be called when mouse pointer move over to the element |
| onmouseup | Displayed elements | JavaScript function to be called when mouse button is released on the element |
| onmousewheel | Displayed elements | JavaScript function to be called when mouse wheel is scrolled on the element |
| onoffline | <body> | JavaScript function to be called when the web page is set to offline |
| ononline | <body> | JavaScript function to be called when the web page is set to online |
| onpagehide | <body> | JavaScript function to be called when the user navigates away from the web page |
| onpageshow | <body> | JavaScript function to be called when the user navigates to the web page |
| onpaste | Form elements | JavaScript function to be called when the copied content is pasted on the element |
| onpause | <audio>, <video> | JavaScript function to be called when the media playback is paused |
| onplay | <audio>, <video> | JavaScript function to be called when the media resource started playing |
| onplaying | <audio>, <video> | JavaScript function to be called when the media resource is playing |
| onpopstate | <body> | JavaScript function to be called when the tab/window"s history changes |
| onprogress | <audio>, <video> | JavaScript function to be called when the loading of the media resource is in progress |
| onratechange | <audio>, <video> | JavaScript function to be called when the rate of playback is changed |
| onreset | <form> | JavaScript function to be called when the form element is reset |
| onresize | <body> | JavaScript function to be called when window is being resized |
| onscroll | Displayed elements | JavaScript function to be called when element"s scrollbar is being scrolled |
| onsearch | <input> | JavaScript function to be called when the value of the input type="search" element is changed |
| onseeked | <audio>, <video> | JavaScript function to be called when the seeking property of the element is false. Means seeking has ended. |
| onseeking | <audio>, <video> | JavaScript function to be called when the seeking property of the element is true. Means seeking has started. |
| onselect | Displayed elements | JavaScript function to be called when the element gets selected |
| onstalled | <audio>, <video> | JavaScript function to be called when the browser unable to fetch the media resource |
| onstorage | <body> | JavaScript function to be called when the browser web storage is updated |
| onsubmit | <form> | JavaScript function to be called before the form is submitted |
| onsuspend | <audio>, <video> | JavaScript function to be called when the browser stop fetching the media resource |
| ontimeupdate | <audio>, <video> | JavaScript function to be called when the media playback$quot;s position is changed |
| ontoggle | <details> | JavaScript function to be called when the details element open/close |
| onunload | <body> | JavaScript function to be called when the web page is unloaded (Eg. browser/tab close) |
| onvolumechange | <audio>, <video> | JavaScript function to be called when the media playback$quot;s volume is changed |
| onwaiting | <audio>, <video> | JavaScript function to be called when the media playback$quot;s is paused to buffer media resource |
| onwheel | Displayed elements | JavaScript function to be called when mouse wheel scroll on an element |
| open | <details> | Open details element to be displayed |
| optimum | <meter> | Define the optimal value for the meter |
| pattern | <input> | Define the regular expression to validate the value of the input |
| placeholder | <input>, <textarea> | Define the hint text on the element |
| poster | <video> | Define the image url to be displayed while the media resource begins to play |
| preload | <audio>, <video> | Define the loading behaviour of the media resource (Eg, only when video metadata is loaded, or auto start download) |
| readonly | <input>, <textarea> | Define whether the element is read only, user is not allowed to change the value |
| rel | <a>, <area>, <form>, <link> | Define the relationship of current web page with the linked url |
| required | <input>, <select>, <textarea> | Define the element is required with value before form submission |
| reversed | <ol> | Define the element"s list is reversed |
| rows | <textarea> | Define the number of rows for textarea element |
| rowspan | <td>, <th> | Define the number of rows a table cell span |
| sandbox | <iframe> | Define an extra set of restrictions for the content in an iframe element |
| scope | <th> | Define whether the header cell is scoped as a header for a column, row, or group of columns or rows |
| selected | <option> | Define whether the option element is selected |
| shape | <area> | Define the shape of the area element |
| size | <input>, <select> | Define the number of visible characters/options |
| sizes | <img>, <link>, <source> | Define the size of the linked resource |
| span | <col>, <colgroup> | Define the number of columns to span |
| spellcheck | Form elements | Define whether the element has spelling/grammer check |
| src | <audio>, <embed>, <iframe>, <img>, <input>, <script>, <source>, <track>, <video> | Define the url for the media resource |
| srcdoc | <iframe> | Define the HTML/CSS/JavaScript content to display in iframe |
| srclang | <track> | Define the language of the track text metadata |
| srcset | <img>, <source> | Define the image to be loaded for different device width |
| start | <ol> | Define the start value of an ordered list |
| step | <input> | Define the number of units to increase/decrease for an input element (Eg, number, date, month, time) |
| style | Displayed elements | Define the CSS style inline for an element |
| tabindex | Displayed elements | Define the tab index for an element (Use with "Tab" key) |
| target | <a>, <area>, <base>, <form> | Define the target place to open the url or submit form |
| title | Displayed elements | Define the text to be displayed when mouse over on the element |
| translate | Displayed elements | Define whether the content can be translated |
| type | <a>, <button>, <embed>, <input>, <link>, <menu>, <object>, <script>, <source>, <style> | Define the type of the element |
| usemap | <img>, <object> | Define the image as client-side image map |
| value | <button>, <input>, <li>, <meter>, <option>, <param>, <progress> | Define the value of the element |
| width | <canvas>, <embed>, <iframe>, <img>, <input>, <object>, <video> | Define the width of the element |
| wrap | <textarea> | Define how the text will be wrapped in form submission |
Affiliate link
Affiliate link
Affiliate link





