As I mentioned last summer, I'm honored to be a contributing
writer 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)
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,
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!