O'Reilly logo

Learning PHP, MySQL, JavaScript, and CSS, 2nd Edition by Robin Nixon

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Pseudoelements

Pseudoelements are a means of adding content rather than style to an element. They are enabled by placing a colon after an element type specifier, followed by a pseudoelement. For example, to place some text before an element that uses the class offer, you could use a rule such as this:

.offer:before { content='Special Offer! '; }

Now any element using the class offer will have the string supplied to the content property displayed before it. Likewise, you can use the :after pseudoelement to place items after all links (for example), as with the following, which will follow all links on a page with the link.gif image:

a:after { url(link.gif); }

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required