-
Notifications
You must be signed in to change notification settings - Fork 174
Add heading selectors #3299
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add heading selectors #3299
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great to me, modulo the suggestion for the name, and missing period at the end of the description.
Co-authored-by: Patrick Brosset <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding this! I have a question in a line comment about the coverage of this feature and how to describe it.
I also have one general question: do we know anything about how these might be implemented across engines? If it seems very likely that they might land separately (e.g., that a vendor might implement :heading
but not :heading()
, it might be desirable to create independent features for each pseudo.
Otherwise, as one feature seems fine with me.
features/heading-selectors.yml
Outdated
@@ -0,0 +1,7 @@ | |||
name: Heading pseudo-classes | |||
description: The `:heading` and `:heading()` CSS pseudo-classes match headings of varying levels. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be nice to be more specific here. Something like:
description: The `:heading` and `:heading()` CSS pseudo-classes match headings of varying levels. | |
description: The `:heading` and `:heading()` CSS pseudo-classes match headings. The `:heading` pseudo-class matches any `<h1>` through `<h6>`. The `:heading()` pseudo matches… |
However, I don't really know how to fill in the rest. I read the spec and I read the MDN page (which seem to conflict greatly) and I don't get it. I suspect there's some history here, so giving a clue about what behavior we're talking about is pretty important.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this new description work?
It is implemented behind a flag in Firefox nightly right now. WebKit are supportive of this and its related feature (WebKit/standards-positions#523). So I am hopeful.
I am unsure if it'll land separately, it seems unlikely, however these two features represent the ones found in BCD.
The functional form underwent some minor changes. It used to be specced that you could use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some extremely minor suggestions on the new description, but I'm happy with this. Thank you, @keithamus!
@@ -0,0 +1,7 @@ | |||
name: Heading pseudo-classes | |||
description: The `:heading` and `:heading()` CSS pseudo-classes match headings of varying levels. The `:heading` pseudo-class matches any heading (`<h1>` through `<h6>`). The `:heading(<integer>#)` selector matches any of the given levels, for example `:heading(1, 2)` will match headings level 1 and 2. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tiny nits on the description (to avoid future tense, to avoid non-literal code, and align the example with other descriptions), but like this a lot. Thank you!
description: The `:heading` and `:heading()` CSS pseudo-classes match headings of varying levels. The `:heading` pseudo-class matches any heading (`<h1>` through `<h6>`). The `:heading(<integer>#)` selector matches any of the given levels, for example `:heading(1, 2)` will match headings level 1 and 2. | |
description: The `:heading` and `:heading()` CSS pseudo-classes match headings of varying levels. The `:heading` pseudo-class matches any heading (`<h1>` through `<h6>`). The `:heading()` selector matches any of the given levels. For example, `:heading(1, 2)` matches headings level 1 and 2. |
This adds the
:heading
and:heading()
pseudo classes as specified in https://drafts.csswg.org/selectors-5/#headings, and added in BCD 6.1.1: mdn/browser-compat-data#27517Refs #3218 which updated BCD to 6.1.1. Perhaps it didn't add these as they're not in a released browser yet?