Generated content in CSS3

Generated content via the content property has been available since CSS2. However this was only available using the :before or :after pseudo-classes. In CSS3 this support has been expanded to be useable on any element, without needing to use these pseudo-classes. Unfortunately this only works in Opera 9 (and above) at the time of writing.

I use this capability in my iTunes interface demo that I’m currently building to show off how powerful current and future web standards are for building application interfaces. This currently isn’t finished yet, and is very buggy (no min-width, missing features, no scrolling on the source list, content jumps, and no actual music support to name but a few). but you can take a sneak peak here. Due to MyOpera hot linking restrictions, you’ll need to press enter (or return) in the URL field to reload the page. This currently only works in Opera Kestrel due to missing standards support in other browsers, so download the latest weekly before trying it out.

The content property is used here so that the buttons and the playing column on the song list can contain their text labels. This is important for accessibility and if the page is styled differently and the design requires text instead of icons. The text is then set to empty using content: ""; for the relevant element. I’m sure there is a more cross-browser way of doing this, but the site is a demo so advanced properties and technologies were chosen to showcase them. To complete the buttons, and other parts of the interface, a SVG background was used. I plan to add border-radius to make the view buttons, and the head and footer of the interface have rounded corners. The screen needs to use SVG as the border uses a gradient to add the perception of depth. I suppose a border image can be used, but I like this approach. Other CSS3 properties used include overflow-y (The Genre, Artist and Album lists, and eventually the song list table), text-shadow (many of the headings), and CSS3 selectors (the song list and the button buttons). Other advanced technology used include SVG and HTML5 (getElementsByClassName).

  • Digg
  • del.icio.us
  • Facebook
  • Print this article!
  • StumbleUpon
  • TwitThis
  • E-mail this story to a friend!
December 13th, 2007 by David Storey in CSS3 Preview, CSS3.info. You can leave a response, or trackback from your own site.

5 Comments to “Generated content in CSS3”

  1. Dimitri Says:

    I wish I could see your iTunes web UI demo, but the link provided (http://files.myopera.com/dstorey/experiments/iTunes.html) returns a 403 error …

  2. David Storey Says:

    Just press enter/return in the url field and it will load. It is the hotllinking restrictions on MyOpera that is stopping me from linking to something in the files domain.

  3. webeame.net Says:

    Generación de contenido en css3…

    artículo acerca del tratamiento de la generación de contenido mediante css3…

  4. Martijn v/d Ven Says:

    David, you might consider rephrasing the part in the article were you tell them to refresh the page. Normal refreshing won’t work and has to be done as you described in the second comment.
    Might keep away people that don’t read the comments.

    I learned some great stuff from this, never really looked into content: before.

  5. David Storey Says:

    I’ll change it. Thanks for the input

Leave a Comment