HTML Attributes

Common HTML attributes are applicable to many or most HTML elements. These HTML attributes allow additional setting of style or other characteristics to the element. The HTML attributes outlined on this page are common in many HTML elements.


ID attribute

Used as a unique identifier for elements for style sheets. In HTML page:

<hr id="firsthr">

In style sheet:

hr#firsthr { color: #80b0ff; height: 15; width: 100% }


CLASS attribute

Used to specify similar attributes for dissimilar elements by putting them in the same class. In HTML page:

<p class="indent">

In style sheet:

.indent { margin-right: 5%; margin-left: 5%; color: #0000ff }


STYLE attribute

Used to set various element attributes to specific values. Example:

<h1 style="text-align: center">Common Attributes</h1>


TITLE attribute

A tool tip on visual browsers.





LANG attribute

An international attribute which is used to set the international language type.

lang="en"


DIR attribute

An international attribute which is used to set whether text is read left to right or right to left.

dir="ltr"


Reserved Attributes

There are also reserved attributes used with the following elements. Reserved attributes may be used to bind HTML documents to XML documents. Elements that use reserved attributes:

  • BUTTON
  • DIV
  • INPUT
  • OBJECT
  • SELECT
  • SPAN
  • TABLE
  • TEXTAREA

The reserved attributes are:

  • datasrc - Specifies the source of data using a URI.
  • datafld - Specifies a column or property name.
  • dataformatas - Specifies how the data is to be formatted with possible values being "html" or "text".