Glubase - share your knowledge


All / Computers / Programming / HTML / XHTML

  • View Object

What common attributes are there in HTML?

Description

Common attributes 

 

Core Attributes

ID - Unique Identifier

An ID attribute is an unique identifier for an element used to create anchors or links to a specific element in the document. It can also be used to define a style with Cascading Style Sheets.

An id has to be unique and must start with a letter A-Z or a-z. After the first letter it is also permitted to use digits (0-9), "-", "_", ";" and ".".

Class

The class attribute is used to define a Cascading Style Sheet style for an element.

<div class=nice_style>
Some text.
</div>

This will make the text inside the DIV element to have the style "nice_style" that is defined in a Cascading Style Sheet.

A class can be defined multiple times.

Style

Defines an inline style definition.

Title

If defined a popup text will appear when you move the mouse over the object. Also works as "Alt" tag in Mozila for image

Examples:

<a href="mailto:leiken@passagen.se" title="Email to Glubase">leiken@passagen.se</a>
<a href="http://www.htmlplayground.com" title="Great place for learning HTML">HTMLPlayground</a>
<img src="image.jpg" title="A nice image." \>
 

Internationalization attributes

Lang

The lang attribute defines the language of the element's content. It could help search-engines to index a document by its language, and help speech engines to use language dependant pronunciation.

The attribute value should be defined according to this document.

Dir

The dir attribute defines the direction of the text inside the element. The following values are possible for this attribute:

  • ltr - Left-to-right
  • rtl - Right-to-left

Common Scripting Events

  • ONCLICK, when the mouse button is clicked on an element;
  • ONDBLCLICK, when the mouse button is double-clicked on an element;
  • ONMOUSEDOWN, when the mouse button is pressed over an element;
  • ONMOUSEUP, when the mouse button is released over an element;
  • ONMOUSEOVER, when the mouse is moved onto an element;
  • ONMOUSEMOVE, when the mouse is moved while over an element;
  • ONMOUSEOUT, when the mouse is moved away from an element;
  • ONKEYPRESS, when a key is pressed and released over an element;
  • ONKEYDOWN, when a key is pressed down over an element;
  • ONKEYUP, when a key is released over an element.