Web Design

(Nancy Kaufman) #1

141


CHAPTER

Advanced CSS 5


To which elements can I apply pseudo-elements?
In theory, any element can take a pseudo-element.
In practice, however, browsers tend to ignore the
pseudo-element when it is not applied to text-based
elements, such as paragraphs, lists, and table cells.

Can I apply pseudo-elements with ID or class
selectors?
Yes. You simply replace the element name before
the colon with the class or ID name. Therefore,
.intro:first-line would style the first line of
any element with the intro class, and
#mainArticle:first-line would apply the
style to an element with a mainArticle ID.

● When you view the page in a
browser, the style is applied
based on the pseudo-
element. In this example,
the first line of text in the
paragraphs is formatted
in bold.

5 Press.


6 Type {.


7 Type the styles you want
to use.


8 Press.


9 Type }.


7


6


9


TIPS

Free download pdf