Yesterday I chimed in on an exchange on Twitter about the constant CSS argument of whether or not to use IDs as selectors (I’m in the not camp, BTW):
(Slightly controversial) new blog post: Hashed classes in CSS bit.ly/15dcE0t
— Harry Roberts (@csswizardry) May 30, 2013
@csswizardry I disagree with this. 🙂 use an id with an attribute selector, instead.
— Snook (@snookca) May 30, 2013
@snookca @csswizardry I’ve been using a ‘the’ prefix. #header →.the-header. I only use it for macro layout sections.
— Ryan Frederick (@ry5n) May 30, 2013
@ry5n @snookca Nice! Pretty common-sense prefix right there; certainly less confusing than hashes, too!
— Harry Roberts (@csswizardry) May 30, 2013
@csswizardry @ry5n @snookca my approach is using ARIA landmark roles as attribute selectors. unique, yet same specificity as classes.
— Tracy Rotton (@taupecat) May 30, 2013
@taupecat @csswizardry @snookca Landmark roles aren’t all intended to be unique, though. Banner should be, but multiple <nav>s are common.
— Ryan Frederick (@ry5n) May 30, 2013
@ry5n @taupecat @snookca Also, ARIA roles are not style hooks…
— Harry Roberts (@csswizardry) May 30, 2013
But still, I felt that my position had some validity. I don’t remember if I had come up with the thought myself and then learned that others were doing it that way too, or if it was something I read somewhere and then started doing it myself. Either way, I didn’t feel like I was in the wrong.
Then I came across this post last night, from 2011, by Jeremy Keith (author of HTML5 for Web Designers).
So yeah, I feel a little vindicated on this. And this was kinda important to me at the moment because just the night before I had written a sidebar in my book about how using ARIA landmark roles as CSS selectors is a better idea than using IDs.
(Which reminds me, I need to post another book update here. Maybe in a couple of weeks when there might actually be news.)
But anyway, I didn’t want to give wrong advice to my readers, so the fact that Trusted Internet Celebrityâ„¢ Jeremy Keith was advocating the same approach I was using justified my position.
The sidebar stays in.