Web Design

(Nancy Kaufman) #1

135


CHAPTER

Advanced CSS 5


Are there rules for naming classes?
Yes. Class names must begin with a letter and can
contain only letters, underscore characters, dashes,
and numbers. Class names cannot contain spaces.
Class names are also case-sensitive, so you need to
be sure to use the same capitalization in the HTML
attribute as you do in the style sheet.

Can I use the same class more than once on
a page?
Yes. A single class can be applied to as many
elements on the page as you want. You do not even
need to apply it to the same element, so, for
example, you could apply a class to a span and a
paragraph in the same document without problem.

● When you view the page in
the browser, the tag to which
you added the class attribute
has the style applied.

3 Within the style sheet, type
a period and the class name
you used in Step 2.


4 Press.


5 Type {.


6 Type one or more style rules.


7 Press.


8 Type }.


6


5


8


3


TIPS

Free download pdf