HTML Attribute Reference
-
HTML Attribute Reference
The table below provides an overview of HTML attributes, including which elements they apply to and their descriptions:
Attribute Belongs to Description accept<input>Specifies the types of files that the server accepts (for type="file").accept-charset<form>Specifies the character encodings to be used for form submission. accesskeyGlobal Attributes Specifies a shortcut key to activate or focus an element. action<form>Specifies where to send form data when the form is submitted. alignNot supported in HTML 5. Specifies alignment according to surrounding elements. Use CSS instead. alt<area>,<img>,<input>Provides alternate text when the original element fails to display. async<script>Specifies that the script should be executed asynchronously (for external scripts). autocomplete<form>,<input>Specifies whether autocomplete is enabled for the element. autofocus<button>,<input>,<select>,<textarea>Indicates that the element should automatically get focus when the page loads. autoplay<audio>,<video>Specifies that the audio/video should start playing as soon as it’s ready. 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. charset<meta>,<script>Defines the character encoding. checked<input>Indicates that an <input>element should be pre-selected (fortype="checkbox"ortype="radio").cite<blockquote>,<del>,<ins>,<q>Provides a URL that explains the quote/deleted/inserted text. classGlobal Attributes Assigns one or more class names to an element (refers to a class in a style sheet). colorNot supported in HTML 5. Specifies the text color of an element. Use CSS instead. cols<textarea>Defines the visible width of a text area. colspan<td>,<th>Specifies how many columns a table cell should span. content<meta>Provides the value associated with the http-equivornameattribute.contenteditableGlobal Attributes Indicates whether the content of an element is editable. controls<audio>,<video>Specifies that audio/video controls should be displayed. coords<area>Defines the coordinates of an area in an image map. data<object>Specifies the URL of the resource for the object. data-*Global Attributes Used to store custom data private to the page or application. datetime<del>,<ins>,<time>Specifies the date and time. default<track>Indicates that the track should be enabled if no other track is more appropriate. defer<script>Specifies that the script should be executed when the page has finished parsing (for external scripts). dirGlobal Attributes Sets the text direction for the content in an element. dirname<input>,<textarea>Indicates that the text direction will be submitted. disabled<button>,<fieldset>,<input>,<optgroup>,<option>,<select>,<textarea>Disables the specified element or group of elements. download<a>,<area>Indicates that the target will be downloaded when a user clicks the hyperlink. draggableGlobal Attributes Determines whether an element is draggable or not. enctype<form>Specifies how form-data should be encoded when submitting it to the server (for method="post").enterkeyhintGlobal Attributes Provides a hint about the text of the enter-key on a virtual keyboard. for<label>,<output>Specifies which form element(s) a label/calculation is bound to. form<button>,<fieldset>,<input>,<label>,<meter>,<object>,<output>,<select>,<textarea>Specifies the name of the form the element belongs to. formaction<button>,<input>Defines where to send form-data when the form is submitted (for type="submit").headers<td>,<th>Lists one or more header cells related to a cell. height<canvas>,<embed>,<iframe>,<img>,<input>,<object>,<video>Sets the height of the element. hiddenGlobal Attributes Indicates that an element is not relevant. high<meter>Defines the range that is considered to be a high value. href<a>,<area>,<base>,<link>Provides the URL of the page the link goes to. hreflang<a>,<area>,<link>Specifies the language of the linked document. http-equiv<meta>Provides an HTTP header for the information/value of the content attribute. idGlobal Attributes Assigns a unique id to an element. inertGlobal Attributes Indicates that the browser should ignore this section. inputmodeGlobal Attributes Defines the mode of a virtual keyboard. ismap<img>Specifies an image as a server-side image map. kind<track>Specifies the kind of text track. label<track>,<option>,<optgroup>Provides the title of the text track. langGlobal Attributes Defines the language of the element’s content. list<input>Refers to a <datalist>element that contains pre-defined options for an<input>element.loop<audio>,<video>Indicates that the audio/video should start over when finished. low<meter>Defines the range considered to be a low value. max<input>,<meter>,<progress>Specifies the maximum value. maxlength<input>,<textarea>Sets the maximum number of characters allowed in an element. media<a>,<area>,<link>,<source>,<style>Defines what media/device the linked document is optimized for. method<form>Specifies the HTTP method to use when sending form-data. min<input>,<meter>Sets the minimum value. multiple<input>,<select>Allows multiple values to be entered. muted<video>,<audio>Indicates that the audio output should be muted. name<button>,<fieldset>,<form>,<iframe>,<input>,<map>,<meta>,<object>,<output>,<param>,<select>,<textarea>Specifies the name of the element. novalidate<form>Prevents the form from being validated when submitted. onabort<audio>,<embed>,<img>,<object>,<video>Script to be executed when an operation is aborted. onafterprint<body>Script to be executed after the document is printed. onbeforeprint<body>Script to be executed before the document is printed. onbeforeunload<body>Script to be executed when the document is about to be unloaded. onblurAll visible elements Script to be executed when an element loses focus. oncanplay<audio>,<video>Script to be executed when the browser can start playing the media. onchange<input>,<select>,<textarea>Script to be executed when the value of an element changes. onclickAll visible elements Script to be executed when an element is clicked. oncontextmenuAll visible elements Script to be executed when the right mouse button is clicked. oncopyAll visible elements Script to be executed when the content of an element is copied. oncutAll visible elements Script to be executed when the content of an element is cut. ondblclickAll visible elements Script to be executed when an element is double-clicked. ondragAll visible elements Script to be executed when an element is dragged. ondragendAll visible elements Script to be executed when a drag operation is completed. ondragenterAll visible elements Script to be executed when an element is dragged over a valid drop target. ondragleaveAll visible elements Script to be executed when an element leaves a valid drop target. ondragoverAll visible elements Script to be executed when an element is dragged over another element. ondragstartAll visible elements Script to be executed when a drag operation starts. ondropAll visible elements Script to be executed when an element is dropped. onended<audio>,<video>Script to be executed when the media ends. onerror<img>,<script>,<iframe>,<object>Script to be executed when an error occurs. onfocusAll visible elements Script to be executed when an element gets focus. onformchange<form>Script to be executed when the form’s elements change. onforminput<form>Script to be executed when an input element within the form changes. oninputAll visible elements Script to be executed when the value of an input element changes. oninvalid<input>,<select>,<textarea>Script to be executed when an input element fails validation. onkeydownAll visible elements Script to be executed when a key is pressed. onkeypressAll visible elements Script to be executed when a key is pressed and released. onkeyupAll visible elements Script to be executed when a key is released. onload<body>,<iframe>,<img>,<input>,<script>Script to be executed when an element finishes loading. onloadeddata<audio>,<video>Script to be executed when the media’s data is loaded. onloadedmetadata<audio>,<video>Script to be executed when the media’s metadata is loaded. onloadstart<audio>,<video>Script to be executed when the media starts loading. onmessage<iframe>,<object>,<window>Script to be executed when a message is received from another window. onmousedownAll visible elements Script to be executed when the mouse button is pressed down. onmousemoveAll visible elements Script to be executed when the mouse pointer moves. onmouseoutAll visible elements Script to be executed when the mouse pointer leaves an element. onmouseoverAll visible elements Script to be executed when the mouse pointer is moved onto an element. onmouseupAll visible elements Script to be executed when the mouse button is released. onpause<audio>,<video>Script to be executed when the media is paused. onplay<audio>,<video>Script to be executed when the media starts playing. onplaying<audio>,<video>Script to be executed when the media starts playing after having been paused. onprogress<audio>,<video>Script to be executed while the media is being loaded. onratechange<audio>,<video>Script to be executed when the playback rate changes. onreset<form>Script to be executed when a form is reset. onscrollAll visible elements Script to be executed when an element is scrolled. onseeked<audio>,<video>Script to be executed when the user has finished seeking to a new position in the media. onseeking<audio>,<video>Script to be executed when the user starts seeking to a new position in the media. onselect<input>,<textarea>Script to be executed when text is selected. onstalled<audio>,<video>Script to be executed when the media has stopped loading. onsubmit<form>Script to be executed when a form is submitted. onsuspend<audio>,<video>Script to be executed when the media is paused before it can be played. ontimeupdate<audio>,<video>Script to be executed when the time of the media is updated. onvolumechange<audio>,<video>Script to be executed when the volume changes. onwaiting<audio>,<video>Script to be executed when the media pauses to buffer. open<details>Specifies whether the <details>element is open or closed.optimum<meter>Defines the range that is considered optimal. pattern<input>Specifies a regular expression that the input element’s value must match. placeholder<input>,<textarea>Provides a hint to the user about what to enter in an input field. poster<video>Specifies an image to show as a placeholder before the video starts playing. preload<audio>,<video>Specifies if and how the media should be loaded when the page loads. readonly<input>,<textarea>Specifies that an input field is read-only. rel<a>,<area>,<link>Specifies the relationship between the current document and the linked document. required<input>,<select>,<textarea>Indicates that the user must fill out this field before submitting the form. reversed<ol>Specifies that the list order should be reversed. rows<textarea>Defines the number of visible rows in a text area. rowspan<td>,<th>Specifies how many rows a table cell should span. sandbox<iframe>Enables an extra set of restrictions for the content in an <iframe>.scope<td>,<th>Specifies whether a header cell is a header for a row, column, or group of rows or columns. selected<option>Specifies that an option should be pre-selected. shape<area>Defines the shape of a clickable area in an image map. size<input>,<select>Specifies the width of the element. sizes<link>Specifies the size of the linked resource. span<col>Defines the number of columns a column group should span. spellcheckGlobal Attributes Specifies whether the element should be checked for spelling and grammar. src<audio>,<embed>,<iframe>,<img>,<input>,<script>,<source>,<video>Specifies the URL of the media resource. srcdoc<iframe>Specifies the HTML content to be displayed in an <iframe>.srclang<track>Specifies the language of the track text data. srcset<img>,<source>Defines a set of images to be used by the browser based on the screen size and resolution. step<input>Specifies the legal number intervals for an input field. summary<table>Provides a summary of the content of the table. tabindexAll visible elements Specifies the tab order of an element. target<a>,<form>,<base>Specifies where to open the linked document or where to submit the form. titleAll visible elements Provides additional information about an element (often shown as a tooltip). typeAll visible elements Specifies the type of element or attribute, such as the type of an input or the type of a script. usemap<img>,<object>,<input>Specifies an image map to be used with the <img>,<object>, or<input>element.value<input>,<button>,<option>,<li>Specifies the value of an element. width<img>,<input>,<iframe>,<video>,<canvas>,<embed>Specifies the width of an element. wrap<textarea>Specifies how the text in a text area should be wrapped. Feel free to ask if you need more details on any of these attributes!
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login