HTML Attributes

HTML Attributes Complete Reference

This is an alphabetical quick-reference of the most common HTML attributes and the elements they apply to.


HTML Attributes Reference

The table below lists frequently used HTML attributes along with the elements they belong to and a short description of what each does. Global attributes such as id, class and style apply to all elements, while others are specific to particular tags.

ℹ️

Use this as a lookup table. For a deeper explanation of any single attribute, see its dedicated topic in the Learn HTML attributes section.

AttributeBelongs toDescription
accept<input>File types a file-upload control should accept
accept-charset<form>Character encodings the server accepts on submit
accesskeyGlobalKeyboard shortcut to focus or activate the element
action<form>URL that processes the submitted form data
alt<img>, <area>, <input>Alternative text describing an image
async<script>Load an external script asynchronously
autocomplete<form>, <input>, <select>, <textarea>Whether the browser may autofill the field
autofocus<button>, <input>, <select>, <textarea>Focus the element automatically on load
autoplay<audio>, <video>Start playing media as soon as it can
charset<meta>, <script>Character encoding of the document or script
checked<input>Pre-select a checkbox or radio button
classGlobalClass names used by CSS and JavaScript
cols<textarea>Visible width of a textarea in characters
colspan<td>, <th>Number of columns a table cell spans
contenteditableGlobalWhether the element's content is editable
controls<audio>, <video>Show default media playback controls
data-*GlobalCustom author-defined data attributes
dirGlobalText direction: ltr, rtl or auto
disabledForm elementsDisable the control so it cannot be used
draggableGlobalWhether the element can be dragged
for<label>, <output>Associates a label with a form control's id
href<a>, <link>, <area>, <base>URL of a linked resource
hiddenGlobalHide the element from rendering
idGlobalUnique identifier for the element
langGlobalLanguage of the element's content
loading<img>, <iframe>Lazy or eager loading of the resource
max<input>, <meter>, <progress>Maximum allowed value
maxlength<input>, <textarea>Maximum number of characters allowed
method<form>HTTP method used to submit the form (get or post)
min<input>, <meter>Minimum allowed value
multiple<input>, <select>Allow selecting or entering multiple values
nameForm elements, <meta>, etc.Name of the control, used when submitting data
pattern<input>Regular expression the value must match
placeholder<input>, <textarea>Hint text shown when the field is empty
readonly<input>, <textarea>Make the field read-only
rel<a>, <link>, <area>Relationship of the linked resource
requiredForm elementsField must be filled before submitting
rows<textarea>Visible number of text lines
rowspan<td>, <th>Number of rows a table cell spans
selected<option>Pre-select an option in a dropdown
src<img>, <script>, <iframe>, <audio>, <video>URL of the embedded resource
styleGlobalInline CSS applied to the element
tabindexGlobalKeyboard tab order and focusability
target<a>, <form>, <base>Where to open the linked document, e.g. _blank
titleGlobalAdvisory tooltip text
type<input>, <button>, <script>, etc.The type of control, script or media
value<input>, <option>, <button>The current or initial value of the element
width<img>, <canvas>, <video>, etc.Intrinsic width of the element in pixels
💡

Attributes marked Global can be used on any element. Prefer semantic HTML and use these attributes to enhance behaviour and accessibility rather than replacing proper element choice.

Ready to use your HTML skills?

Find web development internships and fresher jobs across India.

Browse Web Dev Internships