HTML Attribute Reference

 

ATTENTION: THIS PAGE IS Valid HTML 5 AND IS BEST VIEWED WITH HTML 5 - Please upgrade your browser or download one of the HTML 5 compatible browsers such as Mozilla Firefox, Chrome, Opera or IE 9 (March 14, 2011 or later). For more information see HTML 5 browsers.


If you find this helpful, please click the Google +1 Button to the left, if it is white, to make it turn blue or red. Thank you! (It also helps find this page again more easily.)


PDF mobile

Coding HTML Attributes

An attribute is a named property associated with an element. In a marked-up document, attributes are coded in a starting tag or standalone tag between the element name and the tag's terminating /> or > delimiter. The code for an HTML attribute consists of the attribute name, an equal sign (=) and the value of the property enclosed in quotes:

<elemname attrname="value">...</elemname>
<elemname attrname="value"/>
Coding Boolean Attributes

Boolean attributes should be coded in their full form using the attribute name in quotes (attribute="attribute") when the value is true and completely omitting the attribute when the value is false. The full form will be properly understood by web browsers parsing polyglot documents with either the HTML syntax or the XML syntax of HTML 5. Avoid using minimized attributes, such as selected, or values with an empty string, such as in selected="", which XPath treats as false rather than true.

<input type="text" readonly="readonly"/>
<input type="text" required="required"/>
<option selected="selected"/>
<video autoplay="autoplay" ...>

WARNING: Be careful when looking for web sites for learning HTML, especially when it comes to things that are treated differently by different browsers. For instance, the examples on some very popular web sites show the value "false" as valid for boolean attributes, which is treated as false by browsers that look at the attribute value and as true by other browsers that only look for the presence or absence of the attribute, resulting in very inconsistent behavior, since that is incorrect coding per the HTML specification:

The values "true" and "false" are not allowed on boolean attributes.

To determine what version of HTML a web page is actually using, enter its URL in the W3C Markup Validation Service and look for the Doctype. If it's not HTML5, change it to HTML5 in the drop-down box and then Revalidate. The pages on this site are Valid HTML 5.


Global Attributes List

Global (Common) Attributes

These are the common (global) HTML attributes that can be used on most HTML tags.

The accesskey Attribute
The class Attribute
The contenteditable Attribute
The contextmenu Attribute
The Author-Defined data-* Attributes
The dir Attribute
The draggable Attribute
The dropzone Attribute
The hidden Attribute
The id Attribute
The Microdata item... Attributes
The lang Attribute
The on... Event Attributes
The spellcheck Attribute
The style Attribute
The tabindex Attribute
The title Attribute
XML Atttributes in HTML
xmlns and xml:space

The other HTML attributes are limited to specific HTML tags.


Element Attribute Index

The table below uses the <tag attribute> notation indicating the namespace partition as described in the HTML Namespaces and Namespace Declarations Tutorial.

AttributeTag(s) Where Valid
accept<input accept>
accept-charset<form accept-charset>
accesskeyaccesskey Global Attribute
action<form action>
alt<area alt> <img alt> <input alt>
async<script async>
autocomplete<form autocomplete> <input autocomplete>
autofocus<button autofocus> <input autofocus> <keygen autofocus> <select autofocus> <textarea autofocus>
autoplay<audio autoplay> <video autoplay>
challenge<kengen challenge>
charset<meta charset> <script charset>
checked<command checked> <input checked>
cite<blockquote cite> <del cite> <ins cite> <q cite>
classclass Global Attribute
codecs<source codecs>
cols<textarea cols>
colspan<td colspan> <th colspan>
compact<ol compact>
content<meta content>
contenteditablecontenteditable Global Attribute
controls<audio controls> <video controls>
coords<area coords>
data<object data>
data-*data-* Author-Defined Attributes
datetime<del datetime> <ins datetime> <time datetime>
default<track default>
defer<script defer>
dirdir Global Attribute <bdi dir> <bdo dir>
disabled<button disabled> <command disabled> <input disabled> <keygen disabled> <optgroup disabled> <option disabled> <select disabled> <textarea disabled>
draggabledraggable Global Attribute
dropzonedropzone Global Attribute
encoding<?xml encoding?>
enctype<form enctype>
form<button form> <input form> <keygen form> <object form> <select form> <textarea form>
formaction<button formaction> <input formaction>
formenctype<button formenctype> <input formenctype>
formmethod<button formmethod> <input formmethod>
formnovalidate<button formnovalidate> <input formnovalidate>
formtarget<button formtarget> <input formtarget>
headers<td headers> <th headers>
height<canvas height> <embed height> <iframe height> <img height> <input height> <object height> <video height>
hiddenhidden Global Attribute
href<a href> <area href> <base href> <link href> <?xml-stylesheet href?>
hreflang<a hreflang> <area hreflang> <link hreflang>
http-equiv<meta http-equiv>
icon<command icon>
idid Global Attribute <dfn id>
ismap<img ismap>
itemiditemid Microdata Attribute
itempropitemprop Microdata Attribute
itemrefitemref Microdata Attribute
itemscopeitemscope Microdata Attribute
itemtypeitemtype Microdata Attribute
keytype<keygen keytype>
kind<track kind>
label<command label> <menu label> <optgroup label> <option label> <track label>
langlang Global Attribute
language<script language>
list<input list>
loop<audio loop> <video loop>
manifest<html manifest>
max<input max>
maxlength<input maxlength> <textarea maxlength>
media<a media> <area media> <link media> <style media>
method<form method>
min<input min>
multiple<input multiple> <select multiple>
name<button name> <form name> <iframe name> <input name> <keygen name> <meta name> <object name> <select name> <textarea name>
novalidate<form novalidate>
AttributeTag(s) Where Valid
on...on... Event Attributes
onblur<body onblur>
oncanplay<audio oncanplay> <video oncanplay>
oncanplaythrough<audio oncanplaythrough> <video oncanplaythrough>
onemptied<audio onemptied> <video onemptied>
onended<audio onended> <video onended>
onerror<audio onerror> <body onerror> <video onerror>
onfocus<body onfocus>
onload<body onload>
onloadeddata<audio onloadeddata> <video onloadeddata>
onloadedmetadata<audio onloadedmetadata> <video onloadedmetadata>
onloadstart<audio onloadstart> <video onloadstart>
onpause<audio onpause> <video onpause>
onplaying<audio onplaying> <video onplaying>
onprogress<audio onprogress> <video onprogress>
onratechange<audio onratechange> <video onratechange>
onreadystatechange<audio onreadystatechange> <video onreadystatechaneg>
onscroll<body onscroll>
onseeked<audio onseeked> <video onseeked>
onseeking<audio onseeking> <video onseeking>
onstalled<audio onstalled> <video onstalled>
onsuspend<audio onsuspend> <video onsuspend>
ontimeupdate<audio ontimeupdate> <video ontimeupdate>
onvolumechange<audio onvolumechange> <video onvolumechange>
onwaiting<audio onwaiting> <video onwaiting>
open<details open>
pattern<input pattern>
ping<a ping> <area ping>
placeholder<input placeholder> <textarea placeholder>
poster<video poster>
preload<audio preload> <video preload>
pubdate<time pubdate>
radiogroup<command radiogroup>
readonly<input readonly> <textarea readonly>
rel<a rel> <area rel> <link rel>
required<input required> <textarea required>
reversed<ol reversed>
rows<textarea rows>
rowspan<td rowspan> <th rowspan>
sandbox<iframe sandbox>
scope<th scope>
scoped<style scoped>
seamless<iframe seamless>
selected<option selected>
shape<area shape>
size<input size> <select size>
sizes<link sizes>
span<colgroup span>
spellcheckspellcheck Global Attribute
src<audio src> <embed src> <iframe src> <img src> <input src> <script src> <source src> <track src> <video src>
srcdoc<iframe srcdoc>
srclang<track srclang>
standalone<?xml standalone?>
start<ol start>
step<input step>
stylestyle Global Attribute <svg style>
tabindextabindex Global Attribute
target<a target> <area target> <base target> <form target>
titletitle Global Attribute <abbr title> <command title> <dfn title> <link title> <style title>
type<a type> <area type> <button type> <command type> <embed type> <input type> <link type> <menu type> <object type> <ol type> <script type> <source type> <style type> <?xml-stylesheet type?>
usemap<img usemap> <object usemap>
value<button value> <input value> <option value>
version<?xml version?> <html version> <svg version>
width<canvas width> <embed width> <iframe width> <img width> <input width> <object width> <video width>
wrap<textarea wrap>
xmlnsxmlns Global Attribute <html xmlns> <mathml xmlns> <svg xmlns>

Valid HTML 5