Skip to content
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

replace current outline algorithm with one based on heading levels #7829

Merged
merged 45 commits into from
Jul 1, 2022

Conversation

stevefaulkner
Copy link
Contributor

@stevefaulkner stevefaulkner commented Apr 17, 2022

This PR is an attempt to bring the HTML spec in line with the decade+ old reality of non-implementation of the outline algorithm in User Agents and the continued presence of misleading content in the HTML spec relating to the outline algorithm.

Notes:

  • Removed outline algorithm section
  • Updated hgroup definition to reflect what it actually does/is
  • Updated numerous code examples to reflect Heading semantics as implemented in User agents
  • Updated/removed outline related cruft.

Relates to:

The CSS UA styles partial implementation has been left as is
https://html.spec.whatwg.org/multipage/rendering.html#sections-and-headings

Why partial? refer to https://codepen.io/stevef/pen/ZEvmNPg

  • At least two implementers are interested (and none opposed):
  • The issue at hand is no implementers have shown any interest in implementing for 10+ years
    • Chrome: …
    • Firefox: …
    • Safari: …

/dom.html ( diff )
/form-elements.html ( diff )
/grouping-content.html ( diff )
/index.html ( diff )
/indices.html ( diff )
/infrastructure.html ( diff )
/interaction.html ( diff )
/interactive-elements.html ( diff )
/links.html ( diff )
/sections.html ( diff )
/tables.html ( diff )

@JamieKnight
Copy link

+1. Within the BBC we have to specifically inform devs that the spec does not represent what is implemented or planned to be implemented. For us at least, this change would have positive real world impact.

@aarongustafson
Copy link
Contributor

This deeply saddens me, but it's the right thing to do.

@yatil
Copy link

yatil commented Apr 17, 2022

100% support for this. Maybe removing the outline algorithm makes it possible to find solutions for its use cases that can and will actually be implemented.

source Outdated Show resolved Hide resolved
@domenic
Copy link
Member

domenic commented Apr 18, 2022

As discussed in the thread you link to, we cannot remove the outline algorithm, as documents still have outlines. It instead needs to be based on heading levels, without sectioning complications.

@Alohci
Copy link

Alohci commented Apr 18, 2022

It's hard to see why it's better to keep an outline algorithm that's totally wrong with respect to the outline that documents actually have, than to simply remove it. There's certainly a case for adding back in an algorithm that describes the true outline accurately, but I don't see why the lack of the latter precludes the former.

used modified text of @annevk PR headings and sections section whatwg#3499
general clean up and closer alignment with @annevk PR whatwg#3499
@stevefaulkner
Copy link
Contributor Author

@domenic wrote

As discussed in the thread you link to, we cannot remove the outline algorithm, as documents still have outlines. It instead needs to be based on heading levels, without sectioning complications.

additional commits add simplified version of outline in @annevk's PR #3499

@stevefaulkner stevefaulkner changed the title removes outline algorithm replace current outline algorithm with one based on heading levels Apr 18, 2022
@domenic
Copy link
Member

domenic commented Apr 18, 2022

Great! Let us know when the conflicts with the main branch are resolved and then we can work on review.

@stevefaulkner
Copy link
Contributor Author

@domenic conflicts resolved

source Outdated Show resolved Hide resolved
@domenic
Copy link
Member

domenic commented Apr 19, 2022

Thanks. Could you also make sure the build passes?

@stevefaulkner
Copy link
Contributor Author

Thanks. Could you also make sure the build passes?

@sideshowbarker said he would take a look at that

@stevefaulkner
Copy link
Contributor Author

@domenic

Could you also make sure the build passes?

Thanks to @sideshowbarker build now passes

This error seems to have been introduced in f5def65,
whatwg#7475 — so it’s unclear why CI didn’t
catch it there.
Changing the spec source markup to use a p element in hgroup will need
to wait until after the spec change lands.
source Outdated Show resolved Hide resolved
source Outdated Show resolved Hide resolved
@SaekiTominaga
Copy link

Hello, I have a question.

What is the difference between a rank and a level in a heading?

<h1>-<h6> were called "level" in HTML4.

In HTML5 and HTML LS, they are called "rank".
However, the current outline algorithm also uses the term "level".

This time, the term "heading level" has been restored in the Headings and sections but "rank" is still used for heading elements.

@myakura
Copy link

myakura commented Apr 21, 2022

Hey @SaekiTominaga ,

IIRC rank is a concept to determine the level of the heading in a corresponding section. They are not the same thing.

Suppose there is a document with three headings:

<h1>h1</h1>

<h2>h2</h2>

<h2>h2</h2>

This would create the following outline:

  1. h1
    1. h2
    2. h2

Now, if you change the first h2 to h3, what would the outline be?

<h1>h1</h1>

<h3>h3</h3>

<h2>h2</h2>

It might be surprising but this would yield the same outline (except the text) per the current algorithm.

  1. h1
    1. h3
    2. h2

In this case, the rank in the heading of the first subsection is three, but the level of the heading is two.

tombye added a commit to alphagov/gds-way that referenced this pull request Jan 5, 2023
An attempt to rewite the guidance on use of
`<section>` tags to solve the problems in
#617.

I think the current guidance on use of `<section>`
tags is unclear because:
- the approach it recommends (using
  `aria-labelledby` to get their accessible name
  from the heading) creates a region landmark
  but the examples seem to show content that
  wouldn't benefit from being in one
- from looking through a lot of GDS repos, I
  couldn't find any code following this pattern
- it seems to clash with the current HTML5
  spec', which includes similar content
  examples but doesn't use of `aria-labelledby` to
  set an accessible name

The HTML5 spec' on `<section>`:

https://html.spec.whatwg.org/multipage/sections.html#the-section-element).

By 'region landmark', I mean an element with
`role="region"`.

I think a major cause of this confusion comes from
the current guidance having been written when the
HTML5 spec' still said that `<section>`s should be
used with `<h1>`s to create the document outline,
something never implemented in any browser:

https://www.tpgi.com/html5-document-outline/)

This has since been changed:

whatwg/html#7829

The spec' now seems to advocate using `<section>`s
to identify the scope of a heading. This arguably
makes the HTML easier to read but doesn't add any
new semantics so I'm wary of including guidance
for it here.

These changes instead intend to clear up the
existing guidance on use of `<section>` tags by
making it clear that this approach creates region
landmarks and that using them in other ways
(without assigning an accessible name) removes any
semantics they add.

Worth noting that these changes gratefully borrow
from
https://www.scottohara.me/blog/2018/03/03/landmarks.html

Final note: I expect a bit of discussion on this
pull request so intend to update the date of the
page these changes are in if and when they are
agreed to be the correct approach to the issue.
estelle pushed a commit to mdn/content that referenced this pull request Aug 15, 2023
In the current version of the spec, the `body` element belongs to no content category. The sectioning root concept has been removed entirely from the HTML spec in this PR: whatwg/html#7829
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
document conformance impacts documentation Used by documentation communities, such as MDN, to track changes that impact documentation normative change
Development

Successfully merging this pull request may close these issues.