HTML5, CSS3, and JavaScript Fourth Edition

(Ben Green) #1

CHAPTER 11. HOVER AND PSEUDO CLASSES 117


to mouse up). It can create a nice and immediate sense of feedback to the
user, letting them know that you know they have clicked on a link.


:active { background-color: yellow; }


:active- change the style of an a-link element when we are actively clicking
on it.


11.2 Text Styling


We can style bits of unmarked text depending on whether it is the first letter
or part of the first line of the paragraph.


p:first-letter { font-size: 200%; }
p:first-line { font-weight: bold; }


Technically, these are called pseudo elements (as distinguished from pseudo
classes). I don’t see the big distinction, but some people do. And technically
they are introduced by two colons instead of one, like this.


p::first-letter { font-size: 200%; }
p::first-line { font-weight: bold; }


Exam Question 208(p.348): What is the pseudo-element for the first
character of something?
Required Answer:::first-letter


Exam Question 209(p.348):What is the pseudo-element for the first row
of text of something?
Required Answer:::first-line


As should be obvious, this styling will cause the first line of each paragraph
to be bold, even without anytags. And the first letter of the paragraph
will be twice as big as normal, which is a fun effect I have seen used in books.


Exam Question 210(p.348): What is the prefix for pseudo-element?
Required Answer:::


The prefix symbol for pseudo-element is::(double colon).

Free download pdf