Semantic code: put more in, get more out

IE7 is gaining market share and we can start to use more CSS3 selectors in our day to day code. Because of this, it’s worth a quick reminder that the more semantic we make our (X)HTML, the easier to implement the selectors will be.

For example, imagine the opportunities with the XFN microformat; by combining this with the partial attribute selector, you can add a little flourish to your pages.

Using these examples:

<li><a href="" rel="friend">Tom's
Site</a></li>
<li><a href="" rel="colleague met">Dick's
Site</a></li>
<li><a href="" rel="acquaintance met">Harry's
Site</a></li>

You could use the new selector to highlight anyone you’ve met:

a[rel*='met'] { color: red; }

To have your list like this:

Obviously this is only a very quick and basic example, but with a little imagination and some good semantic text you could really get the new selectors working for you.

These icons link to social bookmarking sites where readers can share and discover new web pages.
  • bodytext
  • del.icio.us
  • Reddit
  • Mixx
  • TwitThis
  • E-mail this story to a friend!
  • Print this article!
January 16th, 2007 by Peter Gasston in CSS3.info, Declarations, Tutorials. You can leave a response, or trackback from your own site.

6 Comments to “Semantic code: put more in, get more out”

  1. Devon Says:

    That’s making good use of XFN information. One could feasibly stuff a little icon of the person next to the link to their site using :after and a CSS background definition.

  2. Joost de Valk Says:

    Cool stuff Peter :)

  3. Arjan Eising Says:

    I use these for external links… for all hyperlinks a small background image is added, and with a[href^="#"] and a[href^="http://[domain-name]"] I delete these images. See my site for a demo :)

  4. Joost de Valk Says:

    Looking cool Arjan, looking cool :)

  5. Tim Wright Says:

    this seems very neat, but I’m not sure how usable it is quite yet. I manage a quasi-heavily trafficked site (about 3,000 visitors a month) and the stats are saying that IE7 is only used by 30% of IE users (15% overall). I’d estimate that about 55% of users could see the semantic code right now. I know some people who still haven’t gotten the auto update from Microsoft. Hopefully it’ll get out soon!

  6. 20 Very Useful CSS3 Tutorials | Speckyboy - Wordpress and Design Says:

    [...] 15.Semantic code: put more in, get more out with CSS3 [...]

Leave a Comment