Re: [csswg-drafts] [css-selectors] Making the Tag-layer and ID-layer more powerful (#4690)

According to the [HTML living standard](https://html.spec.whatwg.org/multipage/dom.html#the-id-attribute), IDs must be unique on a page:

> When specified on HTML elements, the id attribute value must be unique amongst all the IDs in the element's tree and must contain at least one character.

I think there are very good reasons for that – IDs are used to select a single element on the page in various form/ARIA related uses – so I'm not sure that making IDs more flexible is an option here. and it does make sense to me that a unigue-ID direct selection would live at the highest level of specificity. The same is true for tag names living at the lowest level. The two use-cases that would be particularly helpful in development are:

1. The ability to create more flexible/targeted "defaults" that are easy to override. That could happen in a number of ways, including the proposed `!default` flag (#2272), custom origins (#4470), a new layer of specificity, or flexible (class-like) additions to the tag layer.
2. The ability to consider some repeatable "components" more specific than other repeatable "patterns" – like an "article-summary" card is more specific than the "card" pattern it uses, even though both repeat on a page.

While point 2 can be handled with multiple classes, it feels like we're missing out on the power that specificity layering would provide to ensure that specific components always override more general patterns, which always override broad defaults. 

I don't think we need a lot of layers – 3-5 seems about right – but our current 3 don't provide the flexibility required for the common use-cases.

-- 
GitHub Notification of comment by mirisuzanne
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/4690#issuecomment-577300897 using your GitHub account

Received on Wednesday, 22 January 2020 17:38:41 UTC