HTML - Attribute Reference



HTML attributes are the special keywords of HTML, attributes are used inside the opening tag. An HTML element type can be modified via HTML attributes. An attribute either changes an element type default functionality or adds functionality to some element type that wouldn't work properly without it.

Attribute Example

Types of HTML Attributes

In this article we have collected all the attributes in one place and we have categorize them into two parts.

Local Attributes

Local attributes are element specific, these attributes can be used on some specific HTML elements. Following are the local attributes.

Attribute Description Example
accept The HTML accept attribute is used to describe what file type the user should be allowed to select from a file input dialog box.
accept-charset The HTML accept-charset attribute is used to specify the character encodings that are to be used for the form submission.
action The HTML action attribute is used to specify a URL that processes the form submission.
align The alignment of content within an HTML element, such as images or tables, was specified by the HTML align attribute.
alt The alt attribute is essential for supplying alternative text for images, facilitating accessibility, and improving user experience.
async The HTML async attribute is a Boolean attribute that is used to specify the script to execute/run as soon as it’s loaded.
autofocus The HTML autofocus attribute is a boolean attribute that is used to specify that an element should be autofocused after the page has loaded.
bgcolor The HTML bgcolor attribute or property is used to represent the background color of elements.
border The border of an HTML element, such as tables and images, can be specified using the HTML border attribute.
charset The HTML charset attribute is used for the character encoding in the HTML document.
checked The HTML checked attribute is a boolean attribute that indicates whether a checkbox is checked by default (when the page loads).
class One or more classes can be specified for an HTML element using the class attribute, which is a fundamental element.
color The HTML color attribute is used to set the text color of the font element.
cols The HTML cols attribute is used to set or specify the visible width of a text area element.
colspan The HTML colspan attribute is used to define how many table columns a cell should span or extend.
content The HTML content attribute is used to display/contain the value for the name or HTTP-equiv attribute, depending on which is used.
coords The HTML coords attribute is used to specify/set the coordinates of an area in an image map.
data The HTML data attribute is used to specify the URL for the resource.
datetime The HTML datetime attribute is used to indicate the date and time associated with the element.
default The HTML default attribute is a boolean attribute that is used to indicate that a track should be enabled unless the user's preferences indicate that another track is more appropriate.
defer The HTML defer attribute is a boolean attribute that specifies that the script is downloaded parallel to parsing the page, and is executed after parsing the page.
dirname The HTML dirname attribute is used to enable the submission of the directionality of the element.
disabled The HTML disabled attribute is used to specify that the element is disabled.
download The HTML download attribute is used to specify that the resource( the file or resource specified in the href attribute) will be downloaded when a user clicks on the hyperlink.
enctype The HTML enctype attribute is used to specify how the form input data should be encoded before sending it to the server.
formaction The HTML formaction attribute is used to specify an URL of the file that will process the input controls and redirect to a different page when the form is submitted.
headers The HTML header attribute is used to specify a table cell that contains the header information for the current data cell.
height In HTML, the height attribute is frequently used to specify the vertical dimension in pixels of an element, such as an image or an iframe.
high The HTML high attribute is used to specify the lower bound of an upper range.
href The HTML href attribute is used to specify the URL that a hyperlink points to.
hreflang The HTML hreflang attribute is used to specify the language of the linked document or URL.
httpequiv The HTML http-equiv attribute is used to define the pragma directive.
id An HTML element that is used to identify an HTML element on a webpage is the id attribute.
ismap The HTML ismap attribute is a Boolean attribute that is used to specify that the image is part of a server-side image map.
kind The HTML kind attribute is used to specify the kind of text track for the audio/video.
list The HTML list attribute refers to the datalist element that contains the predefined options for an input element.
low The HTML low attribute indicates the upper limit of the lower range.
max The HTML max attribute is used to define the maximum value that is acceptable and valid for an input field.
maxlength The HTML maxlength attribute is used to define the maximum number of characters the user can enter into an ‘input’ and ‘textarea’ field.
media The HTML media attribute is used to specify a hint of the media for which the linked resource was designed.
method The HTML method attribute is used to define which HTTP method to use when submitting the form.
minlength The HTML minlength attribute is used to define the minimum number of characters that a user can enter into an 'input' or 'textarea' field.
min For input elements such as <input type="number">, <input type="date">, or <input type="time">, the min attribute in HTML is used to define the minimal value.
multiple The HTML multiple attribute is a Boolean attribute, and if present, it allows form controls to accept more than one value.
name The HTML name attribute is used to specify the name of an element.
open The open attribute is an HTML attribute that indicates or specifies whether the details, that is, the contents of the <details> element, are currently visible.
optimum The optimum is an HTML attribute that specifies the range where the gauge’s (to determine the capacity of contents or estimate a judge's) value is considered to be an optimal value.
pattern The HTML pattern attribute is usually used with input elements, particularly text fields like input and textarea.
placeholder The HTML placeholder attribute is used to define a short hint that helps the user with data entry.
poster The HTML poster attribute is used to specify an image/poster for the video.
readonly The HTML readonly attribute is used to specify that an input, or textarea field, is read-only.
rel The rel is an HTML attribute that specifies the relationship between the current document and the linked document or resource.
required The HTML required attribute is a boolean attribute. It is used to specify that an input field must be filled by users before submitting the form.
reversed This attribute can be helpful when you want to show a countdown or sort items by decreasing value.
rows The rows is an HTML attribute that is used to specify the height of the textarea in lines.
rowspan The rowspan is an HTML attribute that specifies the number of rows spanned by a cell or grid cell within a table or grid.
sandbox The sandbox is an HTML attribute that stops a document loaded in an iframe from using certain features (such as submitting forms or opening new windows).
scope The scope is an HTML attribute that is used to define the header cell.
selected In HTML, to choose element's options from a dropdown menu are utilized using the selected attribute.
shape The shape is an HTML attribute used to specify an area's shape.
size The size is an HTML attribute that is used to specify the initial width of the input field and the number of visible rows for the selected element.
sizes The sizes is an HTML attribute that specifies the sizes of the linked resources. It is used to provide the sizes of icons for visual media.
src The HTML src attribute is used to represent external resources such as images, videos, audio, and URLs in the page from the external or device resource. Try It
span The span attribute is an HTML attribute that specifies the number of columns a <col> or <colgroup> element should span.
srcdoc The srcdoc is an HTML attribute that specifies the HTML content on the page to show in the inline frame.
srclang The srclang attribute is an HTML attribute that is used to specify the language of the track text.
srcset The srcset is an HTML attribute that is used to specify the URL of an image to use in different situations.
start The start attribute is an HTML attribute that specifies the initial value of the ordered list in numeric form.
step It is used to set the interval between legal numbers or the distinct step size of the <input> tag.
style The HTML style attribute contains a CSS styling declaration and is used to apply it to an element.
target The target is an HTML attribute that is used to specify where to open the linked document.
type The type is an HTML attribute that specifies the type of element.
usemap The usemap is an HTML attribute that creates relationships between <img> and <map> by specifying an image or an object with clickable areas.
value For various form elements like input fields, checkboxes, radio buttons, and select options, the initial or default value is specified using the HTML value attribute.
width The width of an element can be specified in pixels or as a percentage of its parent container using the HTML width attribute.
wrap The wrap attribute of HTML ref is used to wrap the text in a text area when submitted in a HTML form.

Global Attributes

Global attributes are common to all HTML elements and can be used universally. Some of the most important global attributes include.

Attribute Description Example
accesskey The accesskey is a global attribute that provides a hint for generating a keyboard shortcut for the current element.
class The class is a global attribute that is used to specify the class name for the current element or tag.
contenteditable The contenteditable attribute is an HTML global attribute that specifies or indicates whether or not the content present in the browser is editable by the user.
data-* Used to store custom data associated with the element.
dir The dir attribute is used to control the text direction in websites.
draggable The draggable is an HTML global attribute that is used to specify whether an element is draggable or not.
hidden The Hidden HTML Global attribute indicates that the content of an element should not be displayed to the user.
id The id is an HTML global attribute that defines an identifier (id) that must be unique in the whole HTML document.
lang The lang attribute is an HTML Global attribute that is used to define the language of an element's content.
spellcheck Several elements, including text input fields and contenteditable elements, can have the spellcheck global attribute applied to them in HTML.
style A global attribute in HTML called style enables programmers to apply inline CSS styles to HTML elements.
tabindex Specifies the tab order of an element.
title A text to display in a tool tip.
translate A global attribute called translate was created to facilitate the translation and internationalization of web content.
Advertisements