All HTML Attributes

AttributeBelongs toDescription
idGlobal AttributesSpecifies a unique id for an element.
classGlobal AttributesSpecifies one or more classnames for an element (refers to a class in a style sheet).
styleGlobal AttributesSpecifies an inline CSS style for an element.
tabindexGlobal AttributesSpecifies the tabbing order of an element.
titleGlobal AttributesSpecifies extra information about an element.
accesskeyGlobal AttributesSpecifies a shortcut key to activate/focus an element.
contenteditableGlobal AttributesSpecifies whether the content of an element is editable or not.
contextmenuGlobal AttributesSpecifies a context menu for an element. The context menu appears when a user right-clicks on the element.
data-*Global AttributesUsed to store custom data private to the page or application.
dirGlobal AttributesSpecifies the text direction for the content in an element.
draggableGlobal AttributesSpecifies whether an element is draggable or not.
dropzoneGlobal AttributesSpecifies whether the dragged data is copied, moved, or linked, when dropped.
hiddenGlobal AttributesSpecifies that an element is not yet, or is no longer, relevant.
langGlobal AttributesSpecifies the language of the element's content.
spellcheckGlobal AttributesSpecifies whether the element is to have its spelling and grammar checked or not.
translateGlobal AttributesSpecifies whether the content of an element should be translated or not.
   
onblurAll visible elements.Script to be run when the element loses focus.
onchangeAll visible elements.Script to be run when the value of the element is changed.
onclickAll visible elements.Script to be run when the element is being clicked.
oncontextmenuAll visible elements.Script to be run when a context menu is triggered
oncopyAll visible elements.Script to be run when the content of the element is being copied.
oncutAll visible elements.Script to be run when the content of the element is being cut.
ondblclickAll visible elements.Script to be run when the element is being double-clicked.
ondragAll visible elements.Script to be run at the end of a drag operation.
ondragendAll visible elements.Script to be run at the end of a drag operation.
ondragenterAll visible elements.Script to be run when an element has been dragged to a valid drop target.
ondragleaveAll visible elements.Script to be run when an element leaves a valid drop target
ondragoverAll visible elements.Script to be run when an element is being dragged over a valid drop target.
ondragstartAll visible elements.Script to be run at the start of a drag operation.
ondropAll visible elements.Script to be run when dragged element is being dropped.
onfocusAll visible elements.Script to be run when the element gets focus.
oninvalidAll visible elements.Script to be run when the element is invalid.
onkeydownAll visible elements.Script to be run when a user is pressing a key.
onkeypressAll visible elements.Script to be run when a user presses a key.
onkeyupAll visible elements.Script to be run when a user releases a key.
onmousedownAll visible elements.Script to be run when a mouse button is pressed down on an element.
onmousemoveAll visible elements.Script to be run as long as the  mouse pointer is moving over an element.
onmouseoutAll visible elements.Script to be run when a mouse pointer moves ot of an element.
oninputAll visible elements.Script to be run when the element gets user input.
onmouseoverAll visible elements.Script to be run when a mouse pointer moves over an element.
onmouseupAll visible elements.Script to be run when a mouse button is released over an element.
onmousewheelAll visible elements.Script to be run when a mouse wheel is being scrolled over an element.
onpasteAll visible elements.Script to be run when the user pastes som content in an elements
onscrollAll visible elements.Script to be run when an element's scrollbar is being scrolled.
onselectAll visible elements.Script to be run when the element gets selected.
onwheelAll visible elements.Script to be run when the mouse wheel rolls up or down over an element.
alignNot supported in HTML 5.Specifies the alignment according to surrounding elements. Use CSS instead.
bgcolorNot supported in HTML 5.Specifies the background color of an element. Use CSS instead.
borderNot supported in HTML 5.Specifies the width of the border of an element. Use CSS instead.
colorNot supported in HTML 5.Specifies the text color of an element. Use CSS instead.
   
onload<body>, <iframe>, <img>, <input>, <link>, <script>, <style>Script to be run when the element is finished loading.
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.
onhashchange<body>Script to be run when there has been changes to the anchor part of the a URL.
onoffline<body>Script to be run when the browser starts to work offline
ononline<body>Script to be run when the browser starts to work online
onpagehide<body>Script to be run when a user navigates away from a page.
onpageshow<body>Script to be run when a user navigates to a page
onpopstate<body>Script to be run when the window's history changes.
onresize<body>Script to be run when the browser window is being resized.
onstorage<body>Script to be run when a Web Storage area is updated.
onunload<body>Script to be run when a page has unloaded (or the browser window has been closed)
manifest<html>Specifies the address of the document's cache manifest (for offline browsing).
charset<meta>, <script>Specifies the character encoding.
content<meta>Gives the value associated with the http-equiv or name attribute
http-equiv<meta>Provides an HTTP header for the information/value of the content attribute.
sizes<link>Specifies the size of the linked resource.
scoped<style>Specifies that the styles only apply to this element's parent element and that element's child elements
async<script>Specifies that the script is executed asynchronously (only for external scripts).
defer<script>Specifies that the script is executed when the page has finished parsing (only for external scripts).
sandbox<iframe>Enables an extra set of restrictions for the content in an <iframe>
srcdoc<iframe>Specifies the HTML content of the page to show in the <iframe>.
cite<blockquote>, <del>, <ins>, <q>Specifies a URL which explains the quote/deleted/inserted text.
colspan<td>, <th>Specifies the number of columns a table cell should span
headers<td>, <th>Specifies one or more headers cells a cell is related to.
scope<th>Specifies whether a header cell is a header for a column, row, or group of columns or rows.
rowspan<td>, <th>Specifies the number of rows a table cell should span
span<col>, <colgroup>Specifies the number of columns to span.
datetime<del>, <ins>, <time>Specifies the date and time.
coords<area>Specifies the coordinates of the area.
download<a>, <area>Specifies that the target will be downloaded when a user clicks on the hyperlink.
href<a>, <area>, <base>, <link>Specifies the URL of the page the link goes to.
hreflang<a>, <area>, <link>Specifies the language of the linked document.
media<a>, <area>, <link>, <source>, <style>Specifies what media/device the linked document is optimized for.
rel<a>, <area>, <link>Specifies the relationship between the current document and the linked document.
target<a>, <area>, <base>, <form>Specifies the target for where to open the linked document or where to submit the form.
alt<area>, <img>, <input>Specifies an alternate text when the original element fails to display.
width<canvas>, <embed>, <iframe>, <img>, <input>, <object>, <video>Specifies the width of the element.
height<canvas>, <embed>, <iframe>, <img>, <input>, <object>, <video>Specifies the height of the element.
ismap<img>Specifies an image as a server-side image-map.
usemap<img>, <object>Specifies an image as a client-side image-map.
shape<area>Specifies the shape of the area.
onshow<menu>Script to be run when a <menu> element is shown as a context menu
reversed<ol>Specifies that the list order should be descending (9,8,7...).
start<ol>Specifies the start value of an ordered list.
data<object>Specifies the URL of the resource to be used by the object.
low<meter>Specifies the range that is considered to be a low value.
high<meter>Specifies the range that is considered to be a high value.
optimum<meter>Specifies what value is the optimal value for the gauge.
   
autoplay<audio>, <video>Specifies that the audio/video will start playing as soon as it is ready
controls<audio>, <video>Specifies that audio/video controls should be displayed (such as a play/pause button etc).
loop<audio>, <video>Specifies that the audio/video will start over again, every time it is finished.
muted<video>Specifies that the audio output of the video should be muted.
onabort<audio>, <embed>, <img>, <object>, <video>Script to be run on abort.
oncanplay<audio>, <embed>, <object>, <video>Script to be run when a file is ready to start playing (when it has buffered enough to begin).
oncanplaythrough<audio>, <video>Script to be run when a file can be played all the way to the end without pausing for buffering.
ondurationchange<audio>, <video>Script to be run when the length of the media changes
onerror<audio>, <body>, <embed>, <img>, <object>, <script>, <style>, <video>Script to be run when an error occurs.
onloadeddata<audio>, <video>Script to be run when media data is loaded
onloadedmetadata<audio>, <video>Script to be run when meta data (like dimensions and duration) are loaded.
onloadstart<audio>, <video>Script to be run just as the file begins to load before anything is actually loaded.
onpause<audio>, <video>Script to be run when the media is paused either by the user or programmatically.
onplay<audio>, <video>Script to be run when the media is ready to start playing.
onplaying<audio>, <video>Script to be run when the media actually has started playing.
onprogress<audio>, <video>Script to be run when the browser is in the process of getting the media data
onratechange<audio>, <video>Script to be run each time the playback rate changes (like when a user switches to a slow motion or fast forward mode).
onseeked<audio>, <video>Script to be run when the seeking attribute is set to false indicating that seeking has ended.
onseeking<audio>, <video>Script to be run when the seeking attribute is set to true indicating that seeking is active
oncuechange<track>Script to be run when the cue changes in a <track> element
onemptied<audio>, <video>Script to be run when something bad happens and the file is suddenly unavailable (like unexpectedly disconnects).
onended<audio>, <video>Script to be run when the media has reach the end (a useful event for messages like "thanks for listening")
onstalled<audio>, <video>Script to be run when the browser is unable to fetch the media data for whatever reason.
onsuspend<audio>, <video>Script to be run when fetching the media data is stopped before it is completely loaded for whatever reason.
ontimeupdate<audio>, <video>Script to be run when the playing position has changed (like when the user fast forwards to a different point in the media)
onvolumechange<audio>, <video>Script to be run each time the volume is changed which (includes setting the volume to "mute").
onwaiting<audio>, <video>Script to be run when the media has paused but is expected to resume (like when the media pauses to buffer more data).
poster<video>Specifies an image to be shown while the video is downloading, or until 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
kind<track>Specifies the kind of text track.
default<track>Specifies that the track is to be enabled if the user's preferences do not indicate that another track would be more appropriate.
label<track>Specifies the title of the text track.
srclang<track>Specifies the language of the track text data (required if kind="subtitles").
   
name<button>, <fieldset>, <form>, <iframe>, <input>, <keygen>, <map>, <meta>, <object>, <output>, <param>, <select>, <textarea>Specifies the name of the element.
action<form>Specifies where to send the form-data when a form is submitted.
method<form>Specifies the HTTP method to use when sending form-data.
accept-charset<form>Specifies the character encodings that are to be used for the form submission.
enctype<form>Specifies how the form-data should be encoded when submitting it to the server (only for method="post").
novalidate<form>Specifies that the form should not be validated when submitted.
onreset<form>Script to be run when a reset button in a form is clicked.
onsubmit<form>Script to be run when a for is submitted.
rows<textarea>Specifies the visible number of lines in a text area.
cols<textarea>Specifies the visible width of a text area.
wrap<textarea>Specifies how the text in a text area is to be wrapped when submitted in a form.
selected<option>Specifies that an option should be pre-selected when the page loads.
src<audio>, <embed>, <iframe>, <img>, <input>, <script>, <source>, <track>, <video>Specifies the URL of the media file.
accept<input>Specifies the types of files that the server accepts (only for type="file").
autocomplete<form>, <input>Specifies whether the <form> or the <input> element should have autocomplete enabled.
autofocus<button>, <input>, <keygen>, <select>, <textarea>Specifies that the element should automatically get focus when the page loads.
checked<input>Specifies that an <input> element should be pre-selected when the page loads (for type="checkbox" or type="radio").
dirname<input>, <textarea>Specifies that the text direction will be submitted.
disabled<button>, <fieldset>, <input>, <keygen>, <optgroup>, <option>, <select>, <textarea>Specifies that a the specified element/group of elements should be disabled.
form<button>, <fieldset>, <input>, <keygen>, <label>, <meter>, <object>, <output>, <select>, <textarea>Specifies the name of the form the element belongs to
formaction<button>, <input>Specifies where to send the form-data when a form is submitted. Only for type="submit".
list<input>Refers to a <datalist> element that contains pre-defined options for an <input> element.
maxlength<input>, <textarea>Specifies the maximum number of characters allowed in an element.
max<input>, <meter>, <progress>Specifies the maximum value.
min<input>, <meter>Specifies a minimum value.
multiple<input>, <select>Specifies that a user can enter more than one value.
onsearch<input>Script to be run when the user writes something in a search field (for <input="search">).
pattern<input>Specifies a regular expression that an <input> element's value is checked against.
placeholder<input>, <textarea>Specifies a short hint that describes the expected value of the element.
readonly<input>, <textarea>Specifies that the element is read-only
required<input>, <select>, <textarea>Specifies that the element must be filled out before submitting the form.
size<input>, <select>Specifies the width, in characters (for <input>) or specifies the number of visible options (for <select>)
step<input>Specifies the legal number intervals for an input field.
type<button>, <embed>, <input>, <link>, <menu>, <object>, <script>, <source>, <style>Specifies the type of element.
value<button>, <input>, <li>, <option>, <progress>, <param>Specifies the value of the element.
for<label>, <output>Specifies which form element(s) a label/calculation is bound to.
ontoggle<details>Script to be run when the user opens or closes the <details> element.
open<details>Specifies that the details should be visible (open) to the user
challenge<keygen>Specifies that the value of the <keygen> element should be challenged when submitted.
keytype<keygen>Specifies the security algorithm of the key.