Skip to content

[css-selectors] Improve the usefulness of specificity of Tags & IDs #4690

Closed
@jensimmons

Description

@jensimmons

In an effort to modernize the CSS Cascade, and make it more suitable for projects with multiple Authors writing code over many years, @mirisuzanne is thinking about Origins (and how we might extend their power), and about the Specificity of Selectors.

For context:
The Selectors Level 4 defines three levels of sectors / three levels of specificity:

A selector’s specificity is calculated for a given element as follows:
count the number of ID selectors in the selector (= A)
count the number of class selectors, attributes selectors, and pseudo-classes in the selector (= B)
count the number of type selectors and pseudo-elements in the selector (= C)
ignore the universal selector

Miriam wrote on Twitter:

Specificity only has three layers, & only the middle (classes/attributes) layer is flexible enough for most use cases. IDs can only be used once per page, & tags need to be reused semantically. They're useful but very limited.

When everything is in a single layer, minute changes can have major impact. Everything relies on careful counting of selectors, and careful management of source order. Specificity should be more robust.

We need ways to create custom tag-layer – & reusable id-layer – selectors.

Let's talk about this. What would it look like to extend selectors so that:
• IDs can be used more than once per page
• The 'tag layer' has more customizability
• And / or other ways to empower Authors to use all three layers of specificity, instead of flattening their work into one layer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Closed as RetractedWhen the person who raised the issue thinks that there's no issue after all.selectors-5

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions