Oh, too much to list. Here are some of the most common cases:
Special numbering with counter() function along with counter-reset and counter-increment properties
Clean CSS cleanup with:
.foo:after { content: ""; display: block; clear: both; }
Display attributes, for example, for printing URLs for hyperlinks in a print style sheet
a[href]:after { content: ' (' attr(href) ') '; }
Add typographic ornaments that should not be in HTML, because they are presentation. For example, on my blog, I used it to decorate between posts or links to sidebars.
Add icons to hyperlinks, depending on where they indicate, for example
a[href^="http://twitter.com/"]:before { content: url('twitter-icon.png'); }
Adding a pointer to create a speech bubble for CSS only:
.bubble { position: relative; background: silver; } .bubble:after { content: ""; border:10px solid transparent; border-top-color:silver; position: absolute; bottom:-20px }
And many, many others.
Just be careful: if something is not presentation, it should probably be in your HTML. Users will not be able to select the generated CSS content, and screen programs will ignore it.
Lea verou
source share