HTML Attributes Reference
HTML Attribute Reference
The table below lists of all HTML attributes:
Attribute | Belongs to | Description |
---|---|---|
accept | <input> | Specifies the types of files that the server accepts (only allowed for type="file") |
accept-charset | <form> | Specifies the character encodings that are to be used for the form submission. |
accesskey | Global Attributes | Specifies a shortcut key to activate/focus an element. |
action | <form> | Specifies to send the form data when a form is submitted. |
align | <caption>, <img>, <table>, <hr>, <div>, <h1> - <h6>, <p> | Deprecated Specifies the alignment of the elements. |
alink | <body> | Deprecated Specifies the active link color in a document |
alt | <area>, <img>, <input> | Specifies an alternate text. |
async | <script> | Specifies that the script is executed asynchronously. |
autocomplete | <form>, <input> | Specifies the element should have autocomplete enabled. |
autofocus | <button>, <input>, <select>, <textarea> | Specifies the element should automatically get focus when the page loaded. |
autoplay | <audio>, <video> | Specifies the audio/video will start playing when page is loaded. |
background | <body> | Deprecated Specifies the background image. |
bgcolor | <body>, <table>, <tr>, <td>, <th> | Deprecated Specifies the background color of an element. |
border | <img>, <object> | Deprecated Specifies the width of the border of an element. |
charset | <meta>, <script> | Specifies the character encoding. |
checked | <input> | Specifies the <input> element should be pre-selected when the page loads. (only work for type="checkbox" or type="radio") |
cite | <blockquote>, <del>, <ins>, <q> | Specifies the URL which explains the quote/deleted/inserted text. |
class | Global Attributes | Specifies one or more classNames for an element. |
clear | <br> | Deprecated Clears any right or left alignments. |
color | All visible elements | Deprecated Specifies the text color of an element. |
cols | <textarea> | Specifies the width of a text area. |
colspan | <td>, <th> | Specifies the number of columns a table cell should be span. |
content | <meta> | Specifies the value associated with the http-equiv or name attribute. |
contenteditable | Global Attributes | Specifies the content of an element is to be editable or not. |
controls | <audio>, <video> | Specifies that audio/video controls should be displayed. |
compact | <ol>, <ul> | Deprecated Specifies the list should render smaller than normal. |
coords | <area> | Specifies the coordinates of the area. |
data | <object> | Specifies the URL of the resource to be used by the object |
data-* | Global Attributes | This attribute is used to store custom data private to the page or application. |
datetime | <del>, <ins>, <time> | Specifies the date and time. |
default | <track> | Specifies the track is to be enabled if the user's preferences do not specifies that another track would be more appropriate. |
defer | <script> | Specifies the script is executed when the page has finished parsing. [only for external scripts] |
dir | Global Attributes | Specifies the text direction for the content in an element |
dirname | <input>, <textarea> | Specifies the text direction of element will be submitted. |
disabled | <button>, <fieldset>, <input>, <optgroup>, <option>, <select>, <textarea> | Specifies the element/group of elements should be disabled. |
download | <a>, <area> | Specifies the target will be downloaded when a user clicks on the hyperlink. |
draggable | Global Attributes | The draggable attribute is used to set whether or not an element is draggable. |
enctype | <form> | Specifies how form data should be encoded before being sent to the server. |
for | <label>, <output> | Specifies the id for the form control element. |
form | <button>, <fieldset>, <input>, <label>, <meter>, <object>, <output>, <select>, <textarea> | Specifies that corresponds to the id of the form element is associated with. |
formaction | <button>, <input> | Specifies where to send the form-data. |
headers | <td>, <th> | Specifies a space-separated list of id values that correspond to the header cells related to this cell. |
height | <canvas>, <embed>, <iframe>, <img>, <input>, <object>, <video> | Specifies the height of the element. |
hidden | Global Attributes | The hidden attribute is a Boolean, or presence-based, attribute that does not require a value. |
high | <meter> | Specifies the lower numeric bound of the high end of the measured range. |
href | <a>, <area>, <base>, <link> | Specifies the Hyperlink of the page used to navigate. |
hreflang | <a>, <area>, <link> | Specifies the language of the hyperlinked page or document. |
hspace | <img>, <object> | Deprecated Specifies the whitespace or padding on left or right sides of an element. |
http-equiv | <meta> | The http-equiv attribute binds the meta-information in the content attribute to an equivalent HTTP response header. |
id | Global Attributes | Specifies a unique alphanumeric identifier to be associated with an element. |
ismap | <img> | Specifies that the image is a server-side image map. |
kind | <track> | Specifies how the text track is meant to be used. |
label | <track>, <option>, <optgroup> | Specifies title of the text track. |
lang | Global Attributes | Specifies the language being used for the enclosed content. |
language | <script> | Deprecated Specifies scripting language. |
list | <input> | Specifies id of a datalist element used to provide a predefined list of options suggested to the user for entry. |
link | <body> | Deprecated Specifies the default color of the links. |
loop | <audio>, <video> | Specifies that the audio and video should loop. |
low | <meter> | Specifies a numeric value that is the high range allowed in the form control. |
max | <input>, <meter>, <progress> | Specifies the maximum value |
maxlength | <input>, <textarea> | Specifies the maximum content length that can be entered in a text form control. |
media | <a>, <area>, <link>, <source>, <style> | Specifies what media/device the linked document is optimized for |
method | <form> | Specifies how form information should be transferred to the server using a particular HTTP method. |
min | <input>, <meter> | Specifies a minimum value. |
minlength | <input>, <textarea> | Specifies the mainimum content length that can be entered in a text form control. |
multiple | <input>, <select> | Specifies that a user can enter more than one value or items. |
muted | <video>, <audio> | Specifies the default setting of the audio contained in the video or audio elements. |
name | <button>, <fieldset>, <form>, <iframe>, <input>, <map>, <meta>, <object>, <output>, <param>, <select>, <textarea> | Specifies the name of the element. |
novalidate | <form> | Specifies that whether or not form validation should be applied on the elements within. |
noshade | <hr> | Deprecated It specifies that a horizontal line should render in one solid color (noshaded). |
nowrap | <td>, <th> | Deprecated Specifies that the text should not wrap within the table cell. |
onabort | <audio>, <embed>, <img>, <object>, <video> | Script to run when the loading of an audio/video is aborted. |
onafterprint | <body> | Script to be run after the document is printed. |
onbeforeprint | <body> | Script to be run before the document is printed. |
onbeforeunload | <body> | Script to be run when the document is about to be unloaded. |
onblur | All visible elements. | Script to be run when the element loses focus. |
oncanplay | <audio>, <embed>, <object>, <video> | Script to be run when a file is ready to start playing. |
oncanplaythrough | <audio>, <video> | Script to be run when the browser can play through the audio/video without stopping for buffering. |
onchange | All visible elements. | Script to be run when the value of the element is changed. |
onclick | All visible elements. | Script to be run when the element has been clicked. |
oncontextmenu | All visible elements. | Script to be run when a context menu is triggered. |
oncopy | All visible elements. | Script to be run when the content of the element has been copied. |
oncuechange | <track> | The oncuechange attribute specifies a script to run when the cue changes in a <track> element. |
oncut | All visible elements. | Script to be run when the user cuts the content of an element. |
ondblclick | All visible elements. | Script to be run when the element is being double-clicked by user. |
ondrag | All visible elements. | Script to be run when the element is being dragged. |
ondragend | All visible elements. | Script to be run when the end of a drag. |
ondragenter | All visible elements. | Script to be run when an element has been dragged to a valid drop target. |
ondragleave | All visible elements. | Script to be run when an element leaves a valid drop target. |
ondragover | All visible elements. | Script to be run when an element is being dragged over a valid drop target. |
ondragstart | All visible elements. | Script to be run at the start of a drag. |
ondrop | All visible elements. | Script to be run when dragged element has been dropped. |
ondurationchange | <audio>, <video> | Script to be fired when the length of the media changes. |
onemptied | <audio>, <video> | Script to be fired when something went wrong and the file is unavailable. |
onended | <audio>, <video> | Script to be fired when the media has reach the end. |
onerror | <audio>, <body>, <embed>, <img>, <object>, <script>, <style>, <video> | Script to be fired when an error occurs. |
onfocus | All visible elements. | Script to be fired when the element gets focus. |
onhashchange | <body> | Script to be fired when the URL’s hash identifier value changes. |
oninput | All visible elements. | Script to be fired when the element gets user input. |
oninvalid | All visible elements. | Script to be fired when the element is invalid. |
onkeydown | All visible elements. | Script to be fired when a user is pressing a key. |
onkeypress | All visible elements. | Script to be fired when a user presses a key. |
onkeyup | All visible elements. | Script to be fired when a user releases a key. |
onload | <body>, <iframe>, <img>, <input>, <link>, <script>, <style> | Script to be fired when the element is finished loading. |
onloadeddata | <audio>, <video> | Script to be fired when media data is loaded. |
onloadedmetadata | <audio>, <video> | Script to be fired when meta data are loaded. |
onloadstart | <audio>, <video> | Script to be fired just when the file begins to load before actually loaded. |
onmousedown | All visible elements. | Script to be fired when a mouse button is pressed down on an element. |
onmousemove | All visible elements. | Script to be fired as long as the mouse pointer is moving over an element. |
onmouseout | All visible elements. | Script to be fired when a mouse pointer moves out of an element. |
onmouseover | All visible elements. | Script to be fired when a mouse pointer moves over an element. |
onmouseup | All visible elements. | Script to be fired when a mouse button is released over an element. |
onmousewheel | All visible elements. | Deprecated Script to be fired when a mouse wheel is being scrolled over an element. |
onoffline | <body> | Script to be fired when the user agent goes back offline. |
ononline | <body> | Script to be fired when the user agent goes back online. |
onpagehide | <body> | Script to be fired when a user navigates away from a page. |
onpageshow | <body> | Script to be fires when a suspended page is shown again. |
onpaste | All visible elements. | Script to be fires when the user pastes some text in an element. |
onpause | <audio>, <video> | Script to be fired when the media is paused. |
onplay | <audio>, <video> | Script to be fired when the media has started playing. |
onplaying | <audio>, <video> | Script to be run when the media has started playing. |
onpopstate | <body> | Script to be run when the window history changes. |
onprogress | <audio>, <video> | Script to be run when the browser is getting the media data. |
onratechange | <audio>, <video> | Script to be run each time the playback rate changes. |
onreset | <form> | Script to be run when a reset button is clicked in a form element. |
onresize | <body> | Script to be run when the browser window has been resized. |
onscroll | All visible elements. | Script to be run when an element's scrollbar is being scrolled. |
onsearch | <input> | Script to be run when the user writes in a search field. |
onseeked | <audio>, <video> | Script to be run when the user is finished moving/skipping to a new position in the audio/video. |
onseeking | <audio>, <video> | Script to be run when the user starts moving/skipping to a new position in the audio/video. |
onselect | All visible elements. | Script to be run when the element is selected. |
onstalled | <audio>, <video> | Script to be run when the browser is unable to fetch the media data. |
onstorage | <body> | Script to be run when a Web Storage area is updated. |
onsubmit | <form> | Script to be run when a form is submitted. |
onsuspend | <audio>, <video> | Script to be run when fetching the media data is stopped before it is completely loaded. |
ontimeupdate | <audio>, <video> | Script to be run when the playing position has been changed. |
ontoggle | <details> | Script to be run when the user opens or closes the <details> element. |
onunload | <body> | Script to be run when a page has unloaded. |
onvolumechange | <audio>, <video> | Script to be run each time the volume of a audio/video has been changed. |
onwaiting | <audio>, <video> | Script to be run when the media has paused but it might be resume. |
onwheel | All visible elements. | Script to be run when the mouse wheel rolls up or down over an element. |
open | <details>, <dialog> | Specifies that the detail/dialog element should be open(visible) to the user. |
optimum | <meter> | Specifies what value is the optimal value for the gauge. |
pattern | <input> | Specifies a regular expression that the value is checked against. |
placeholder | <input>, <textarea> | Specifies a short bit of text that is used to help the user figure out what type of information to fill in for a form control. |
poster | <video> | Specifies an image to be shown while the user hits the play button. |
preload | <audio>, <video> | Specifies if and how the author thinks the audio/video should be loaded when the page loads. |
readonly | <input>, <textarea> | Specifies that the element is read-only. |
rel | <a>, <area>, <form>, <link> | Specifies the relationship between the current document and the linked page. |
required | <input>, <select>, <textarea> | Specifies that the element must be filled out before submitting the form. |
reversed | <ol> | Specifies that the list order should be descending (3,2,1). |
rows | <textarea> | Specifies the visible number of lines in a text area. |
rowspan | <td>, <th> | Specifies the number of rows a table cell should span. |
sandbox | <iframe> | Enables an extra set of restrictions for the content in an <iframe>. |
scope | <th> | Specifies whether a header cell is a header for a column, row, or group of columns or rows. |
selected | <option> | Specifies that an option should be pre-selected when the page loads. |
shape | <area> | Specifies the shape of the area. |
size | <input>, <select> | Specifies the visible dimension, in characters, of a text form control. |
sizes | <img>, <link>, <source> | Specifies the size of the linked resource. |
span | <col>, <colgroup> | Specifies the number of columns to span. |
spellcheck | Global Attributes | Specifies whether the element is to have its spelling and grammar checked or not. |
src | <audio>, <embed>, <iframe>, <img>, <input>, <script>, <source>, <track>, <video> | Specifies the URL of the media file. |
srcdoc | <iframe> | Specifies the HTML content of the page to show in the <iframe>. |
srclang | <track> | Specifies the language of the track text data. |
srcset | <img>, <source> | Specifies one or more strings separated by commas, indicating possible image sources for the user agent to use. |
start | <ol> | Specifies the start value of an ordered list. |
step | <input> | Specifies the legal number intervals for an input field. |
style | Global Attributes | Specifies an inline CSS style for an element. |
tabindex | Global Attributes | Specifies the tabbing order of an element. |
target | <a>, <area>, <base>, <form> | Specifies the target for where to open the linked document or where to submit the form. |
title | Global Attributes | It used to provide advisory text about an element or its contents. |
translate | Global Attributes | Specifies the content of an element should be translated or not. |
type | <a>, <button>, <embed>, <input>, <link>, <menu>, <object>, <script>, <source>, <style> | Specifies the media type in the form of a MIME type. |
usemap | <img>, <object> | Specifies the URL of the image map to be used with the object/image. |
value | <button>, <input>, <li>, <option>, <meter>, <progress>, <param> | Specifies the value for elements(initial value for some elements). |
width | <canvas>, <embed>, <iframe>, <img>, <input>, <object>, <video> | Specifies the width of an element. |
wrap | <textarea> | Specifies how the control wraps text. |