Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change guidance on sections and landmarks in HTML
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.
- Loading branch information