Skip to content

Rephrase single h1 as best practice#21948

Merged
Rumyra merged 2 commits into
mdn:mainfrom
robinmetral:heading-docs-clarity
Oct 31, 2022
Merged

Rephrase single h1 as best practice#21948
Rumyra merged 2 commits into
mdn:mainfrom
robinmetral:heading-docs-clarity

Conversation

@robinmetral
Copy link
Copy Markdown
Contributor

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 h1 elements 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):

  • the "usage notes" bullet points lack context, are not commonly used on other pages, and duplicate information found later on the page (e.g. in the accessibility section)
  • in the accessibility section, "navigation" and "nesting" could be grouped under a single heading—they essentially cover the same requirement but from different angles
  • other concerns could be added to the accessibility section, such as (on top of my head):
    • don't use heading elements for non-heading content (e.g. for large text) (this is mentioned in "usage notes")
    • the counterpart of the above, don't use e.g. large text without a heading element for headings
    • headings essentially section content, and they should label sections accurately

Related issues and pull requests

Relates to discussion #232

@github-actions github-actions Bot added the Content:HTML Hypertext Markup Language docs label Oct 30, 2022
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Oct 30, 2022

Preview URLs

Flaws (1)

URL: /en-US/docs/Web/HTML/Element/Heading_Elements
Title: <h1>–<h6>: The HTML Section Heading elements
Flaw count: 1

  • macros:
    • wrong xref macro used (consider changing which macro you use)
External URLs (1)

URL: /en-US/docs/Web/HTML/Element/Heading_Elements
Title: <h1>–<h6>: The HTML Section Heading elements

(this comment was updated 2022-10-30 17:02:17.748113)

Copy link
Copy Markdown
Contributor Author

@robinmetral robinmetral left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

@robinmetral robinmetral marked this pull request as ready for review October 30, 2022 17:01
@robinmetral robinmetral requested a review from a team as a code owner October 30, 2022 17:01
@robinmetral robinmetral requested review from schalkneethling and removed request for a team October 30, 2022 17:01
@Rumyra Rumyra merged commit 7bbc6a9 into mdn:main Oct 31, 2022
@Rumyra
Copy link
Copy Markdown
Collaborator

Rumyra commented Oct 31, 2022

Thanks @robinmetral ! I think this really helps clear up the discussion and I'll add a note there 👍

@debiru
Copy link
Copy Markdown
Contributor

debiru commented Nov 1, 2022

Thanks @robinmetral

It is simpler and easier to understand than the two previous versions.
I have translated it into Japanese as soon as possible.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Nov 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Content:HTML Hypertext Markup Language docs

3 participants