Reference to All HTML Attributes

HTML attributes are a special type of instructions that are given to the HTML elements. The attributes are element dependent and a specific element can have a specific HTML attribute. However, there are certain HTML attributes, which are used as global attributes and can be used with all types of elements. The below table lists all the HTML attributes and acts as a guide and reference.

Search HTML Attributes Reference

Type the name of the attribute and instantly find the assosiated HTML tag or element with that attribute.

HTML Attributes Reference
Attribute Tag Name Description
accept <input> This attribute strict the user to select specific type of file (only for type=”file”).
accept-charset <form> Character encoding which are used for form submission are specified with this attribute.
accesskey Global Attributes This attribute creates a shortcut key to focus an  element.
action <form> When a form is submitted, the action attributes specifies its target location to send the data.
align Not supported in HTML 5 This is a deprecated attribute. It was used to align the content according to surrounding elements.
alt <area>, <img alt=”alt-text”>, <input> If the original content or resource of these elements is not present, an alternative text is displayed using this attribute. Also accessible by blind people.
async <script> The external script loads asynchronously with the page. The alternative attribute is defer.
autocomplete <form>, <input> Enables or disables the autocomplete features for form elements i.e. wheather to show the drop down list or not.
autofocus <button>, <input>, <select>, <textarea> If a page loads, the element is  automatically gets in focus. This is done using autofocus attribute.
autoplay <audio>, <video> If this attribute is active, the video or audio will be automatically played after getting ready.
bgcolor Not supported in HTML 5 This attribute is deprecated. It was used to declare element’s background color. Now this is done using CSS Background property.
border Not supported in HTML 5 This attribute is deprecated. Previously, it was used to declare the width of the border of an element. Now this is done using CSS Borders property.
charset <meta>, <script> Specifies the character encoding for the current document or external script file.
checked <input> This attribute makes an input field pre-selected when the page loads. Usually used for type=”radio” or type=”checkbox”.
cite <blockquote>, <del>, <ins>, <q> It is used to cite a quoted text, mark a deleted text, or inserted text.
class Global Attributes This attribute is used to add one or more classes for the element.
color Not supported in HTML 5 Previously, it was used to specify the color of the text. Now this is really easy with CSS colors property.
cols <textarea> The visible width of a textarea is declared using this attribute.
colspan <td>, <th> This attribute enables a table cell to span to the specified number of the columns.
content <meta> It sets the value associated with the http-equiv or name attribute
contenteditable Global Attributes If this attribute is set to “true” for an element, the content of the element is editable by the user.
controls <audio>, <video> If this attribute is present in <audio> or <video> element, the controls will be displayed for that video or audio player. i.e. play, stop, volume, etc.
coords <area> The coordinates of an area are specified using this attribute.
data <object> It specifies the URL of the resource and make it usable by the object.
data-* Global Attributes The private data for page or application is stored using this attribute.
datetime <del>, <ins>, <time> A date time attribute specifies the date and time of an event like deleted text, inserted text, or simple time and date.
default <track> Sets the default subtitle track for a video
defer <script> The external script loads after the page is loaded. The alternative attribute is async.
dir Global Attributes It declares the direction of the text in an element.
dirname <input>, <textarea> The direction of the field is also submitted with the form.
disabled <button>, <fieldset>, <input>, <optgroup>, <option>, <select>,
<textarea>
This attribute disables the selected elements and disables them for user’s interaction.
download <a>, <area> This attribute downloads the resource that is linked upon clicking the hyperlink.
draggable Global Attributes If  it is set to “true” for an element, the element is draggable on the screen.
enctype <form> It sets the encoding type of the submitted form data.
(only for method=”post”)
for <label>, <output> This attribute tells the association of the label or output tag to another element.
form <button>, <fieldset>, <input>, <label>, <meter>, <object>,
<output>, <select>, <textarea>
This attribute contains the name of the <form> to which the current element is associated.
formaction <button>, <input> The target location of the data to send, upon form submit.(Only for type=”submit”)
headers <td>, <th> Relation of a cell to the header cells.
height <canvas>, <embed>, <iframe>, <img alt=”alt-text”>, <input>, <object>, <video> This attribute declares the height of the element.
hidden Global Attributes Makes an element irrelevant and hides it.
high <meter> Upper limit of a range uses heigh attribute to set the value.
href <a>, <area>, <base>, <link> This href attribute declares URL of the target link.
hreflang <a>, <area>, <link> It tells the language of the linked document or resource.
http-equiv <meta> It declares an HTTP header for the value of the content attribute
id Global Attributes The ID for an HTML element is set using this attribute.
ismap <img alt=”alt-text”> If present, the image will act as an HTML image map.
kind <track> This attribute tells the kind or type of the text/subtitle track in a video.
label <track>, <option>, <optgroup> The title of the text/subtitle track in a video is declared using this attribute.
lang Global Attributes It defines the language of the document.
list <input> This attribute points to the id in datalist> element which have predefined options with values.
loop <audio>, <video> If this attribute is present in <audio> or <video> element, it will continue to play again and again.
low <meter> Lower limit of a range uses low attribute to set the value.
max <input>, <meter>, <progress> States the maximum value.
maxlength <input>, <textarea> It defines the allowable maximum number of the characters in an input field.
media <a>, <area>, <link>, <source>, <style> It defines the device for which the liked resource or document is optimized.
method <form> This attribute sets the HTTP method to use upon form submit.
min <input>, <meter> States the minimum value
multiple <input>, <select> It enables a user to enter more than one value
muted <video>, <audio> This HTML attribute mutes the video.
name <button>, <fieldset>, <form>, <iframe>, <input>, <map>, <meta>,
<object>, <output>, <param>, <select>, <textarea>
This HTML attribute sets the name of the element.
novalidate <form> The form is not validated upon submission if this attribute is present.
onabort <audio>, <embed>, <img alt=”alt-text”>, <object>, <video> The script inside onabort attribute runs or abort of media loading.
onafterprint <body> A script defined by onafterprint attribute runs after a document prints.
onbeforeprint <body> A script defined by onbeforeprint attribute runs before a document prints.
onbeforeunload <body> The script defined using onbeforeunload attribute runs when the document is about to be unloaded
onblur All visible elements. When the element loses focus, the script runs defined by onblur HTML attribute.
oncanplay <audio>, <embed>, <object>, <video> If a file is ready to play, the script runs as defined by the oncanplay attribute.
oncanplaythrough <audio>, <video> If a file is ready to play until the end without pausing for buffering, the script runs as defined by the oncanplaythrough attribute.
onchange All visible elements. When the content of the element is changed, the script runs set by the onchange attribute.
onclick All visible elements. When someone clicks the element, the script defined by onclick runs immediately.
oncontextmenu All visible elements. A script contained in oncontextmenu attribute runs when a context menu is triggered
oncopy All visible elements. If the user copies the content of an element, the script of the oncopy attribute runs.
oncuechange <track> A script in oncuechange attribute triggers when the cue changes in a <track> element
oncut All visible elements. If the user cuts the content of an element, the script of the oncut attribute runs.
ondblclick All visible elements. If the user double clicks the content of an element, the script of the ondblclick attribute runs.
ondrag All visible elements. A script runs on the drag of an element. The script is defined using the ondrag attribute.
ondragend All visible elements. A script runs after the drag of an element terminates. The script is defined using the ondragend attribute.
ondragenter All visible elements. When a user drags an element to a valid drop target, a script in the ondragenter attribute runs.
ondragleave All visible elements. When an element leaves a valid drop target, a script in the ondragleave attribute runs.
ondragover All visible elements. If an element drags over a valid drop target, a script in the ondragover attribute runs.
ondragstart All visible elements. A script runs after the drag of an element starts. The script is defined using the ondragstart attribute.
ondrop All visible elements. On drop of an element to a valid drop target, a script in ondrop attribute runs.
ondurationchange <audio>, <video> On change of the duration of the media, a script runs defined by the ondurationchange attribute.
onemptied <audio>, <video> The script in the onemptied attribute triggers when the video or audio file becomes unavailable due o some error or fault.
onended <audio>, <video> On end of the video or audio, the script in onended attribute triggers.
onerror <audio>, <body>, <embed>, <img alt=”alt-text”>, <object>, <script>, <style>, <video> A script triggers defined in onerror when some error occurs.
onfocus All visible elements. When the element gets focus, the script runs defined by the onblur HTML attribute.
onhashchange <body> A script in onhashchange attribute runs if there is some change in the URL
oninput All visible elements. When an element gets an input by the user, a script defined in oninput attribute triggers.
oninvalid All visible elements. A script runs if the element gets invalid.
onkeydown All visible elements. While a user pressing a key, a script defined in onkeydown attribute triggers.
onkeypress All visible elements. When a user presses a key, a script defined in onkeypress attribute triggers.
onkeyup All visible elements. While a user releasing a key, a script defined in onkeyup attribute triggers.
onload <body>, <iframe>, <img alt=”alt-text”>, <input>, <link>, <script>, <style> A script loads defined in onload attribute after an element is finished loading.
onloadeddata <audio>, <video> A script loads defined in onloadeddata attribute after a media in video or audio element is finished loading.
onloadedmetadata <audio>, <video> When meta data loading is finished like width, height, etc. The script defined inside the onloadedmetadata triggers.
onloadstart <audio>, <video> Some script loads defined in the onloadstart attribute when an element starts loading.
onmousedown All visible elements. While a user presses a mouse button on an element, a script defined in the onmousedown attribute triggers.
onmousemove All visible elements. Some script defined inside the onmousemove attribute runs as long as the mouse is moving.
onmouseout All visible elements. Some script defined inside the onmouseout attribute runs when the mouse pointer moves out of some element.
onmouseover All visible elements. A script defined inside the onmouseover attribute runs when the mouse pointer moves over some element.
onmouseup All visible elements. While a user releases a mouse button on an element, a script defined in the onmouseup attribute triggers.
onmousewheel All visible elements. When the mouse wheel scrolls over an element, a script triggers.
onoffline <body> When the browser starts working offline, the onoffline attribute triggers the script.
ononline <body> Some script triggers when the browser starts working online using ononline attribute.
onpagehide <body> On navigating away from the page, the script inside the onpagehide attribute runs.
onpageshow <body> On navigating to the page, the script inside the onpageshow attribute runs.
onpaste All visible elements. When the user pastes some content in an element, a script inside the onpaste attribute runs.
onpause <audio>, <video> When the video or the audio pauses by the user or for some other reason, the script inside the onpause attribute runs.
onplay <audio>, <video> While the video or the audio starts playing, the script inside the onplay attribute runs.
onplaying <audio>, <video> While the video or the audio has started playing, the script inside the onplaying attribute runs.
onpopstate <body> Some script runs when the windows history changes.
onprogress <audio>, <video> When the browser is working to collect the media data, the onprogress attribute triggers the script.
onratechange <audio>, <video> When the playback speed changes, a script inside onratechange runs each time.
onreset <form> Some script triggers on pressing the reset button in a form.
onresize <body> Some script triggers on resizing the window of the browser.
onscroll All visible elements. When the scrollbar of an element is being scrolled, the script inside the onscroll attribute runs.
onsearch <input> Some script runs while the user writes something in the search field.
onseeked <audio>, <video> Some script runs when the user seeks to a new position on the player for audio or video.
onseeking <audio>, <video> A script runs when the user seeks to a new position on the player for audio or video.
onselect All visible elements. When an element gets selected, the onselect attribute triggers some script.
onstalled <audio>, <video> While the browser is unable to fetch the resourced object due to some reason, a script runs defined by onstalled attribute.
onstorage <body> When a Web Storage area is updated, a script runs.
onsubmit <form> Upon form submission, script triggers.
onsuspend <audio>, <video> When fetching of media is stopped due to some reason in between, a script runs using onsuspend attribute.
ontimeupdate <audio>, <video> When a user fasts forward to a new position in the player, a script runs by ontimeupdate attribute.
ontoggle <details> Some script triggers when the user opens or closes the <details> element.
onunload <body> When the browser window is closed, some script runs.
onvolumechange <audio>, <video> A script runs each time the volume of the script changes.
onwaiting <audio>, <video> When a media pauses and chances of resuming, a script triggers.
onwheel All visible elements. Upon scrolling from an element up or down, a script triggers.
open <details> <details> are visible to the user if this attribute is present.
optimum <meter> Define the optimal value for the guage.
pattern <input> Checking of the input value against a regular expression.
placeholder <input>, <textarea> A short hint inside an input field telling the user to enter the desired form of data.
poster <video> Defines an image to be displayed on the screen while video is download until user hits 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> It makes the element read-only.
rel <a>, <area>,
<form>, <link>
Relation between current document and the liked doucment.
required <input>, <select>, <textarea> if this attribute is present in an element, then its input value is required in order to submit the form.
reversed <ol> If this attribute is used, the ordered list will have reverse numbering.
rows <textarea> This attribute defines the number of rows that are visible by default in textarrea.
rowspan <td>, <th> It defines the number of rows a table cell spans.
sandbox <iframe> Some more restriction inside the <iframe> using sandbox attribute.
scope <th> Specifies the scope of the header cell.
selected <option> A <option> is pre-selected upon page loading if selected attribute is present.
shape <area> The shape of the area is defined using shape attribute.
size <input>, <select> Limit of characters or number of visible options is done using size attribute.
sizes <img alt=”alt-text”>, <link>,
<source>
Define dimensions or size of the linked resource.
span <col>, <colgroup> The number of columns to span by a table item is set using span attribute.
spellcheck Global Attributes Whether to check the spellings of the element or not is defined using spellcheck attribute.
src <audio>, <embed>, <iframe>, <img alt=”alt-text”>, <input>, <script>, <source>, <track>,
<video>
Source or URL of the media file is set using src attribute.
srcdoc <iframe> Declares the HTML content of the page to show in iframe.
srclang <track> The language of the title track is set using this attribute.
srcset <img alt=”alt-text”>, <source> Define the URL of the image to use in different situations.
start <ol> The starting value of an ordered list is set using start attribute.
step <input> The legal number intervals for an input field is set using step attribute.
style Global Attributes This global attribute assigns a class to an element.
tabindex Global Attributes The tabbing order of an element is set using tabindex.
target <a>, <area>, <base>, <form> The target location is set where the link opens or form submits.
title Global Attributes Some extra information are added to the element using title attribute which pops up upon hover on the element.
translate Global Attributes Tells the browser that weather the content of the element is to be translated or not.
type <a>, <button>, <embed>, <input>, <link>, <menu>, <object>, <script>,
<source>, <style>
This attribute defines the type of the element.
usemap <img alt=”alt-text”>, <object> Declares an image to be used as HTML image map.
value <button>, <input>, <li>, <option>,
<meter>, <progress>, <param>
Define the value of an element using value attribute.
width <canvas>, <embed>, <iframe>, <img alt=”alt-text”>, <input>, <object>, <video> Define the width of an element using width attribute.
wrap <textarea> This attribute specifies how the submitted data is wrapped.

If you want to know more about the types of the HTML elements or the types of the attribute i.e semantic or non-semantic or presentational type HTML, just visit the following link.
Types of HTML Attributes
Give Us Your Feedback
OR
If You Need Any Help!
Contact Us