HTML Attributes provide extra information about HTML Tags. This is the List of all HTML Attributes and their Function. HTML Attributes are used in almost all HTML Elements.
Table of Contents
What is HTML Attribute
HTML Attribute is something that we use in the starting tag of HTML Elements or HTML Tags which provides extra information about those HTML Elements or HTML Tags.
List of HTML Attributes
There are around 170 HTML Attributes that we use. List of all HTML Attributes is given below.
-
accept attribute
It is used for input tag (only for type="file"), it tells about the type of files that the website server accepts or user can upload, Read More.
-
accept-charset attribute
It is used for form tag, It specifies the character encoding that is to be used for the submission of form, Read More.
-
accesskey attribute
It defines a shortcut key to activate or focus an element, Read More.
-
action attribute
It is used for form tag, It tells where to send the submitted form data, Read More.
-
align attribute
It is not supported in HTML5, It was used to specify the alignment with respect to surrounding elements but we use CSS for that now, Read More.
-
alt attribute
It is used for img tag, area tag and input tag. It defines the alternative text if the element doesn't display, Read More.
-
async attribute
It is used for script tag, It tells that script is executed asynchronously, Read More.
-
autocomplete attribute
It is used for form tag, input tag. It's value is on. It enables the browser to display previously typed text, so you don't have to write it again and again.
-
autofocus attribute
It is used for button tag, input tag, select tag and textarea tag. It enables element to automatically get focused when the page loads.
-
autoplay attribute
It is used for audio tag, video tag, It specifies that the audio or video should automatically play after the page is loaded.
-
border attribute
It is not supported in HTML 5, It is used to set width of border, we use CSS instead now.
-
bgcolor attribute
It is not supported in HTML 5, It is used to set background color of element, we use CSS instead now.
-
charset attribute
It is used for meta tag and script tag. It defines the character encoding.
-
checked attribute
It is used for input tag (for type="radio" or type="checkbox"), It specifies the element to be pre-selected.
-
cite attribute
It is used for blockquote tag, del tag, ins tag and q tag. It gives the URL of document which explains the quote, text or data.
-
class attribute
It is a Global Attribute. It defines one or more class names for an element that can be used to style it or can be used to refer to it by JavaScript for various interactive functions.
-
color attribute
It is not supported in HTML 5. It sets the text color of element, but we use CSS for that now.
-
cols attribute
It is used for textarea tag. It defines the width of text area.
-
colspan attribute
It is used for th tag and td tag. It defines the number of columns table cell must have.
-
content attribute
It is used for meta tag. It defines the content type of meta data.
-
contenteditable attribute
It is also a Global Attribute. It defines if the content of Html element is editable or not.
-
controls attribute
It is used for audio tag and video tag. It allows the browser to display the control buttons (like play and pause etc) for the audio or video file.
-
coords attribute
It is used for area tag. It defines the coordinates of the area element.
-
data attribute
It is used for object tag. It defines the URL of the resource that is linked with object.
-
data-* attribute
It is also a Global Attribute. It enables us to embed or store the custom data attributes on all our HTML elements.
-
datetime attribute
It is used for del tag, time tag and ins tag. It sets the date and time on web page.
-
default attribute
It is used for track tag. It is a Boolean attribute, It defines which track is to be enabled if the user doesn't specify the appropriate track.
-
defer attribute
It is used for script tag. It is only used for external script files. It makes sure that the script is only executed after the page parsing is complete.
-
dir attribute
It is used to set the base direction of text for display.
-
dirname attribute
It is used for input tag, textarea tag. It enables that the direction of text will be submitted.
-
disabled attribute
It is used for button tag, fieldset tag, input tag, optgroup tag, option tag, select tag and textarea tag. It disables the element or group of elements.
-
draggable attribute
It is a Global Attribute. It defines if element is draggable or not.
-
dropzone attribute
It is a Global Attribute. It defines if dragged data is copied, linked or moved when dropped.
-
enctype attribute
It is used for form tag. It specifies the encoding method of form data when the form is submitted.
-
face attribute
It defines default font for text but it is not supported in HTML5.
-
for attribute
It is used for label tag and output tag. It defines the link of label or calculation with the element.
-
form attribute
It is used for button tag, fieldset tag, label tag, input tag, meter tag, object tag, output tag, select tag and textarea tag. It specifies which form belongs to the particular element using form name.
-
formaction attribute
It is used for button tag and input tag. It tells where to send the form data when form is submitted. It is only for type="submit".
-
headers attribute
It is used for td tag and th tag. It defines one or more header cells connected to a cell.
-
height attribute
It is used for canvas tag, embed tag, iframe tag, img tag, input tag, object tag and video tag. It sets the height of element.
-
hidden attribute
It is a Global Attribute. It is Boolean attribute, it hides the element.
-
high attribute
It is used for meter tag. It sets the value for meter tag which is considered high.
-
href attribute
It is used for a tag, area tag, base tag and link tag. It sets the URL of web page or document.
-
hreflang attribute
It is used for a tag, area tag and link tag. It defines the Language of web page or document.
-
http-equiv attribute
It is used for meta tag. It defines HTTP response header for the value of the content attribute.
-
id attribute
It is a Global Attribute. It defines a specific id for element. Element id must be unique.
-
ismap attribute
It is used for img tag. It defines an image to be image-map.
-
kind attribute
It is used for track tag. It defines the type of text track.
-
label attribute
It is used for track tag, option tag and optgroup tag. It defines the title of text track.
-
lang attribute
It is a Global Attribute. It defines the language of element's content.
-
list attribute
It is used for input tag. It is used for the datalist element that have pre defined listed options for input element.
-
loop attribute
It is used for audio tag and video tag. It specifies that audio or video file will repeat every time after it's finished.
-
low attribute
It is used for meter tag. It defines the range for meter element that sets the value which is considered low.
-
max attribute
It is used for input tag, meter tag and progress tag. It defines the maximum value.
-
maxlength attribute
It is used for input tag and textarea tag. It specifies the maximum number of characters that are allowed for input tag or textarea tag.
-
media attribute
It is used for a tag, area tag, link tag, source tag and style tag. It explains that which device is optimal for the linked web page or document.
-
method attribute
It is used for form tag. It defines which method to use while submitting the form data. Two main methods are Post and Get.
-
min attribute
It is used for input tag and meter tag. It defines the minimum value.
-
multiple attribute
It is used for input tag and select tag. It enables the user to enter more than one values for input type elements.
-
muted attribute
It is used for audio tag and video tag. It makes the audio and video file silent, the sound will be muted.
-
name attribute
It is used for button tag, fieldset tag, form tag, iframe tag, input tag, map tag, meta tag, object tag, output tag, param tag, select tag and textarea tag. It defines the name of the element.
-
novalidate attribute
It is used for form tag. It specifies that the form should be submitted without validation.
-
onabort attribute
It is used for audio tag, video tag, embed tag, img tag and object tag. It specifies that the script must always run on abort.
-
onafterprint attribute
It is used for body tag. It specifies that the script must always run after the desired document is printed.
-
onbeforeprint attribute
It is used for body tag. It specifies that the script must always run before the desired document is printed.
-
onbeforeunload attribute
It is used for body tag. It specifies that the script must always run before the time when document is unloaded.
-
onblur attribute
It is used for All Visible Elements. It specifies that script will run once the element is out of focus.
-
oncanplay attribute
It is used for audio tag, video tag, embed tag and object tag. It specifies that script will run once the file has buffered to the limit that it can start playing.
-
oncanplaythrough attribute
It is used for audio tag and video tag. It specifies that script will run once the file has buffered completely.
-
oncanplaythrough attribute
It is used for audio tag and video tag. It specifies that script will run once the file has buffered completely so that file can play without any pause.
-
onchange attribute
It is used for All Visible Elements. It specifies that script will run if the value of element is changed.
-
onclick attribute
It is used for All Visible Elements. It specifies that script will run when the element is clicked.
-
oncontextmenu attribute
It is used for All Visible Elements. It specifies that script will run when the context menu is triggered or initiated.
-
oncopy attribute
It is used for All Visible Elements. It specifies that script will run when the content of element is copied.
-
oncuechange attribute
It is used for track tag. It specifies that script will run when the cue is changed.
-
oncut attribute
It is used for All Visible Elements. It specifies that script will run when the content of element is being cut.
-
ondblclick attribute
It is used for All Visible Elements. It specifies that script will run when the element is double clicked.
-
ondrag attribute
It is used for All Visible Elements. It specifies that script will run when the element is dragged.
-
ondragend attribute
It is used for All Visible Elements. It specifies that script will run when the element is dragged till the end.
-
ondragenter attribute
It is used for All Visible Elements. It specifies that script will run when the element is dragged till a particular target or point.
-
ondragleave attribute
It is used for All Visible Elements. It specifies that script will run when the element leaves a particular target or point while being dragged.
-
ondragover attribute
It is used for All Visible Elements. It specifies that script will run when the element is dragged over a particular target or point.
-
ondragstart attribute
It is used for All Visible Elements. It specifies that script will run when the dragging process of element has just started.
-
ondrop attribute
It is used for All Visible Elements. It specifies that script will run when the element is being dropped.
-
ondurationchange attribute
It is used for audio tag and video tag. It specifies that script will run when the length of media file changes.
-
onemptied attribute
It is used for audio tag and video tag. It specifies that script will run when the file is suddenly not available due to the disconnection or something.
-
onended attribute
It is used for audio tag and video tag. It specifies that script will run when the file has reached the end, usually a greeting message.
-
onerror attribute
It is used for audio tag. body tag, embed tag, img tag, object tag, script tag, style tag and video tag. It specifies that script will run if the error occurs.
-
onfocus attribute
It is used for All Visible Elements. It specifies that script will run when the element gets focused.
-
onhashchange attribute
It is used for body tags. It specifies that script will run when the anchor part of URL is changed.
-
oninput attribute
It is used for All Visible Elements. It specifies that script will run when user will enter some input for element.
-
oninvalid attribute
It is used for All Visible Elements. It specifies that script will run when the element is invalid.
-
onkeydown attribute
It is used for All Visible Elements. It specifies that script will run when the user is pressing a key.
-
onkeypress attribute
It is used for All Visible Elements. It specifies that script will run when the user presses a key.
-
onkeyup attribute
It is used for All Visible Elements. It specifies that script will run when the user releases a key.
-
onload attribute
It is used for body tag, img tag, iframe tag, input tag, link tag, script tag and style tag. It specifies that script will run when the element is loaded completely.
-
onloadeddata attribute
It is used for audio tag and video tag. It defines that script will run when the file is loaded.
-
onloadedmetadata attribute
It is used for audio tag and video tag. It defines that script will run when the meta data of file is loaded.
-
onloadstart attribute
It is used for audio tag and video tag. It defines that script will run as soon as the file has started loading.
-
onmousedown attribute
It is used for All Visible Elements. It defines that script will run when the mouse button is pressed.
-
onmousemove attribute
It is used for All Visible Elements. It defines that script will run when the pointer of mouse is moving over element.
-
onmouseout attribute
It is used for All Visible Elements. It defines that script will run when the pointer of mouse is moving out of element.
-
onmouseover attribute
It is used for All Visible Elements. It defines that script will run when the pointer of mouse moves over an element.
-
onmouseup attribute
It is used for All Visible Elements. It defines that script will run when the pointer of mouse is released over an element.
-
onmousewheel attribute
It is used for All Visible Elements. It defines that script will run when the mouse wheel is scrolled over any element.
-
onoffline attribute
It is used for body tag. It defines that script will run when the browser works offline or there is no connection.
-
ononline attribute
It is used for body tag. It defines that script will run when the browser works online or the connection is reestablished.
-
onpagehide attribute
It is used for body tag. It defines that script will run when the user navigates away from the page.
-
onpageshow attribute
It is used for body tag. It defines that script will run when the user navigates to the page.
-
onpaste attribute
It is used for All Visible Elements. It defines that script will run when the user paste something to the element.
-
onpause attribute
It is used for audio tag and video tag. It defines that script will run when the media pauses due to any other reason.
-
onplay attribute
It is used for audio tag and video tag. It defines that script will run when the media starts playing.
-
onplaying attribute
It is used for audio tag and video tag. It defines that script will run when the media is playing.
-
onpopstate attribute
It is used for body tag. It defines that script will run when the window's history is changed.
-
onprogress attribute
It is used for audio tag and video tag. It defines that script will run when the browser is getting the media data.
-
onratechange attribute
It is used for audio tag and video tag. It defines that script will run when the user changes the speed of media i.e slow motion and fast motion.
-
onreset attribute
It is used for form tag. It defines that script will run when the reset button of the form is clicked.
-
onresize attribute
It is used for body tag. It defines that script will run when the browser size is changed.
-
onscroll attribute
It is used for All Visible Elements. It defines that script will run when the scroll bar of element is scrolled.
-
onsearch attribute
It is used for input tag (for input="search"). It specifies that script will run when the user writes something in the search field.
-
onseeked attribute
It is used for audio tag and video tag. It specifies that script will run when the process of seeking is ended.
-
onseeking attribute
It is used for audio tag and video tag. It specifies that script will run when the process of seeking is still going on.
-
onselect attribute
It is used for All Visible Elements. It specifies that script will run when the element gets selected.
-
onstalled attribute
It is used for audio tag and video tag. It specifies that script will run when the media data is stuck and browser is unable to fetch it.
-
onstorage attribute
It is used for body tag. It specifies that script will run whenever the Web storage area is updated.
-
onsubmit attribute
It is used for form tag. It specifies that script will run when the form is submitted.
-
onsuspend attribute
It is used for audio tag and video tag. It specifies that script will run when the process of fetching the media is stopped due to any reason.
-
ontimeupdate attribute
It is used for audio tag and video tag. It specifies that script will run when the playing position is changed by the user i.e forwards the media to specific point or reverse it.
-
ontoggle attribute
It is used for details tag. It specifies that script will run when the user opens or closes the details element.
-
onunload attribute
It is used for body tag. It specifies that script will run when the page is unloaded.
-
onvolumechange attribute
It is used for audio tag and video tag. It specifies that script will run when the volume of audio or video media file is changed.
-
onwaiting attribute
It is used for audio tag and video tag. It specifies that script will run when media file is paused due to buffering or due to any other reason.
-
onwheel attribute
It is used for All Visible Elements. It specifies that script will run when the mouse wheel rolls up or down.
-
open attribute
It is used for details tag. It specifies that details element should not be hidden.
-
optimum attribute
It is used for meter tag. It defines the value which is optimum for the gauge.
-
pattern attribute
It is used for input tag. It defines expression or pattern for input tag and is checked against it.
-
placeholder attribute
It is used for input tag and textarea tag. It displays the short hint or text for the user to tell what to enter as input.
-
poster attribute
It is used for video tag. It defines the image that will be displayed when the video is not played yet or it's downloading.
-
preload attribute
It is used for audio tag and video tag. It defines how the video or file should load when the page is loaded.
-
readonly attribute
It is used for input tag and textarea tag. It defines that element is read-only element.
-
rel attribute
It is used for link tag, a tag and area tag. It defines the relationship of linked document or file with the current file.
-
required attribute
It is used for input tag, select tag and textarea tag. It specifies that the form cannot be submitted without entering the value.
-
reversed attribute
It is used for ol tag. It specifies that the list items must be in descending order.
-
rows attribute
It is used for textarea tag. It defines the number of lines in textarea element.
-
rowspan attribute
It is used for td tag and th tag. It defines the number rows of the cell of table.
-
sandbox attribute
It is used for iframe tag. It defines the restriction for the iframe content.
-
scope attribute
It is used for th tag. It specifies if the header cell is header for rows, column or group of row or columns.
-
selected attribute
It is used for option tag. It specifies that the particular option must be selected when the page loads.
-
shape attribute
It is used for area tag. It defines the shape of area.
-
size attribute
It is used for input tag and select tag. It defines the size of input for the input tag (in characters) and the number of visible options for select tag.
-
sizes attribute
It is used for img tag, link tag and source tag. It defines the size of the linked document file or resource.
-
span attribute
It is used for col tag and colgroup tag. It defines the number of columns element should span.
-
spellcheck attribute
It is used for Global Attributes. It enables the element to be able to check the grammar and spelling of it's content.
-
src attribute
It is used for audio tag, embed tag, iframe tag, img tag, input tag, script tag, source tag, track tag and video tag. It defines the url of the file.
-
srcdoc attribute
It is used for iframe tag. It defines the HTML content of page which is to be shown in iframe tag.
-
srclang attribute
It is used for track tag. It defines the language of the text track data if kind is set to subtitles.
-
srcset attribute
It is used for img tag and source tag. It defines the url of image to be used in different situations.
-
start attribute
It is used for ol tag. It defines the start value of an ordered list.
-
step attribute
It is used for input tag. It defines the allowed number of intervals for an input tag.
-
style attribute
It is used for Global Attributes. It defines the inline styles of all HTML elements to change their style.
-
tabindex attribute
It is used for Global Attributes. It defines the tabbing order of element.
-
target attribute
It is used for a tag, area tag, base tag and form tag. It defines the target of where to open the linked document or page or file and also where to submit the form.
-
title attribute
It is used for Global Attributes. It defines the extra information about element.
-
translate attribute
It is used for Global Attributes. It defines if the content of an element should be translated or not.
-
type attribute
It is used for a tag, embed tag, button tag, link tag, menu tag, object tag, source tag, script tag, input tag and style tag. It defines the type of element.
-
usemap attribute
It is used for img tag and object tag. It defines the image as image map.
-
value attribute
It is used for li tag, meter tag, button tag progress tag, option tag, input tag and param tag. It defines the value of element.
-
width attribute
It is used for canvas tag, embed tag, iframe tag, img tag, object tag, input tag and video tag. It defines the width of element.
-
wrap attribute
It is used for textarea tag. It defines how to wrap the text when form is submitted in textarea tag.