Disallow adjoining classes
Pages 49
-
LoadingHome
-
LoadingAbout
-
LoadingAvoid un anchored hovers
-
LoadingBeware of box model size
-
LoadingBuild System
-
LoadingBuild System Integration
-
LoadingBulletproof font face
-
LoadingCommand line interface
-
LoadingContributing
-
LoadingDeveloper Guide
-
LoadingDisallow !important
-
LoadingDisallow @import
-
LoadingDisallow box sizing
-
LoadingDisallow duplicate properties
-
LoadingDisallow empty rules
-
LoadingDisallow IDs in selectors
-
LoadingDisallow negative text indent
-
LoadingDisallow non alphabetical
-
LoadingDisallow outline:none
-
LoadingDisallow overqualified elements
-
LoadingDisallow qualified headings
-
LoadingDisallow star hack
-
LoadingDisallow too many floats
-
LoadingDisallow underscore hack
-
LoadingDisallow units for zero values
-
LoadingDisallow universal selector
-
LoadingDon't use too many web fonts
-
LoadingIDE integration
-
LoadingNew Release
-
LoadingRequire all gradient definitions
-
LoadingRequire fallback colors
-
LoadingRequire shorthand properties
-
LoadingRequire use of known properties
-
LoadingRules
-
LoadingRules by ID
-
LoadingSource Code
-
LoadingUnit Tests
-
LoadingUsing in a Node.js Application
-
LoadingWorking with Rules
Clone this wiki locally
Adjoining classes, sometimes also called class chaining, look like .foo.bar. While technically allowed in CSS, these aren't handled properly by Internet Explorer 6 and earlier. IE will match the selector as if it were simply '.bar' which means your selector will match more frequently than you intend it to and create cross-browser bugs.
Generally, it's better to define styles based on single classes instead of based on multiple classes being present. Consider the following:
.foo {
font-weight: bold;
}
.bar {
padding: 10px;
}
.foo.bar {
color: red;
}The rule for selector .foo.bar can be rewritten as a new class:
.foo {
font-weight: bold;
}
.bar {
padding: 10px;
}
.baz {
color: red;
}That new class, baz, must now be added to the original HTML element. This is actually more maintainable because the .baz rule may now be reused whereas the .foo.bar rule could only be used in that one instance.
Rule Details
Rule ID: adjoining-classes
This rule is intended to flag uses of adjoining classes that will fail in Internet Explorer 6 and earlier.
The following patterns are considered warnings:
.foo.bar {
border: 1px solid black;
}
.first .abc.def {
color: red;
}The following patterns are considered okay and do not cause a warning:
/* space in between classes */
.foo .bar {
border: 1px solid black;
}Further Reading
``$ {webkit-tap-highlight-color: rgba(255,255,0,0);}