Affiliate link

HTML Reference - Attributes

List of attributes to define in HTML element/tag.

HTML Attributes List

AttributeElement/tagDescription
accept<input>Type of file that <input type="file" /> can accept
accept-charset<form><form> character encodings for submission
accesskeyGlobal AttributesShortcut key to activate/focus an element
action<form>Define the web url to send the form-data when a form is submitted
alignNot supported in HTML 5. Use CSS alignment
alt<area>, <img>, <input>Shortcut key to activate/focus an element
async<script>Script is executed asynchronously (only for loading external script file)
autocomplete<form>, <input>Define whether <form> or the <input> element should have autocomplete enabled
autofocus<button>, <input>, <select>, <textarea>Automatic focus on the element when the page loaded
autoplay<audio>, <video>Autoplay audio/video when the resource is ready to play
bgcolorNot supported in HTML 5. Use CSS background color
borderNot supported in HTML 5. Use CSS border
charset<meta>, <script>Define the character encoding for HTML document or JavaScript file
checked<input>Define <input type="checkbox"> and <input type="radio"> elements is checked/selected.
cite<blockquote>, <del>, <ins>, <q>Define <input type="checkbox"> and <input type="radio"> elements is checked/selected.
classGlobal AttributesDefine the class name for HTML elements
colorNot supported in HTML 5. Use CSS font color
cols<textarea>Width of textarea element
colspan<td>, <th>Number of columns a table cell spans
content<meta>The value of the meta tag
contenteditableGlobal AttributesDefine whether the content of the element is editable
controls<audio>, <video>Define whether the controls (eg, play, pause, mute) of audio/video playback will be displayed
coords<area>Coordinates of the area
data<object>URL of resource to be loaded for object element
data-*Global AttributesCustom data attributes for web application
datetime<del>, <ins>, <time>Date time
default<track>Default track to be enabled
defer<script>Defer external script execution until page loaded
dirGlobal AttributesText direction for the content in HTML element
dirname<input>, <textarea>Text direction for the content to be submitted in form
disabled<button>, <fieldset>, <input>, <label>, <meter>, <object>, <output>, <select>, <textarea>Define whether the element is disabled
download<a>, <area>Define whether the link is download targer url resource
draggableGlobal AttributesDefine whether an element is draggable
enctype<form>Define the encoding type for HTML form
for<label>, <output>Define the HTML form element that the label/output element is bound to
form<button>, <fieldset>, <input>, <label>, <meter>, <object>, <output>, <select>, <textarea>Define the name of the HTML form element
formaction<button>, <input>Define the form action url for button/input type="submit"
headers<td>, <th>Define the headers cell a td/th cell is related to
height<canvas>, <embed>, <iframe>, <img>, <input>, <object>, <video>Define the height of the element
hiddenGlobal AttributesDefine whether the element is hidden from displaying
high<meter>Define the high range value
href<a>, <area>, <base>, <link>Define the url link to navigate to
hreflang<a>, <area>, <link>Define the language of the web page the url linked to
http-equiv<meta>Define the HTTP header for the content of meta element
idGlobal AttributesDefine the unqiue id for an HTML element
ismap<img>Define image as a server-side image map
kind<track>Define the kind of the track
label<track>, <option>, <optgroup>Define the title of the track
langGlobal AttributesDefine the language for the content of an HTML element
list<input>Define the id of the datalist element which contains the list of input values
loop<audio>, <video>Define whether the audio/video element playback loop
low<meter>Define the low range value
max<input>, <meter>, <progress>Define the maximum value
maxlength<input>, <textarea>Define the maximum number of characters allowed
media<a>, <area>, <link>, <source>, <style>Define the type of media device targeted for the url link to be navigated to
method<form>Define the HTTP method for submitting form data
min<input>, <meter>Define the minimum value
multiple<input>, <select>Define the element can accept multiple values
muted<audio>, <video>Define the element can accept multiple values
name<button>, <fieldset>, <form>, <iframe>, <input>, <map>, <meta>, <object>, <output>, <param>, <select>, <textarea>Define the name of the element
novalidate<form>Define whether the form element require validation
onabort<audio>, <embed>, <img>, <object>, <video>JavaScript function to be called when abort loading the element
onafterprint<body>JavaScript function to be called after the web page is printed
onbeforeprint<body>JavaScript function to be called before the web page start print
onbeforeunload<body>JavaScript function to be called before the web page unload
onblurDisplayed elementsJavaScript function to be called after the element lose focus
oncanplay<audio>, <embed>, <object>, <video>JavaScript function to be called when the resource is ready to play
oncanplaythrough<audio>, <video>JavaScript function to be called when the resource is loaded and can play until finished
onchangeHTML elementsJavaScript function to be called when the content/value of the element is changed
onclickDisplayed elementsJavaScript function to be called when mouse left button clicked on the element
oncontextmenuDisplayed elementsJavaScript function to be called when mouse right button clicked on the element to display context menu
oncopyHTML elementsJavaScript function to be called when the content/value of the element is copied to clipboard
oncuechange<track>JavaScript function to be called when the cue of the track is changed
oncut<track>JavaScript function to be called when the cue of the track is changed
ondblclickDisplayed elementsJavaScript function to be called when mouse left button double-clicked on the element
ondragDisplayed elementsJavaScript function to be called when the element is being dragged
ondragendDisplayed elementsJavaScript function to be called when the element end dragged
ondragenterDisplayed elementsJavaScript function to be called when the element dragged to a valid drop target element
ondragleaveDisplayed elementsJavaScript function to be called when the element dragged out from a valid drop target element
ondragoverDisplayed elementsJavaScript function to be called when the element dragged over a valid drop target element
ondragstartDisplayed elementsJavaScript function to be called when the element start dragging
ondropDisplayed elementsJavaScript function to be called when the element is dropped
ondurationchange<audio>, <video>JavaScript function to be called when the media playback duration is changed
onemptied<audio>, <video>JavaScript function to be called when the media resource is unavailable or failed to load due to error
onended<audio>, <video>JavaScript function to be called when the media resource playback is ended
onerror<audio>, <body>, <embed>, <img>, <object>, <script>,<style>, <video>JavaScript function to be called when an error happens
onfocusDisplayed elementsJavaScript function to be called when an element is focused
onhashchange<body>JavaScript function to be called when the hash part of the url is changed
oninputDisplayed elementsJavaScript function to be called when the element gets keyboard input
oninvalidForm elementsJavaScript function to be called when the value of the element is invalid in form validation
onkeydownForm elementsJavaScript function to be called when the user is pressing a key on the element
onkeypressForm elementsJavaScript function to be called when the user presses a key on the element
onkeyupForm elementsJavaScript function to be called when the user releases a key on the element
onload<body>, <iframe>, <img>, <input>, <link>, <script>, <style>JavaScript function to be called when the element or element"s resource is loaded
onloadeddata<audio>, <video>JavaScript function to be called when the media resource is loaded
onloadedmetadata<audio>, <video>JavaScript function to be called when the metadata of the media resource is loaded
onloadstart<audio>, <video>JavaScript function to be called when the media resource is starting to load
onmousedownDisplayed elementsJavaScript function to be called when mouse button pressed down on the element
onmousemoveDisplayed elementsJavaScript function to be called when mouse pointer is moving on the element
onmouseoutDisplayed elementsJavaScript function to be called when mouse pointer move out of the element
onmouseoverDisplayed elementsJavaScript function to be called when mouse pointer move over to the element
onmouseupDisplayed elementsJavaScript function to be called when mouse button is released on the element
onmousewheelDisplayed elementsJavaScript function to be called when mouse wheel is scrolled on the element
onoffline<body>JavaScript function to be called when the web page is set to offline
ononline<body>JavaScript function to be called when the web page is set to online
onpagehide<body>JavaScript function to be called when the user navigates away from the web page
onpageshow<body>JavaScript function to be called when the user navigates to the web page
onpasteForm elementsJavaScript function to be called when the copied content is pasted on the element
onpause<audio>, <video>JavaScript function to be called when the media playback is paused
onplay<audio>, <video>JavaScript function to be called when the media resource started playing
onplaying<audio>, <video>JavaScript function to be called when the media resource is playing
onpopstate<body>JavaScript function to be called when the tab/window"s history changes
onprogress<audio>, <video>JavaScript function to be called when the loading of the media resource is in progress
onratechange<audio>, <video>JavaScript function to be called when the rate of playback is changed
onreset<form>JavaScript function to be called when the form element is reset
onresize<body>JavaScript function to be called when window is being resized
onscrollDisplayed elementsJavaScript function to be called when element"s scrollbar is being scrolled
onsearch<input>JavaScript function to be called when the value of the input type="search" element is changed
onseeked<audio>, <video>JavaScript function to be called when the seeking property of the element is false. Means seeking has ended.
onseeking<audio>, <video>JavaScript function to be called when the seeking property of the element is true. Means seeking has started.
onselectDisplayed elementsJavaScript function to be called when the element gets selected
onstalled<audio>, <video>JavaScript function to be called when the browser unable to fetch the media resource
onstorage<body>JavaScript function to be called when the browser web storage is updated
onsubmit<form>JavaScript function to be called before the form is submitted
onsuspend<audio>, <video>JavaScript function to be called when the browser stop fetching the media resource
ontimeupdate<audio>, <video>JavaScript function to be called when the media playback$quot;s position is changed
ontoggle<details>JavaScript function to be called when the details element open/close
onunload<body>JavaScript function to be called when the web page is unloaded (Eg. browser/tab close)
onvolumechange<audio>, <video>JavaScript function to be called when the media playback$quot;s volume is changed
onwaiting<audio>, <video>JavaScript function to be called when the media playback$quot;s is paused to buffer media resource
onwheelDisplayed elementsJavaScript function to be called when mouse wheel scroll on an element
open<details>Open details element to be displayed
optimum<meter>Define the optimal value for the meter
pattern<input>Define the regular expression to validate the value of the input
placeholder<input>, <textarea>Define the hint text on the element
poster<video>Define the image url to be displayed while the media resource begins to play
preload<audio>, <video>Define the loading behaviour of the media resource (Eg, only when video metadata is loaded, or auto start download)
readonly<input>, <textarea>Define whether the element is read only, user is not allowed to change the value
rel<a>, <area>, <form>, <link>Define the relationship of current web page with the linked url
required<input>, <select>, <textarea>Define the element is required with value before form submission
reversed<ol>Define the element"s list is reversed
rows<textarea>Define the number of rows for textarea element
rowspan<td>, <th>Define the number of rows a table cell span
sandbox<iframe>Define an extra set of restrictions for the content in an iframe element
scope<th>Define whether the header cell is scoped as a header for a column, row, or group of columns or rows
selected<option>Define whether the option element is selected
shape<area>Define the shape of the area element
size<input>, <select>Define the number of visible characters/options
sizes<img>, <link>, <source>Define the size of the linked resource
span<col>, <colgroup>Define the number of columns to span
spellcheckForm elementsDefine whether the element has spelling/grammer check
src<audio>, <embed>, <iframe>, <img>, <input>, <script>, <source>, <track>, <video>Define the url for the media resource
srcdoc<iframe>Define the HTML/CSS/JavaScript content to display in iframe
srclang<track>Define the language of the track text metadata
srcset<img>, <source>Define the image to be loaded for different device width
start<ol>Define the start value of an ordered list
step<input>Define the number of units to increase/decrease for an input element (Eg, number, date, month, time)
styleDisplayed elementsDefine the CSS style inline for an element
tabindexDisplayed elementsDefine the tab index for an element (Use with "Tab" key)
target<a>, <area>, <base>, <form>Define the target place to open the url or submit form
titleDisplayed elementsDefine the text to be displayed when mouse over on the element
translateDisplayed elementsDefine whether the content can be translated
type<a>, <button>, <embed>, <input>, <link>, <menu>, <object>, <script>, <source>, <style>Define the type of the element
usemap<img>, <object>Define the image as client-side image map
value<button>, <input>, <li>, <meter>, <option>, <param>, <progress>Define the value of the element
width<canvas>, <embed>, <iframe>, <img>, <input>, <object>, <video>Define the width of the element
wrap<textarea>Define how the text will be wrapped in form submission
Affiliate link
Affiliate link
Affiliate link
Advertisment
StudioPress
Get Surfshark VPN