HTML Attribute
Attribute allows to specify how web browsers should treat a particular tag (provides additional information on its elements). It is included within start tag or an empty tag. End or closing tags do not contain attributes.
Example
align="center"
List of some of the HTML Attributes
Attribute | Description | Used with Element |
---|---|---|
action | Used for directing request with form-data while submitting a form. | <form> |
alt | Used to show an alternate text when the original content failed to display. | <img> <area> <input> |
async | Used for allowing a script to run asynchrously. | <script> |
autoplay | Used to make a video or audio play automatically when it is ready. | <video> <audio> |
checked | Used to pre-select option of radio type or checkbox type. | <input> |
charset | Used for setting the character encoding. | <meta><script> |
class | Used for assigning one or more class for styling the element using css. | Global |
col | Used for specifying the width of text area. | <textarea> |
controls | Used for showing audio or video controls, such as play/pause button. | <video> <audio> |
disabled | Used for assigning one or more class for styling the element using css. | <input> <button> <select> <option> <textarea> <fieldset> |
download | Used for starting download when a link is clicked. | <a><textarea> |
form | Used for indicating the element's form. | <input> <button> <select> <option> <textarea> <fieldset> <meter> <object> |
height | Used for specifying the height of the element. | <input> <img> <video> <canvas> <object> <iframe> <embed> |
hidden | Used for hiding the element. | Global |
href | Used for specifying the URL of a page. | <a> <textarea> <link> <base> |
id | Used for assigning a unique id to an element. | Global |
lang | Used for specifying the language of an element. | Global |
max | Used for specifying the maximum value of the element. | <input> <progress> <mater> |
maxLength | Used for maximum length of the element. | <input> <textarea> |
method | Used for specifying the request type, such as POST, GET, DELETE, PATCH, etc. | <form> |
min | Used for specifying a minimum value of the element. | <input> <meter> |
name | Used for specifying the name of the element. | <input> <textarea> <button> <fieldset> <iframe> <select> <meta> <map> <object> <param> |
novalidate | Used for specifying that the form must not be validated while submitting. | <form> |
onclick | This is an event attribute. Used for specifying what to run when a value of an element is clicked. | <select> |
onchange | This is an event attribute. Used for specifying what to run when a value of an element is changed. | <select> <button> <input> |
onscroll | Used to detect when an element's scrollbar is being scrolled. | <table> <body> |
onsubmit | Used to detect an event when a form is submitted. | <form> |
placeholder | Used to show hint value to describe what value is accepted. | <textarea> <input> |
selected | Used to pre-select an option of the element. | <option> |
shape | Used for specifying shape of the element. | <textarea> |
spellcheck | Used for specifying if the element should have specifying and grammer checking. | Global |
style | Used for specifying an inline css style for the element. | Global |
target | Used for specifying whether to open a page in the new tab of a browser. | <a> <area> <base> <form> |
type | Used for specifying the type of an element. | <input> <button> <embed> <a> <link> <object> <menu> <script> <style> <source> |
value | Used to assign a value to the element. | <input> <button> <li> <meter> <option> <param> <progress> |
wrap | Used for wrapping a text in textarea when submitting. | <textarea> |