A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/CSSLint/csslint/wiki/Disallow-adjoining-classes below:

Disallow adjoining classes · CSSLint/csslint Wiki · GitHub

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 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;
}

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4