written by
Peter Gasston
16 January 2007 in Declarations, News, Tutorials
16 Comments

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.



Peter Gasston

I work as creative developer for a design and branding agency in London. I’m an advocate of open web standards and creative commons, and live in hope that CSS3 will address some of the limitations of the language (and become a recommendation in my lifetime!). I blog on technical issues at Broken-Links.com, and my ambition is to one day stop agreeing to work on other people’s sites so I can concentrate on getting my own up to scratch.

Visit Authors Website  |  More Articles By Peter Gasston

This website uses IntenseDebate comments, but they are not currently loaded because either your browser doesn't support JavaScript, or they didn't load fast enough.

16 Responses 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. 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. 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. [...] 15.Semantic code: put more in, get more out with CSS3 [...]

  7. [...] Semantic code: put more in, get more out with CSS3 – A quick tutorial on how to use semantics so that you get more out of CSS3 selectors. [...]

  8. [...] Semantic Code: Put More In, Get More Out – A quick example of how CSS3 selectors, when used semantically, can add functionality to your site. [...]

  9. [...] Semantic Code: Put More In, Get More Out – A quick example of how CSS3 selectors, when used semantically, can add functionality to your site. [...]

  10. [...] Semantic Code: Put More In, Get More Out – 一个快速教程,涉及 CSS3 选择器使用和语义,以及为网站添加新功能的方法。 [...]

  11. [...] Semantic Code: Put More In, Get More Out – Ejemplo sobre como utilizar selectores CSS3 para añadir funcionalidades a un web site. [...]

  12. [...] Semantic Code: Put More In, Get More Out – A quick example of how CSS3 selectors, when used semantically, can add functionality to your site. [...]

  13. [...] Semantic code: put more in, get more out with CSS3 – A quick tutorial on how to use semantics so that you get more out of CSS3 selectors. [...]

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

  15. [...] 21. Semantic Code: Put More In Get More Out [...]

Leave a Reply

Leave a Reply

or chancel

Copyright 2006-2010 CSS3.info