Core HTML Attributes  Hot PDF Print E-mail
Tag it:
Delicious
Furl it!
Digg
NewsVine
Reddit
YahooMyWeb
Technorati
Articles Reviews HTML
Written by Phil Harrison   
Thursday, 08 March 2007
Article Index
Core HTML Attributes  Hot
Class Attribute
style Attribute
title Attribute
Core Attribute
Core Events

{mos_sb_discuss:21}

To accommodate new technologies such as style sheets and scripting languages, some important changes have been made to HTML and XHTML.


 
Since HTML 4.0, a set of four core attributes—id, class, style, and title—have been added to nearly all HTML and XHTML elements.

id Attribute

The id attribute is used to set a unique name for an element in a document. For example, using id with the paragraph tag, <p>,

            <p id="FirstParagraph">
            This is the first paragraph of text.
            </p>

names the bound element "FirstParagraph". Naming an element is useful for manipulating the enclosed contents with a style sheet or script.

For example, a style sheet rule such as

            <style type="text/css">
              #FirstParagraph {color: red;}
            </style>

could be put in the head of a document. This style rule says to make an element named "FirstParagraph" red. Naming is key to associating style or interactivity to particular elements. Of course, document authors must make sure objects are named uniquely, as having elements with the same id attribute value might cause significant bugs.



Last Updated ( Thursday, 05 July 2007 )
 
< Prev   Next >