A Blog Not Limited

to web design, standards & semantics

CSS Selectors & Preferred “Styles”

Feb 20, 2012

Published in

Web Standards Sherpa

As I mentioned last summer, I'm honored to be a contributing writer Sherpa for Web Standards Sherpa. The site focuses on best practices and web standards, offering reviews of reader-submitted sites and applications.

My latest piece, What's Your CSS Style? is now available for your reading pleasure! In it, I review the reader-submitted klvn.org and discuss different selectors the author could use instead of (or in addition to) id and class selectors.

Selecting Selectors

The site I reviewed for What's Your CSS Style? featured what, I believe, is very common in our field: a ton of id selectors and a smattering of class selectors. This is certainly how I've written my CSS for most of my career. As I've encountered different types of projects and learned more about specificity, though, I'm starting to use other types of selectors.

Attribute selectors are my favorite these days, but I also encounter situations where sibling and child selectors are immensely helpful. Each — along with element, id and class selectors — have their own strengths and weaknesses. The key is understanding the options. Knowing different approaches to writing my CSS has made me a better developer simply because I have more knowledge to meet the need of different projects.

If you've always relied on a particular CSS selector, check out What's Your CSS Style? You might discover different selectors that could prove useful for your next project. Remember, knowledge is power!

HTML5 Cookbook

Interested in HTML5?
Get the Cookbook!

I was a contributing author for the newly-released HTML5 Cookbook, now available for sale on Amazon! Get yours now! (I hear chapters 1, 4 and 5 are particularly good.)

P.S. Don't forget my book Microformats Made Simple is still for sale!

Tags:

Share the Love

Your Two Cents:

* required fields

I will delete off-topic, inflammatory or anonymous comments. And, as much as I like compliments, if your comment is something along the lines of "great post, I'll pass it along," I'm gonna assume it is spam (especially if you don't provide a "real" name) and will delete it. So, add something useful to the conversation or don't comment at all.

If you don't like the picture I chose for your comment, quit whining and get a Gravatar account.

The Coolest Person I Know

Emily Lewis

Yeah, that would be me: .

I'm a freelance web designer of the standardista variety, which means I get excited about things like valid POSH, microformats and accessibility. I ply my trade from my one-person design studio in Albuquerque, New Mexico 87106 USA.

A Blog Not Limited is my personal blog where I pontificate about web design, web standards, semantics and whatever else strikes my fancy. Head on over to Emily Lewis Design if you'd like to see my work or, even better, hire me.

More

I Tweet, Therefore I Am

@e_to_the_m Thank you! Now I'm getting really excited :) (05/16/20128:19 pm)