Miscellaneous Properties

CSS 2.1 offers a few additional—and sometimes interesting— properties. They let you enhance your Web pages with special content and cursors, offer more control over how a page prints, and so on. (Unfortunately, browser understanding of these properties is spotty at best.)

content

Specifies text that appears either before or after an element. Use this property with the :after or :before pseudo-elements. You can add an opening quotation mark in front of quoted material and a closing quotation after the quote. This property isn't supported by Internet Explorer (not even IE 7 as of this writing), so its use is limited.

  • Values: Text inside of quotes "like this", the keywords normal, open-quote, close-quote, no-open-quote, no-close-quote. You can also use the value of an HTML attribute. (See "Revealing Links in Print" in Section 13.3.4 for an example.)

  • Examples: p.advert:before { content: "And now a word from our sponsor…"; }

    a:after { content: " (" attr(href) ") "; }

Note

Adding text in this way (like the opening and closing quote example) is called generated content. Read a simple explanation of the generated content phenomenon at http://www.westciv.com/style_master/academy/css_tutorial/advanced/generated_content.html. For a deeper explanation, visit http://www.w3.org/TR/CSS21/generate.html.

cursor

Lets you change the look of the mouse pointer when it moves over a particular element. You can make a question mark appear next to the cursor when someone mouses ...

Get CSS: The Missing Manual now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.