Allow me to explore the issue and my initial thoughts.
This does cause code management issues in larger sites where multiple teams work on areas of the style and markup of a site; however I feel this is best managed by code review and testing.
I question however if by simplifying specificity would reduce the issues at hand. In a big organisation when different teams are completely fragmented from another their CSS might be pushed higher up the list of compiled CSS breaking all their styles.
This wouldn’t be an issue if CSS had some inherent dependency tree to manage order however I feel this would quickly become a requirement if specificity was dropped.
For example:
//Team one CSS
.component-name strong {
color: blue;
}
...
//Team two css
strong {
color: red;
}
Currently the ordering allows for the following thought process to styling all strong tags:
- Add strong tag rule to CSS
- Check results for styles
- See that a library has set a more specific rule, either:
- Replace the rules
- Create more specific rules than the library
- Modify HTML to add extra anchors around the library code (New classes, id’s or wrapping html)
The appeal is the no specificity process:
- Append strong tag to end of CSS rules
However what I feel the first gives designers is an ability to add semantic meaning to the files rather than a fight for the most important CSS.
<div class="my-component">
<h1>Heading</h1>
<p>Text here</p>
</div>
<h1 class="super-important">Heading</h1>
.my-component h1 {
color: red;
}
h1.super-important {
color: purple;
}
h1 {
color: blue;
}
Rather than classifying the meaning of the h1 actually you are doing the reverse, meaning that developers won’t be promoted to add meaning. What the style based systems you mention give is adding in extra meaning to the HTML further classifying what the tags mean.
If anything I would drop !important as it causes a quick line of abuse to CSS files ending in a constant struggle to becoming the most important. Rather than actually fixing the specific case of HTML that you care about at the time, you rectify this by adding !important. When further changes are required there is no way to rectify the nest of !important that has been added to just add the styles that team needs. The same I feel applies to fighting to be the end of the CSS file.
That being said for utility classes like mentioned in the following article I agree important ‘could’ be the right solution here (However I prefer to ban it in CSS):
Deprecation issues
In terms of deprecation it is the same issue that plagues evolving JavaScript; Its not brilliant to evolve the language this way by deprecating features.
Worth reading: http://www.2ality.com/2014/12/one-javascript.html