HTML and CSS Reference
In-Depth Information
FORMAT
#IDselector { declaration ; }
EXAMPLE
#menu1 { font-family: arial;
font-size: big;
color: blue; }
To apply an ID to an HTML tag, use the id attribute. The attribute will be assigned the
same name given to the ID selector; so, to apply an ID selector to a <p> tag, you would
stipulate <p id=name> where name is the name of the ID selector (see Example 14.17).
The id Attribute. When JavaScript enters the picture, the id attribute is used to iden-
tify each element as a unique object so that it can be manipulated in a JavaScript pro-
gram. The id should be unique for an element and not used more than once on a page.
If you need to use the style more than once for multiple elements, it would be better to
use the class selector instead. The ID selector can be used with a class selector of the
same name, as #big, .big { } .
EXAMPLE 14.17
<html>
<head><title>ID's</title>
1
<style type="text/css">
2
p { font-family:arial,sans-serif,helvetica;
font-style:bold;
font-size:18
}
3
#block { /* The ID selector */
color: red;
text-decoration:underline;
}
</style>
</head>
<body >
4 <p> When making my point, I will get quite red and underline
what I say!!</p>
5 <p id="block"> This text is red and underlined!!</P>
6 <p>and now I am somewhat appeased.
</body>
</html>
EXPLANATION
1
This is the start of a style sheet; it is placed between the <head></head> tags in the
document.
Continues
 
Search WWH ::




Custom Search