Avoid qualifying elements in selectors (also known as "tag-qualifying").
Bad: qualifying elements
div#thing {
...
}
ul.list {
...
}
ul li.item {
...
}
a[href="place"] {
...
}Good
#thing {
...
}
.list {
...
}
ul .item {
...
}
[href="place"] {
...
}Since IDs are unique, they will not apply to multiple elements, so there is no good reason to qualify an ID selector with an element.
In most cases, qualifying a class or attribute selector with an element adds unnecessary or undesirable specificity. Often the element qualifier is already superfluous; and if it is not, you will probably be better off refactoring so that it can be removed.
Use the options to allow certain qualifying elements.
| Configuration Option | Description |
|---|---|
allow_element_with_attribute |
Allow elements to qualify attributes (default false) |
allow_element_with_class |
Allow elements to qualify classes (default false) |
allow_element_with_id |
Allow elements to qualify ids (default false) |