Re: [csswg-drafts] [selectors] Adding a `:heading()` selector for headingoffset? (#10296)

@keithamus Would `:heading` (with or without parentheses) not be a pseudo-class, and should it then by definition not also have a class-level specificity? While I fully understand why we'd want an exception here, that introduces inconsistency in the language.

That just seems a little weird, and I think that's mentioned in the IRC log as a gotcha to teach: "Pseudo-classes behave like classes and have the same specificity, except `:heading` because it represents a list of standard heading elements." 

Let's say we had a special selector for form input elements like `:field` that mapped to `input, textarea, select` (and friends), that should then also behave as `:heading` to be consistent, right? The list of exceptions could then grow over time, potentially, and remembering exceptions in a language, whether programming like CSS or natural like English, can be fun, but is usually frustrating.

If it **has** to have an element-level specificity, then it would make more sense to be `::heading` with double-colons as that is a pseudo-element and already has a `0,0,1` specificity (unless I'm making that up), and there is precedent for functional notation, such as `::view-transition-group(*)`. Though I recognise the weirdness of using a pseudo-element selector for actual elements…

Anyways, sorry, this is nit-picky and perhaps a little off-topic, just seems an important point to keep in mind. While I know CSS has its historical list of mistakes, moving forward, being consistent (the letters "CSS" are in the word) seems like a good idea.

PS: sorry for the abundant use of the word "specificity". 🫠

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


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Thursday, 3 April 2025 19:01:05 UTC