|
|
|
Cascading Style Sheets: an Interactive Tutorial
All About Selectorspart 3
advertisement advertisement There are two important pseudo-elements that are built into CSS capable web browsers. (There are also common pseudo-classes which you'll learn in the links chapter.) These two elements are :first-letter and :first-line. Notice that pseudo-elements are defined with a : instead of a . or # (this is because they have special meanings to a web browser). Here's a silly example for each: Imagine you want the first letter of each paragraph to be red, or the first-line of each paragraph to be green.
p:first-letter { color: red; } This example is kind of You can also apply these pseudo-elements to only certain classes of p, for example, if you make a p called seasonal, you could use this style:
p.seasonal:first-letter { color: red; }
<p>This paragraph is not<br> seasonal.</p> This paragraph is not However, this paragraph Ready to test your skills? Try making a paragraph selector with a pseudo-element first-line that is purple. Then make an ID selector with yellow text. Click here for an answer if you get stuck or you want to see how I did it.
|
|
Copyright © 2002 Dave Kristula. All Rights Reserved.