/

HTML / CSS / JavaScript Tutorial

HTML Standard attributes

[this page | pdf | back links]

Different HTML elements can have attributes that specify how they should be formatted or interpreted or allow further characterisation of the element, which can be either standard attributes or event attributes. Standard attributes describe or characterise the element further and include:

 

Attribute

Description

Applicable to

 

More

accept

Specifies types of file accepted by server

<input>

Here

accept-charset

Specifies character encodings used for form submission

<form>

Here

accesskey

Shortcut key to activate/focus element

All

Here

action

Where to send form-data when form submitted

<form>

Here

align

Alignment versus surrounding elements

 

Here. Not supported in HTML 5 (instead use CSS)

alt

Specifies alternative text to show when original content fails to display

Various

Here

async

Indicates if script to be executed asyncronously

<script>

Here. Only for external scripts

autocomplete

Specifies whether element has autocomplete enabled

<form>, <input>

Here

autofocus

Specifies whether element should automatically get focus when page loads

Various

Here

autoplay

Specifies whether audio/video should start playing as soon as ready

<audio>, <video>

Here

bgcolor

Specifies background colour

 

Here. Not supported in HTML 5 (instead use CSS)

border

Specifies width of border

 

Here. Not supported in HTML 5 (instead use CSS)

challenge

Indicates value of element should be challenged when submitted

<keygen>

Here

charset

Specifies character encoding

<meta>, <script>

Here

checked

Specifies that the element should be pre-selected

<input>, <menuitem>

Here

cite

URL which explains the quote / deleted / inserted text

<blockquote>, <del>, <ins>, <q>

Here

class

One or more class names for the element

All

Here. Refers to a class in a CSS style

color

Text colour of element

All text elements

Here. Not supported in HTML 5 (instead use CSS)

cols

Width of text area (in characters)

<textarea>

 

colspan

Number of columns a table cell should span

<td>, <th>

Here

content

Value associated with the http-equiv or name attribute

<meta>

Here

contenteditable

Indicates whether content is editable

All

Here

contextmenu

Specifies context menu (i.e. what appears when right-click)

All

Here

controls

Whether <audio> and <video> controls (such as play and pause buttons) should be displayed

<audio>, <video>

Here

coords

Specifies the coordinates of an <area>

<area>

Here

crossorigin

Specifies how element handles cross-origin requests

<img>, <link>

Here

data

URL of resource to be used by object

<object>

Here

data-*

Custom data private to page of application

All

Here

datetime

Date and time of element

<del>, <ins>, <time>

Here

default

Default track / command to be enabled unless user preferences specify otherwise

<menuitem>, <track>

Here

defer

Script to be executed only when page has finished parsing

<script>

Here. Only for external scripts

dir

Text direction for element content

All

Here

dirname

Specifies text direction will be submitted

<input>, <textarea>

Here

disabled

Specified element(s) to be disabled

Various

Here

download

Target will be downloaded when user clicks on hyperlink

<a>, <area>

Here

draggable

Whether element is draggable

All

Here

dropzone

Whether dragged data is copied, moved or linked when dropped

All

Here

enctype

How form-data to be encoded when submitted to server

<form>

Here. Only for method = post

for

Specifies which form element(s) a label calculation is bound to

<label>, <output>

Here

form

Name of the form that element belongs to

Various

Here

formaction

Where to send form-data to when form submitted

<button>, <input>

Here. Only for type = submit

formenctype

How form-data should be encoded before sending it to a server

<button>, <input>

Here. Only for type = submit

formmethod

How to send form-data (i.e. which HTTP method to use)

<button>, <input>

Here. Only for type = submit

formnovalidate

Specifies that form-data should not be validated on submission

<button>, <input>

Here. Only for type = submit

formtarget

Specifies where to display the response that is received after submitting form

<button>, <input>

Here. Only for type = submit

headers

One or more header cells a cell is related to

<td>, <th>

Here

height

Height of element

Various (not all)

Here

hidden

Whether element is not relevant

All

Here

high

Value above which is considered a high value

<meter>

Here

href

URL of page the link goes to

<a>, <area>, <base>, <link>

Here

hreflang

Language of linked document

<a>, <area>, <link>

Here

http-equiv

HTTP header for information/value of attribute

<meta>

Here

icon

Icon for a command / menu item

<menuitem>

Here

id

Unique id for an element (for e.g. JavaScript)

All

Here

ismap

Image is a server-side image-map

<img>

Here

keytype

Specifies security algorithm of key

<keygen>

Here

kind

Kind of text track

<track>

Here

label

Title / label of track or command or group of commands

<menu>, <menuitem>, <option>, <optgroup>, <track>

Here

lang

Language of an element’s content

All

Here

list

Refers to <datalist> that contains pre-defined options

<input>

Here

loop

Audio / video to start over again when it finishes

<audio>, <video>

Here

low

Value below which is considered a low value

<meter>

Here

manifest

Specifies address of document’s cache manifest (for offline browsing)

<html>

Here

max

Maximum value

<input>, <meter>, <progress>

Here

maxlength

Maximum number of characters allowed in an element

<input>, <textarea>

Here

media

Specifies media / device linked document is optimised for

<a>, <area>, <link>, <source>, <style>

Here

method

Specifies HTTP method used when sending form-data

<form>

Here

min

Minimum value

<input>, <meter>

Here

multiple

Indicates that a user can enter more than one value

<input>, <select>

Here

muted

Audio output should be muted

<audio>, <video>

Here

name

Name of element (or of a piece of metadata for a <meta> element)

Various

Here

novalidate

Form should not be validated when submitted

<form>

Here

open

Whether details should be visible (i.e. open) to user

<details>

Here

optimum

Value deemed optimal for gauge

<meter>

Here

pattern

Regular expression that value of element is checked against

<input>

Here

placeholder

Short hint describing expected value of element

<input>, <textarea>

Here

poster

Image to be shown while video is downloading (or until user hits play)

<video>

Here

preload

If / how author thinks audio / video should be loaded when page loads

<audio>, <video>

Here

radiogroup

Name of group of commands when menu item toggled

<menuitem>

Here

readonly

Whether element is read-only

<input>, <textarea>

Here

rel

Relationship between current document and linked document

<a>, <area>, <link>

Here

required

Whether the element must be filled out before submitting form

<input>, <select>, <textarea>

Here

reversed

List order should be descending (3, 2, 1) not ascending (1, 2, 3)

<ol>

Here

rows

Visible number of lines in a <textarea> element

<textarea>

Here

rowspan

Number of rows a table cell should span

<td>, <th>

Here

sandbox

Allows an extra set of restrictions for the content of an <iframe> element

<iframe>

Here

scope

Indicates whether a header cell is a header for a column, row or groups of these

<th>

Here

scoped

Indicates styles only apply to the element’s parent element and that element’s child elements

<style>

Here

selected

Indicates that an <option> element should be pre-selected when the page loads

<option>

Here

shape

Specifies shape of an <area> element

<area>

Here

size

Specifies width in characters for <input> or number of visible options for <select>

<input>, <select>

Here

sizes

Specifies size of linked resource

<img>, <link>, <source>

Here

span

Number of columns to span

<col>, <colgroup>

Here

spellcheck

Indicates whether element is to have its spelling and grammar checked

All

Here

src

URL of resource

Various

Here

srcdoc

HTML content of page to show in an <iframe>

<iframe>

Here

srclang

Language of track text data

<track>

Here. New in HTML 5, for kind = subtitles

srcset

URL of image to use in different situations

<img>, <source>

Here

start

Start value of an ordered list

<ol>

Here

step

Accepted number intervals for an <input> element

<input>

Here

style

Inline CSS style for an element

All

Here

tabindex

Tab order of an element

All

Here

target

Specifies where / how to open the linked document (or where to submit the form)

<a>, <area>, <base>, <form>

Here

title

Extra information about element

All

Here

translate

Whether content of an element should be translated

All

Here

type

Type of element

Various

Here

usemap

Specifies an image as a client-side image-map

<img>, <object>

Here

value

Value of element

Various

Here

width

Width of element

Various (not all)

Here

wrap

How text in a <textarea> element is to be wrapped when submitted in a form

<textarea>

Here

xmlns

XML namespace attribute applicable to the webpage (if it needs to conform to XHTML)

<html>

Here

 

Some standard attributes can apply to essentially all HTML elements. These are called global attributes.

 


NAVIGATION LINKS
Contents | Prev | Next | HTML Attributes


Desktop view | Switch to Mobile