View video tutorial

HTML Attribute List

HTML

The page lists all HTML attributes and shows what elements the attributes can be used in.

HTML Attribute List

The table below lists all HTML attributes and shows what elements the attributes can be used within.

Attribute_Name Used within Description
accept <input> This specifies the types of files that the server accepts (only for type="file").
accept-charset <form> This specifies the character encodings to use for form submissions.
accesskey Global Attributes This specifies a shortcut key to activate or focus an element.
action <form> This specifies where to send form-data when submitting a form.
align Not supported in HTML5. This specifies alignment according to surrounding elements.. Use CSS instead.
alt <area>, <img>, <input> It specifies an alternate text when the element fails to display source.
async <script> It specifies that the script is executed asynchronously (only for external scripts).
autocomplete <form>, <input> This specifies whether the form or input element should be autocomplete enabled.
autofocus <button>, <input>, <select>, <textarea> It specifies whether the element should automatically receive focus when the page loads.
autoplay <audio>, <video> It specifies that the audio/video will start playing as soon as it is ready.
bgcolor Not supported in HTML5. It specifies the background color of an element. Use CSS instead.
border Not supported in HTML5 It specifies the width of the border of an element. Use CSS instead.
charset <meta>, <script> It specifies the character encoding.
checked <input> It specifies that an input element should be pre-selected when the page loads (if type="checkbox" or type="radio").
cite <blockquote>, <del>, <ins>, <q> It specifies a URL to explains the text.
class Global Attributes It specifies one or more classnames for an element to use in a style sheet.
color Not supported in HTML5 It specifies the text color of an element. Use CSS instead.
cols <textarea> It specifies the width of a text area.
colspan <td>, <th> It specifies the number of columns a table cell should expand.
content <meta> It returns the value associated with the http-equiv or name attribute.
contenteditable Global Attributes This specifies whether the content of an element is editable or not.
controls <audio>, <video> It specifies that the audio/video controls should be displayed.
coords <area> It specifies the coordinates of the area element.
data <object> It specifies the URL of the resource to be used in the object tag.
data-* Global Attributes It is used to store custom data private to the page.
datetime <del>, <ins>, <time> It specifies the date and time.
default <track> This specifies that the track will be activated if there is no user preference.
defer <script> It specifies that the script is executed when the page finishes parsing (for external scripts only).
dir Global Attributes It specifies the direction of text in an element.
dirname <input>, <textarea> It specifies the direction of the text to be submitted.
disabled <button>, <fieldset>, <input>, <optgroup>, <option>, <select>, <textarea> It specifies that the element should be disabled.
download <a>, <area> It specifies that the resource will be downloaded when a user clicks on the hyperlink.
draggable Global Attributes It specifies whether an element can be dragged or not.
enctype <form> This specifies how the form-data should be encoded when form data is submitted to the server (only for method="post").
for <label>, <output> It specifies which form element the label element is bound to.
form <button>, <fieldset>, <input>, <label>, <meter>, <object>, <output>, <select>, <textarea> It specifies the name of the form the element belongs to.
formaction <button>, <input> It specifies where to send form-data when submitting a form (Only for type="submit").
headers <td>, <th> It specifies one or more header cells to which a cell is associated.
height <canvas>, <embed>, <iframe>, <img>, <input>, <object>, <video> It specifies the height of the element.
hidden Global Attributes It specifies that an element is hidden from view.
high <meter> It specifies the range considered a high value.
href <a>, <area>, <base>, <link> It specifies the URL of the page the link goes to.
hreflang <a>, <area>, <link> It specifies the language of the attached document.
http-equiv <meta> It provides an HTTP header information for the content attribute.
id Global Attributes It specifies a unique id of an element.
ismap <img> It specifies an image as the image map.
kind <track> It specifies the text track type.
label <track>, <optgroup>, <option> It specifies the title of the text track.
lang Global Attributes It specifies the content language of the element.
list <input> It Points to a detaillist element that contains predefined options for an input element.
loop <audio>, <video> It specifies that the audio/video will resume, each time it ends.
low <meter> It specifies the range considered a low value..
max <input>, <meter>, <progress> It specifies the maximum value.
maxlength <input>, <textarea> It specifies the maximum number of characters allowed in an element..
media <a>, <area>, <link>, <source>, <style> It specifies which media/device the linked document is optimized for.
method <form> It specifies the HTTP method to use when submitting the form.
min <input>, <meter> It specifies a minimum value.
multiple <input>, <select> It specifies that a user can select multiple values.
muted <audio>, <video> It specifies that the audio output should be muted.
name <button>, <fieldset>, <form>, <iframe>, <input>, <map>, <meta>, <object>, <output>, <param>, <select>, <textarea> It specifies the name of the element.
novalidate <form> It specifies that the form should not be validated during submission.
onabort <audio>, <embed>, <img>, <object>, <video> The script to be run on abort.
onafterprint <body> The script is executed after the document is printed.
onbeforeprint <body> The script is executed before the document is printed.
onbeforeunload <body> The script is executed before the document is unloaded.
onblur All visible elements The script is executed when the element loses focus.
oncanplay <audio>, <embed>, <object>, <video> The script is executed when a file is ready to start playing, when there is enough buffer to start it.
oncanplaythrough <audio>, <video> The script is executed when a file can be run to the end without pausing for buffering.
onchange All visible elements The script is executed when the value of the element changes.
onclick All visible elements The script is executed when the element is clicked.
oncontextmenu All visible elements The script is executed when a context menu is triggered.
oncopy All visible elements The script is executed when the content of the element is being copied.
oncuechange <track> The script is executed when the cue changes to the track element.
oncut All visible elements The script is executed when the content of the element is being cut.
ondblclick All visible elements The script is executed when the element is double-clicked.
ondrag All visible elements The script is executed when the element is dragged.
ondragend All visible elements The script is executed after a drag operation.
ondragenter All visible elements The script is executed when an element is dragged to a valid drop target.
ondragleave All visible elements The script is executed when an element leaves a valid drop target.
ondragover All visible elements The script is executed when an element is dragged onto a valid drop target.
ondragstart All visible elements The script is executed at the start of the drag operation.
ondrop All visible elements The script is executed when the dragged element is dropped.
ondurationchange <audio>, <video> The script is executed when the media length changes.
onemptied <audio>, <video> The script is executed if something bad happens and the file suddenly becomes unavailable.
onended <audio>, <video> The script is executed when the media reaches the end.
onerror <audio>, <body>, <embed>, <img>, <object>, <script>, <style>, <video> The script is executed when an error occurs.
onfocus All visible elements The script is executed when the element gets focus.
onhashchange <body> The script is executed when a change is made to the anchor portion of a URL.
oninput All visible elements The script is executed when the component receives user input.
oninvalid All visible elements The script is executed if the element is invalid.
onkeydown All visible elements The script is executed when a user presses a key.
onkeypress All visible elements The script is executed when the user presses a key.
onkeyup All visible elements The script is executed when a user releases a key.
onload <body>, <iframe>, <img>, <input>, <link>, <script>, <style> The script is executed when the element is finished loading.
onloadeddata <audio>, <video> The script is executed when the media data is loaded.
onloadedmetadata <audio>, <video> The script is executed when the meta data is loaded.
onloadstart <audio>, <video> The script is executed when the file starts to load before anything is actually loaded.
onmousedown All visible elements The script is executed when the mouse button is pressed on an element.
onmousemove All visible elements The script is executed as long as the mouse pointer is moving over an element.
onmouseout All visible elements The script is executed when a mouse pointer moves away from an element.
onmouseover All visible elements The script is executed when a mouse pointer moves over an element.
onmouseup All visible elements The script is executed when a mouse button is released over an element.
onmousewheel All visible elements The script is executed when the mouse wheel is scrolled over an element.
onoffline <body> The script is executed when the browser starts working offline.
ononline <body> The script is executed when the browser starts working online.
onpagehide <body> The script is executed when a user navigates away from a page.
onpageshow <body> The script is executed when a user navigates to a page.
onpaste All visible elements The script is executed when the user pastes some content into an element.
onpause <audio>, <video> The script executes when the media is paused by the user or programmatically.
onplay <audio>, <video> The script is executed when the media starts playing.
onplaying <audio>, <video> The script is executed when the media starts playing.
onpopstate <body> The script is executed when the window's history changes.
onprogress <audio>, <video> The script is executed when the browser is in the process of receiving media data.
onratechange <audio>, <video> The script is executed every time the playback rate changes (eg slow motion or fast forward mode).
onreset <form> The script is executed when a form's reset button is clicked.
onresize <body> The script is executed when the browser window is resized.
onscroll All visible elements The script is executed when an element's scrollbar is being scrolled.
onsearch <input> The script is executed when the user types something into a search field (for input="search">).
onseeked <audio>, <video> The script is executed when the lookup property is set to false indicating that the lookup has finished.
onseeking <audio>, <video> The script is executed when the seeking attribute is set to true indicating that the search is active.
onselect All visible elements The script is executed when the element is selected.
onstalled <audio>, <video> The script is executed if the browser is unable to fetch the media data for any reason.
onstorage <body> The script is executed when a web storage area is updated.
onsubmit <form> The script is executed when a form is submitted.
onsuspend <audio>, <video> The script is executed when the process of fetching media data stops before it is fully loaded for any reason.
ontimeupdate <audio>, <video> The script is executed when the playing position changes (eg fast forward to another point).
ontoggle <details> The script executes when the user opens or closes the details element.
onunload <body> The script is executed when a page is unloaded (or the browser window is closed).
onvolumechange <audio>, <video> The script is executed every time the video/audio volume is changed.
onwaiting <audio>, <video> The script is executed when the media is paused but expected to resume (eg when the media pauses to buffer more data).
onwheel All visible elements The script is executed when the mouse wheel is rolled up or down on an element.
open <details> It specifies that the details should be visible to the user.
optimum <meter> This specifies which value is the best value for the gauge.
pattern <input> It specifies a regular expression that the value of an input element is checked against.
placeholder <input>, <textarea> It specifies a short hint that describes the expected value of the element.
poster <video> It specifies an image to display when the video is downloaded or until the user hits the play button.
preload <audio>, <video> This specifies whether and how the author thinks audio/video should be loaded when the page loads.
readonly <input>, <textarea> This specifies that the element is read-only.
rel <a>, <area>, <from>, <link> It specifies the relationship between the current document and the linked document.
required <input>, <select>, <textarea> It specifies that the element must be filled before the form can be submitted.
reversed <ol> This specifies that the order of the list should be descending.
rows <textarea> It specifies the visible number of rows in a text area.
rowspan <td>, <th> It specifies the number of rows a table cell should be expanded to.
sandbox <iframe> This enables an additional set of constraints for content in an iframe.
scope <th> It specifies whether a header cell is a header for a column, row, or group of columns or rows.
selected <option> This specifies that an option should be pre-selected when the page is loaded.
shape <area> It specifies the shape of the area.
size <input>, <select> It specifies the width in characters (for input) or specifies the number of visible options (for select).
sizes <img>, <link>, <source> It specifies the size of the linked resource.
span <col>, <colgroup> It specifies the number of columns to expand.
spellcheck Global Attributes Specifies whether to check the element's spelling and grammar.
src <audio>, <embed>, <iframe>, <img>, <input>, <script>, <source>, <track>, <video> It specifies the URL of the media file.
srcdoc <iframe> It specifies the HTML content of the page to be displayed in the iframe.
srclang <track> It specifies the language of the track text data.
srcset <img>, <source> It specifies the image URL to use in different scenarios.
start <ol> It specifies the initial value of an ordered list.
step <input> It specifies the legal number interval for an input field.
style Global Attributes It specifies an inline CSS style for an element.
tabindex Global Attributes This specifies the tabbing order of an element.
target <a>, <area>, <base>, <form> It specifies the target where to open the attached document or where to submit the form.
title Global Attributes It specifies additional information about an element.
translate Global Attributes This specifies whether the content of an element should be translated.
type <a>, <button>, <embed>, <input>, <link>, <object>, <script>, <source>, <style> It specifies the element type.
usemap <img>, <object> This specifies that an image is used as an image map.
value <button>, <input>, <li>, <meter>, <option>, <param>, <progress> It specifies the value of the element.
width <canvas>, <embed>, <iframe>, <img>, <input>, <object>, <video> This specifies the width of the element.
wrap <textarea> It specifies how the text of a text area should be wrapped when submitting a form.