42
CHAPTER 3. CSS
of conflicts, the most specific specification is used, e.g. p.toocool style will be
used in a paragraph with the toocool attribute. Likewise, the bland style will
be used in a bland paragraph. Finally, note that the style names can be any
name you wish to create. The names must begin with a letter and contain only
letters, digits, and dashes ( ).
The style definitions can go into the head element of the html tag for exam
ple, the following code defines a toocool class and uses it for a heading and a
sentence:
test
.toocool
{background:black; color:red}
p
{background:white; color:red}
p.toocoll {background:black; color:white}
.bland
{background:white; color:black}
>
Cool page
This is neat and
this is too cool!
This is a normal paragraph with CSS style
This uses the special toocool paragraph
style and
This is a bland paragraph
The style file has the form:
NAME {STYLE SPEC}
NAME {STYLE SPEC}
NAME {STYLE SPEC}
where the STYLE SPEC is a specification of the style as we have seen for inline
CSS.
The media specification in the style tag allows you to specify different
styles for different media. Current media include screen for usual webpage
browsing, print for printing, and aural for screen readers.
You can also store the CSS in a separate file and link it to the current page
using a link tag in the head:
test