Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I agree that you could in a lot of cases get along without these classes. But sometimes you want e.g. an anchor acting as a button in a web application. Or you want a button element with browser styles. You could argue that this is also already an anti-pattern but it does way less harm then leaking inline styles into the namespace and it is still semantic. Also this was just an example (maybe not the best one) to illustrate my point that class names should be semantic and not express solely presentational attributes. The later is what styles are there for.

Especially in a javascript driven web application you may want to select all "buttons that are disabled". But you never want to select elements that "have a rounded border of 2 px and a grey background and italic font style and....". This takes class names ad absurdum.



<a href="" disabled="disabled" ...>

is selectable with

    [disabled] { }
or

    [disabled="disabled"] { } 
And

    [disabled]:not(.greyButtonStyle) { } 
does the last example if you classed that style, doesn't it? I've only done a little CSS, not very recent ... unless you're recruiting, then I'm an expert ;o).

I imagine though there are times when you want to class (some) button tags as .button.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: