id Attribute
Description
The id
attribute assigns a unique identifier to an element.
These identifiers are commonly used to apply styles to an element or to select an element with JavaScript.
Example
<!DOCTYPE HTML>
<html>
<style>
#w3clink {<!-- w w w . ja v a 2s . c o m-->
background:grey;
color:white;
padding:5px;
border:thin solid black;
}
</style>
<body>
<a href="http://java2s.com">web site</a>
<br/>
<a id="w3clink" href="http://w3c.org">W3C web site</a>
</body>
</html>
To apply a style based on an id
attribute value,
you prefix id with the #
character when defining the style.