An ID is identical, in many ways, to the NAME
attribute in HTML; in fact, in future browsers, ID will completely replace the NAME
attribute! An ID is used to identify an element for manipulation in a scripting language, such as JavaScript.
An ID is declared in CSS much like a class, only using the pound (#
) sign rather than a dot (.
) character. Unlike a CLASS, an ID may NOT be prefaced by a selector or contextual selector; it must stand alone in the CSS code.
Example:
#banana { color:yellow; }
In HTML, then, I would assign an ID to an HTML tag using the ID
attribute.
Example:
<p id="banana">This is the banana paragraph.</p>
An ID, as you might have guessed from its similarity to the NAME
attribute, may ONLY be applied to ONE element on a given HTML page.
IDs are mostly used with CSS-P, for positioning elements absolutely on an HTML page, and with Dynamic HTML. You will probably NOT need to use IDs for anything right now.
Copyright © 2001 Michael Masumoto. All Rights Reserved.