The following table lists the defined attributes of the HTML standard. A global attribute can be used with any tag, whereas most attributes have certain tags with which they are most commonly used.
Attribute Name | Description |
---|---|
accept |
List of types the server accepts, typically a file type. |
accept-charset |
List of supported charsets. |
accesskey |
Keyboard shortcut to activate or add focus to the element. |
action |
The URI of a program that processes the information submitted via the form. |
align |
Specifies the horizontal alignment of the element. |
allow |
Specifies a feature-policy for the iframe. |
alt |
Alternative text in case an image can't be displayed. |
async |
Executes the script asynchronously. |
autocapitalize |
Sets whether input is automatically capitalized when entered by user |
autocomplete |
Indicates whether controls in this form can by default have their values automatically completed by the browser. |
autofocus |
The element should be automatically focused after the page loaded. |
autoplay |
The audio or video should play as soon as possible. |
background |
Specifies the URL of an image file. |
bgcolor |
Background color of the element. |
border |
The border width. |
buffered |
Contains the time range of already buffered media. |
capture |
From the HTML Media Capture The definition of 'media capture' in that specification.spec, specifies a new file can be captured. |
challenge |
A challenge string that is submitted along with the public key. |
charset |
Declares the character encoding of the page or script. |
checked |
Indicates whether the element should be checked on page load. |
cite |
Contains a URI which points to the source of the quote or change. |
class |
Often used with CSS to style elements with common properties. |
code |
Specifies the URL of the applet's class file to be loaded and executed. |
codebase |
This attribute gives the absolute or relative URL of the directory where applets' .class files referenced by the code attribute are stored. |
color |
This attribute sets the text color using either a named color or a color specified in the hexadecimal #RRGGBB format. |
cols |
Defines the number of columns in a textarea. |
colspan |
The colspan attribute defines the number of columns a cell should span. |
content |
A value associated with http-equiv or name depending on the context. |
contenteditable |
Indicates whether the element's content is editable. |
contextmenu |
Defines the ID of a ><menu> element which will serve as the element's context menu. |
controls |
Indicates whether the browser should show playback controls to the user. |
coords |
A set of values specifying the coordinates of the hot-spot region. |
crossorigin |
How the element handles cross-origin requests |
csp |
Specifies the Content Security Policy that an embedded document must agree to enforce upon itself. |
data |
Specifies the URL of the resource. |
data-* |
Lets you attach custom attributes to an HTML element. |
datetime |
Indicates the date and time associated with the element. |
decoding |
Indicates the preferred method to decode the image. |
default |
Indicates that the track should be enabled unless the user's preferences indicate something different. |
defer |
Indicates that the script should be executed after the page has been parsed. |
dir |
Defines the text direction. Allowed values are ltr (Left-To-Right) or rtl (Right-To-Left) |
dirname |
|
disabled |
Indicates whether the user can interact with the element. |
download |
Indicates that the hyperlink is to be used for downloading a resource. |
draggable |
Defines whether the element can be dragged. |
dropzone |
Indicates that the element accept the dropping of content on it. |
enctype |
Defines the content type of the form date when the method is POST. |
enterkeyhint |
The enterkeyhint specifies what action label (or icon) to present for the enter key on virtual keyboards. The attribute can be used with form controls (such as the value of textarea elements), or in elements in an editing host (e.g., using contenteditable attribute). |
for |
Describes elements which belongs to this one. |
form |
Indicates the form that is the owner of the element. |
formaction |
Indicates the action of the element, overriding the action defined in the <form> . |
formenctype |
If the button/input is a submit button (type="submit" ), this attribute sets the encoding type to use during form submission. If this attribute is specified, it overrides the enctype attribute of the button's form owner. |
formmethod |
If the button/input is a submit button (type="submit" ), this attribute sets the submission method to use during form submission (GET , POST , etc.). If this attribute is specified, it overrides the method attribute of the button's form owner. |
formnovalidate |
If the button/input is a submit button (type="submit" ), this boolean attribute specifies that the form is not to be validated when it is submitted. If this attribute is specified, it overrides the novalidate attribute of the button's form owner. |
formtarget |
If the button/input is a submit button (type="submit" ), this attribute specifies the browsing context (for example, tab, window, or inline frame) in which to display the response that is received after submitting the form. If this attribute is specified, it overrides the target attribute of the button's form owner. |
headers |
IDs of the <th> elements which applies to this element. |
height |
Specifies the height of elements listed here. For all other elements, use the CSS > |
hidden |
Prevents rendering of given element, while keeping child elements, e.g. script elements, active. |
high |
Indicates the lower bound of the upper range. |
href |
The URL of a linked resource. |
hreflang |
Specifies the language of the linked resource. |
http-equiv |
Defines a pragma directive. |
icon |
Specifies a picture which represents the command. |
id |
Often used with CSS to style a specific element. The value of this attribute must be unique. |
importance |
Indicates the relative fetch priority for the resource. |
integrity |
Specifies a Subresource Integrity value that allows browsers to verify what they fetch. |
intrinsicsize |
This attribute tells the browser to ignore the actual intrinsic size of the image and pretend it’s the size specified in the attribute. |
inputmode |
Provides a hint as to the type of data that might be entered by the user while editing the element or its contents. The attribute can be used with form controls (such as the value of textarea elements), or in elements in an editing host (e.g., using contenteditable attribute). |
ismap |
Indicates that the image is part of a server-side image map. |
itemprop |
|
keytype |
Specifies the type of key generated. |
kind |
Specifies the kind of text track. |
label |
Specifies a user-readable title of the element. |
lang |
Defines the language used in the element. |
language |
Defines the script language used in the element. |
loading |
Indicates if the element should be loaded lazily (loading="lazy" ) or loaded immediately (loading="eager" ).
|
list |
Identifies a list of pre-defined options to suggest to the user. |
loop |
Indicates whether the media should start playing from the start when it's finished. |
low |
Indicates the upper bound of the lower range. |
manifest |
Specifies the URL of the document's cache manifest. |
max |
Indicates the maximum value allowed. |
maxlength |
Defines the maximum number of characters allowed in the element. |
minlength |
Defines the minimum number of characters allowed in the element. |
media |
Specifies a hint of the media for which the linked resource was designed. |
method | Defines which HTTP method to use when submitting the form. Can be GET (default) or POST . |
min |
Indicates the minimum value allowed. |
multiple |
Indicates whether multiple values can be entered in an input of the type email or file . |
muted |
Indicates whether the audio will be initially silenced on page load. |
name |
Name of the element. For example used by the server to identify the fields in form submits. |
novalidate |
This attribute indicates that the form shouldn't be validated when submitted. |
open |
Indicates whether the details will be shown on page load. |
optimum |
Indicates the optimal numeric value. |
pattern |
Defines a regular expression which the element's value will be validated against. |
ping |
The ping attribute specifies a space-separated list of URLs to be notified if a user follows the hyperlink. |
placeholder |
Provides a hint to the user of what can be entered in the field. |
poster |
A URL indicating a poster frame to show until the user plays or seeks. |
preload |
Indicates whether the whole resource, parts of it or nothing should be preloaded. |
radiogroup |
|
readonly |
Indicates whether the element can be edited. |
referrerpolicy |
Specifies which referrer is sent when fetching the resource. |
rel |
Specifies the relationship of the target object to the link object. |
required |
Indicates whether this element is required to fill out or not. |
reversed |
Indicates whether the list should be displayed in a descending order instead of a ascending. |
rows |
Defines the number of rows in a text area. |
rowspan |
Defines the number of rows a table cell should span over. |
sandbox |
Stops a document loaded in an iframe from using certain features (such as submitting forms or opening new windows). |
scope |
Defines the cells that the header test (defined in the th element) relates to. |
scoped |
|
selected |
Defines a value which will be selected on page load. |
shape |
|
size |
Defines the width of the element (in pixels). If the element's type attribute is text or password then it's the number of characters. |
sizes |
|
slot |
Assigns a slot in a shadow DOM shadow tree to an element. |
span |
|
spellcheck |
Indicates whether spell checking is allowed for the element. |
src |
The URL of the embeddable content. |
srcdoc |
|
srclang |
|
srcset |
One or more responsive image candidates. |
start |
Defines the first number if other than 1. |
step |
|
style |
Defines CSS styles which will override styles previously set. |
summary |
|
tabindex |
Overrides the browser's default tab order and follows the one specified instead. |
target |
|
title |
Text to be displayed in a tooltip when hovering over the element. |
translate |
Specify whether an element’s attribute values and the values of
its text. |
type |
Defines the type of the element. |
usemap |
|
value |
Defines a default value which will be displayed in the element on page load. |
width |
Establishes the element's width. |
wrap |
Indicates whether the text should be wrapped. |
Boolean Attributes
Some content attributes (e.g. required
, readonly
, disabled
) are called boolean attributes. If a boolean attribute is present, its value is true, and if it’s absent, its value is false.
HTML5 defines restrictions on the allowed values of boolean attributes: If the attribute is present, its value must either be the empty string (equivalently, the attribute may have an unassigned value), or a value that is an ASCII case-insensitive match for the attribute’s canonical name, with no leading or trailing whitespace. The following examples are valid ways to mark up a boolean attribute:
<div itemscope> This is valid HTML but invalid XML. </div>
<div itemscope=itemscope> This is also valid HTML but invalid XML. </div>
<div itemscope=""> This is valid HTML and also valid XML. </div>
<div itemscope="itemscope"> This is also valid HTML and XML, but perhaps a bit verbose. </div>
To be clear, the values "true
" and "false
" are not allowed on boolean attributes. To represent a false value, the attribute has to be omitted altogether. This restriction clears up some common misunderstandings: With checked="false"
for example, the element’s checked
attribute would be interpreted as true because the attribute is present.