Skip to content

Shady styling increases selector specificity #1279

Closed
@ssorallen

Description

When inspecting an element's styles to alter externally, the selectors are less specific than they will actually be in the browser. It's not obvious this will happen, and it makes styles more difficult to override. In core-header-panel for example:

Specificity 110:

:host([mode=cover]) #mainContainer { ... }

becomes specificity 121:

core-header-panel[mode=cover] #mainContainer[style-scope=core-header-panel] { ... }

When looking at the file it seems reasonable to override the first style with a selector of matching specificity like:

Specificity 111:

core-header-panel[mode=cover]::shadow #mainContainer { ... }

but that will not override the generated selector regardless of placement of the styles because the generated selector is more specific. The dev has to add unexpected specificity to his or her selector in order to override the generated one.

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions