Sunday, September 18, 2011

Attributes

Most of the attributes of an element are name-value pairs, separated by "=" and written within the start tag of an element after the element's name. The value may be enclosed in single or double quotes, although values consisting of certain characters can be left unquoted in HTML (but not XHTML). Leaving attribute values unquoted is considered unsafe. In contrast with name-value pair attributes, there are some attributes that affect the element simply by their presence in the start tag of the element, like the ismap attribute for the img element.
There are several common attributes that may appear in many elements:

  • The id attribute provides a document-wide unique identifier for an element. This is used to identify the element so that stylesheets can alter its presentational properties, and scripts may alter, animate or delete its contents or presentation. Appended to the URL of the page, it provides a globally unique identifier for the element, typically a sub-section of the page. For example, the ID "Attributes" in http://en.wikipedia.org/wiki/HTML#Attributes
  • The class attribute provides a way of classifying similar elements. This can be used for semantic or presentation purposes. For example, an HTML document might semantically use the designation class="notation" to indicate that all elements with this class value are subordinate to the main text of the document. In presentation, such elements might be gathered together and presented as footnotes on a page instead of appearing in the place where they occur in the HTML source. Class attributes are used semantically in microformats. Multiple class values may be specified; for example class="notation important" puts the element into both the 'notation' and the 'important' classes.
  • An author may use the style attribute to assign presentational properties to a particular element. It is considered better practice to use an element's id or class attributes to select the element from within a stylesheet, though sometimes this can be too cumbersome for a simple, specific, or ad hoc styling.
  • The title attribute is used to attach subtextual explanation to an element. In most browsers this attribute is displayed as a tooltip.
  • The lang attribute identifies the natural language of the element's contents, which may be different from that of the rest of the document. For example, in an English-language document:   
<p>Oh well, <span lang="fr">c'est la vie</span>, as they say in France.</p>

The abbreviation element, abbr, can be used to demonstrate some of these attributes:

<abbr id="anId" class="jargon" style="color:purple;" 
title="Hypertext Markup Language">HTML</abbr>

This example displays as HTML; in most browsers, pointing the cursor at the abbreviation should display the title text "Hypertext Markup Language."

Most elements also take the language-related attribute dir to specify text direction, such as with "rtl" for right-to-left text in, for example, Arabic, Persian or Hebrew

Related Post

Komentar :

ada 0 comments ke “Attributes”

Post a Comment

FOLLOWERS

LIKE PLEASE

ads
CO.CC:Free Domain

ENTRI POPULER

free counters
PASANG IKLAN !!! Bagi rekan-rekan yang ingin mempromosikan sebuah produk dagangannya atau usahanya silahkan hubungi melalui
E-Mail ir_aditya@ymail.com /Telp. 085718404907
Ayo buruan ini harga promo sampai 17 Agustus 2012
Free Website Hosting ads ads ads ads ads
 

© 2009 Fresh Template. Powered by Blogger.

Fresh Template by kangaditya.