4 ms·
When running a large project, there is never just a single version of a ui element. For example, using media queries, different resolutions, zoom, and print. Or
by cng2 11y ago
When running a large project, there is never just a single version of a ui element. For example, using media queries, different resolutions, zoom, and print. Or if write your css in oocss with separation of concerns. Being less specific allows your css to be more manageable to change in many different situations. In complicated layouts, cascades are very non-friendly. Styling elements directly also has very high specificity.
- BinaryIdiot 11y ago> When running a large project, there is never just a single version of a ui element. For example, using media queries, different resolutions, zoom, and print. Not sure why you'd make such an absolute claim. When you say single version are you saying single html element or single CSS definition? If the former then I disagree (headers, footers, main containers of content, etc), if the latter then I don't understand how this would be the case. In HTML IDs are limited to one specific element but you can refer to it as many ways as you want in CSS which means you can use different media questions, handle resolutions, print, etc. So I'm not really sure I understand your point. > Being less specific allows your css to be more manageable to change in many different situations. In complicated layouts, cascades are very non-friendly. I've worked in a lot of really large projects and I'm not sure how little to no specificity could be more manageable due to side-effects. Ultimately you're going to need a mixture of specific and non-specific styling so arguing whether you should be more or less doesn't really make sense to me; just use the right level of specificity for the job at hand. If you have a page with specialized content you might want to be more specific there to not mess up another page. If you have a lot of re-usable components you probably want less.