Skip to content

Remove UA style for h1-h6 in section (et. al.) and hgroup #7867

@zcorpan

Description

@zcorpan
Member

If/when #7829 is merged, the following UA style doesn't make sense. Can it be removed?

In the following CSS block, x is shorthand for the following selector: :is(article, aside, nav, section)

@namespace url(http://www.w3.org/1999/xhtml);

x h1 { margin-block-start: 0.83em; margin-block-end: 0.83em; font-size: 1.50em; }
x x h1 { margin-block-start: 1.00em; margin-block-end: 1.00em; font-size: 1.17em; }
x x x h1 { margin-block-start: 1.33em; margin-block-end: 1.33em; font-size: 1.00em; }
x x x x h1 { margin-block-start: 1.67em; margin-block-end: 1.67em; font-size: 0.83em; }
x x x x x h1 { margin-block-start: 2.33em; margin-block-end: 2.33em; font-size: 0.67em; }

x hgroup > h1 ~ h2 { margin-block-start: 1.00em; margin-block-end: 1.00em; font-size: 1.17em; }
x x hgroup > h1 ~ h2 { margin-block-start: 1.33em; margin-block-end: 1.33em; font-size: 1.00em; }
x x x hgroup > h1 ~ h2 { margin-block-start: 1.67em; margin-block-end: 1.67em; font-size: 0.83em; }
x x x x hgroup > h1 ~ h2 { margin-block-start: 2.33em; margin-block-end: 2.33em; font-size: 0.67em; }

x hgroup > h1 ~ h3 { margin-block-start: 1.33em; margin-block-end: 1.33em; font-size: 1.00em; }
x x hgroup > h1 ~ h3 { margin-block-start: 1.67em; margin-block-end: 1.67em; font-size: 0.83em; }
x x x hgroup > h1 ~ h3 { margin-block-start: 2.33em; margin-block-end: 2.33em; font-size: 0.67em; }

x hgroup > h1 ~ h4 { margin-block-start: 1.67em; margin-block-end: 1.67em; font-size: 0.83em; }
x x hgroup > h1 ~ h4 { margin-block-start: 2.33em; margin-block-end: 2.33em; font-size: 0.67em; }

x hgroup > h1 ~ h5 { margin-block-start: 2.33em; margin-block-end: 2.33em; font-size: 0.67em; }> 

https://html.spec.whatwg.org/multipage/rendering.html#sections-and-headings

Activity

domenic

domenic commented on Apr 28, 2022

@domenic
Member

Seems extremely unlikely.

annevk

annevk commented on May 3, 2022

@annevk
Member

Unlikely, but also quite unfortunate. I'd certainly support someone investigating this.

cc @whatwg/css

zcorpan

zcorpan commented on May 3, 2022

@zcorpan
MemberAuthor

The hgroup special styling could probably be removed since hgroup usage is a lot lower than the sectioning elements, and multiple headings in hgroup is non-conforming with #7829. And it's not implemented in any of Gecko, Chromium, WebKit!

Demo:
https://h1-ua-style.glitch.me/

Maybe it's possible to remove the other rules also; author CSS to set the font-size was needed to get consistent style in older browsers (in particular IE8). But this would need some research.

added a commit that references this issue on May 3, 2022
added a commit that references this issue on May 3, 2022
zcorpan

zcorpan commented on May 3, 2022

@zcorpan
MemberAuthor

h2-h5 in hgroup styling removed in #7886

added
agenda+To be discussed at a triage meeting
on May 3, 2022
zcorpan

zcorpan commented on May 3, 2022

@zcorpan
MemberAuthor

Adding agenda+ to check interest in adding a use counter for h1 with a sectioning element ancestor and no Author Origin style for font-size.

zcorpan

zcorpan commented on May 5, 2022

@zcorpan
MemberAuthor

We didn't get to this issue in the triage meeting today. Optimistically tagging @mfreed7 :)

63 remaining items

zcorpan

zcorpan commented on May 9, 2025

@zcorpan
MemberAuthor

I think the Chromium use counter has some amount of false positives because some sites have a flash of unstyled content (due to forcing layout or loading CSS async). See GoogleChrome/lighthouse#16404 (comment)

mfreed7

mfreed7 commented on May 9, 2025

@mfreed7
Collaborator

I think the Chromium use counter has some amount of false positives because some sites have a flash of unstyled content (due to forcing layout or loading CSS async). See GoogleChrome/lighthouse#16404 (comment)

Thanks for the link - I hadn't seen that bug report. (Makes me happy that the deprecation->Lighthouse->developer path is working!) At first I was thinking about how to avoid providing the deprecation message in that FOUC case, but I think maybe the counter/message is working as expected. I agree that it likely means the counter is likely a bit higher than it should be, but maybe it's ok given the state of this removal?

zcorpan

zcorpan commented on May 12, 2025

@zcorpan
MemberAuthor

I agree that it likely means the counter is likely a bit higher than it should be, but maybe it's ok given the state of this removal?

Yeah, no need to tweak the use counter IMO.

zcorpan

zcorpan commented on May 13, 2025

@zcorpan
MemberAuthor

Status update: still no broken site reports. Rollout is now active for 10% of release.

zcorpan

zcorpan commented on May 20, 2025

@zcorpan
MemberAuthor

Status update: still no reported regressions. I'm calling success on the rollout experiment. When 139 is released, I plan to increase the rollout on desktop to 100%. The pref flip will ride the trains for 140.

zcorpan

zcorpan commented on Jun 24, 2025

@zcorpan
MemberAuthor

Firefox 140 shipped today!

mfreed7

mfreed7 commented on Jun 27, 2025

@mfreed7
Collaborator

Firefox 140 shipped today!

Congrats! I'm sure you will, but just to be sure: can you please check in one more time when you think this change "stuck" in Firefox and you're sure it'll stay landed? At that point, I'll request shipment of the change in Blink.

AtkinsSJ

AtkinsSJ commented on Jul 9, 2025

@AtkinsSJ
Contributor

Firefox updated the WPT for this ( web-platform-tests/wpt#53658 ) claiming that this part of the UA stylesheet has been removed when it hasn't? cc: @emilio

emilio

emilio commented on Jul 9, 2025

@emilio
Contributor

Ah, you're right, sorry! I think I glanced at https://html.spec.whatwg.org/multipage/rendering.html#sections-and-headings and didn't see :is(..) and assumed it was gone (but it's using x instead, of course :'/).

So I guess at this point we can revert my change (happy to do that) or merge #11102. Both Firefox 139 and 140 have shipped with it at 100% with no regressions reported.

@domenic / @annevk / @mfreed7: Slight preference to merge #11102, but let me know either way?

domenic

domenic commented on Jul 10, 2025

@domenic
Member

I think per discussions at #11102 (comment) we've reached the threshold for merging the spec PR, so let's do that within the next couple of days.

mfreed7

mfreed7 commented on Jul 10, 2025

@mfreed7
Collaborator

@domenic / @annevk / @mfreed7: Slight preference to merge #11102, but let me know either way?

Definitely let's merge #11102 - it feels like this change has sailed. (Or has ridden the trains?) I'll get started with the process to disable on Chromium.

added a commit that references this issue on Jul 19, 2025
1af7430
mfreed7

mfreed7 commented on Jul 23, 2025

@mfreed7
Collaborator

Definitely let's merge #11102 - it feels like this change has sailed. (Or has ridden the trains?) I'll get started with the process to disable on Chromium.

The special rules will be disabled in Chromium as of M140.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @past@pepelsbey@AtkinsSJ@zcorpan@domenic

      Issue actions

        Remove UA style for h1-h6 in section (et. al.) and hgroup · Issue #7867 · whatwg/html