|
Our Hosting Partners:
65% off at FatCow! iPage Hosting 1&1 Hosting $6.99/mo Free Domain Name If you Order Today! Our CSS Style topics:CSS Code Tutorial Chapters:
visit our other tutorials:
|
Cascading Style Sheets: an Interactive Tutorial
All About Selectors for StylesChapter 3 part 3 (of 3)
PSEUDO-ELEMENTS
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). Download HTML and CSS Web Design Basics Right Now! Or Search for "Web Design Basics" in AppStore!
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.
advertisement
Our Hosting Partners:
The Original $3.15/mo. FatCow Plan - Unlimited Disk Space, Unlimited Transfer, Unlimited E-mails & Site building tools. iPage Hosting 1&1 Hosting $6.99/mo Free Domain Name If you Order Today! |
Copyright © Dave Kristula. All Rights reserved.