HTML attributes provide additional instructions or meaning to HTML elements. This reference acts as an alphabetical guide to the most common attributes you will use when building standard web pages.
| Attribute | Tags Used On | Description |
|---|---|---|
accept | <input> | Specifies the types of files that the server accepts (only for type="file"). |
action | <form> | Specifies where to send the form-data when a form is submitted. |
alt | <img>, <area> | Provides alternative text for an image if the image cannot be displayed. |
async | <script> | Specifies that the script is executed asynchronously (only for external scripts). |
autocomplete | <form>, <input> | Specifies whether a form or input field should have autocomplete turned on or off. |
autoplay | <video>, <audio> | Specifies that the media will automatically start playing as soon as it can do so. |
charset | <meta>, <script> | Specifies the character encoding used. |
checked | <input> | Pre-selects an input element when the page loads (for type="checkbox" or "radio"). |
class | Global Attribute | Specifies one or more classnames for an element (used by CSS and JavaScript). |
cols | <textarea> | Specifies the visible width of a text area. |
colspan | <td>, <th> | Specifies the number of columns a table cell should span across. |
controls | <video>, <audio> | Specifies that audio/video controls should be displayed (play, pause, etc). |
data-* | Global Attribute | Used to store custom, invisible data on an element for JavaScript to use later. |
defer | <script> | Tells the browser to only execute the script when the page has finished parsing. |
disabled | <input>, <button>, <select> | Disables an element so the user cannot click or interact with it. |
download | <a>, <area> | Instructs the browser to download the URL instead of navigating to it. |
| Attribute | Tags Used On | Description |
|---|---|---|
enctype | <form> | Specifies how form-data should be encoded when submitting (vital for file uploads). |
for | <label>, <output> | Binds a label to a specific form element by referencing its id. |
height | <img>, <video>, <iframe> | Specifies the height of an element in pixels. |
hidden | Global Attribute | Instantly hides an element from the page. |
href | <a>, <link>, <base> | Specifies the massive URL (web address) of the linked page or resource. |
id | Global Attribute | Provides a unique identification name for an element. Must not be used twice on the same page. |
label | <track>, <option> | Specifies the title of the text track or option group. |
loop | <video>, <audio> | Makes the media file start over again automatically when it finishes. |
max | <input> | Specifies the maximum value allowed (like maximum date or number). |
maxlength | <input>, <textarea> | Limits the maximum number of text characters the user can type in the field. |
method | <form> | Specifies the HTTP method to use when submitting form-data (GET or POST). |
min | <input> | Specifies the minimum value allowed. |
multiple | <input>, <select> | Allows the user to select more than one value or file. |
muted | <video>, <audio> | Forces the media output to be muted upon loading. |
| Attribute | Tags Used On | Description |
|---|---|---|
name | <input>, <button>, <form> | Specifies the name of an element (crucial for form data submission). |
pattern | <input> | Specifies a regular expression that the input's value is checked against before submission. |
placeholder | <input>, <textarea> | Displays a short hint in a text field before the user enters a value. |
poster | <video> | Specifies an image to be shown prominently while the video is downloading. |
readonly | <input>, <textarea> | Specifies that an input field cannot be modified by the user (but text can still be copied). |
rel | <a>, <link> | Specifies the relationship between the current document and the linked document (e.g. stylesheet). |
required | <input>, <select> | Forces the user to fill out the form field before they are allowed to submit the form. |
rows | <textarea> | Specifies the visible number of lines in a text area. |
rowspan | <td>, <th> | Specifies the number of rows a table cell should span vertically. |
src | <img>, <video>, <script> | Specifies the actual URL or path of the media file/script to be embedded. |
step | <input> | Specifies the legal number intervals for an input field (e.g. step="2" for 2, 4, 6...). |
style | Global Attribute | Used to write inline CSS to style an individual element. |
tabindex | Global Attribute | Specifies the tabbing order of an element when using the "Tab" key on a keyboard. |
target | <a>, <form> | Specifies where to open the linked document (e.g. _blank for a new window). |
title | Global Attribute | Provides extra information about an element, usually shown as a tooltip when hovered. |
type | <input>, <button>, <link> | Specifies the type of input/element (e.g. password, checkbox, submit). |
value | <input>, <button>, <option> | Specifies the underlying value or text content of the element. |
width | <img>, <video>, <iframe> | Specifies the width of an element in pixels. |