Rephrase single h1 as best practice#21948
Conversation
|
Preview URLs Flaws (1)URL:
External URLs (1)URL:
(this comment was updated 2022-10-30 17:02:17.748113) |
robinmetral
left a comment
There was a problem hiding this comment.
Feedback and edits by maintainers are more than welcome. I'm not a native English speaker, so feel free to improve phrasing to make it sound nicer 🙂
|
|
||
| These elements only include the [global attributes](/en-US/docs/Web/HTML/Global_attributes). | ||
|
|
||
| > **Note:** The `align` attribute is obsolete; don't use it. |
There was a problem hiding this comment.
Since this doesn't mention other obsolete global attributes such as color or border, I don't think it's necessary to mention align (which isn't even listed on the global attributes page).
| - Avoid using heading elements to resize text. Instead, use the {{glossary("CSS")}} {{cssxref("font-size")}} property. | ||
| - Avoid skipping heading levels: always start from `<h1>`, followed by `<h2>` and so on. | ||
| - Use only one `<h1>` per page or view. It should concisely describe the overall purpose of the content. | ||
| - Do not use heading elements to resize text. Instead, use the {{glossary("CSS")}} {{cssxref("font-size")}} property. |
There was a problem hiding this comment.
Avoid 👉 Do not, because doing this is a failure WCAG 2.1 SC 1.3.1 Info and relationships
A note: the other way around (using font-size for heading-like content, instead of heading elements) is a more obvious failure of the SC. I think that this scenario (using heading elements for non-heading-like content, instead of font-size) also fails the SC, but if it doesn't, it surely fails 2.4.6 Headings and labels). I haven't added any of this to the docs in doubt, would need an accessibility specialist to double-check
| - Avoid skipping heading levels: always start from `<h1>`, followed by `<h2>` and so on. | ||
| - Use only one `<h1>` per page or view. It should concisely describe the overall purpose of the content. | ||
| - Do not use heading elements to resize text. Instead, use the {{glossary("CSS")}} {{cssxref("font-size")}} property. | ||
| - Do not skip heading levels: always start from `<h1>`, followed by `<h2>` and so on. |
There was a problem hiding this comment.
Avoid 👉 Do not, because doing this is not conforming to the HTML standard:
Each heading following another heading lead in the outline must have a heading level that is less than, equal to, or 1 greater than lead's heading level.
| - Do not use heading elements to resize text. Instead, use the {{glossary("CSS")}} {{cssxref("font-size")}} property. | ||
| - Do not skip heading levels: always start from `<h1>`, followed by `<h2>` and so on. | ||
|
|
||
| ### Avoid using multiple `<h1>` elements on one page |
There was a problem hiding this comment.
Do not 👉 Avoid, because multiple h1 elements on a page is allowed by the standard.
I rephrased the paragraph and kept the mention of the outline algorithm (for now), since I expect that some authors might be asking themselves this question when visiting the page (because nested h1 elements are still found on a lot of tutorials/articles from before the outline algorithm was removed from the standard)
|
Thanks @robinmetral ! I think this really helps clear up the discussion and I'll add a note there 👍 |
|
Thanks @robinmetral It is simpler and easier to understand than the two previous versions. |
Description
See https://github.com/orgs/mdn/discussions/232 and specifically this comment.
Motivation
The docs for heading elements (h1–h6) is mixing up conforming to the HTML standard with following best practices. This can be misleading.
In a nutshell: while using multiple
h1elements on a page is allowed by the standard, it is not considered a best practice.Additional details
Line comments with extra details below.
This PR is a quick rephrasing of the problematic paragraph (to hopefully make reviewing easier).
However, I believe that this page would need some major rework (mostly around structure):
Related issues and pull requests
Relates to discussion #232