HTML5 Zone is brought to you in partnership with:

Mitch Pronschinske is a Senior Content Analyst at DZone. That means he writes and searches for the finest developer content in the land so that you don't have to. He often eats peanut butter and bananas, likes to make his own ringtones, enjoys card and board games, and is married to an underwear model. Mitch is a DZone Zone Leader and has posted 2573 posts at DZone. You can read more from them at their website. View Full User Profile

An introduction to CSS pseudo-element hacks

10.17.2011
| 2882 views |
  • submit to reddit
CSS is a versatile style language that is most frequently used to control the look and formatting of an HTML document based on information in the document tree. But there are some common publishing effects – such as formatting the first line of a paragraph – that would not be possible if you were only able to style elements based on this information. Fortunately, CSS has pseudo-elements and pseudo-classes.

That's the intro to Nicolas Gallagher's introduction to CSS pseudo-element hacks.  Of course, not everyone thinks that CSS hacks are a good idea, but I'd suggest that any web developer who is interested in learning CSS pseudo-elements that are part of CSS 2.1, namely, how to use :first-letter, :first-line, :before, and :after – and how the :before and :after pseudo-elements can be exploited to create some interesting effects; should take a good look at this comprehensive tutorial.  It includes sections on:

  • Browser support for pseudo-elements

  • Alternative ways to use pseudo-elements

  • CSS speech bubbles

  • CSS ‘ribbons’

  • CSS folded corners

  • Pseudo background-crop

  • and Pseudo background-position


"Some new applications will emerge, and existing ones will fade away as browser implementation of ‘CSS3 modules’ continues to improve," Gallagher says, but for now these are still relevant.
References
Reference: http://nicolasgallagher.com/an-introduction-to-css-pseudo-element-hacks/