I implemented website for my company. One of my focuses was using as semantic structure for the HTML as possible. So I used <section>
s and marked each section properly with heading tag (<h1>
-<h6>
), as the spec requires.
After we finished the website the marketing department of our company requested that for SEO purposes we:
- Change some of the
<h2>
tags to<h5>
- Change some of the
<h2>
-<h6>
tags to<p>
- Wrap subtitles (not titles) of some sections in heading tags
<h2>
-<h6>
I understand that from SEO perspective they want to precisely control over what texts/keywords are getting processesed/associated by search engine crawlers. But then those changes would violate the semantics of HTML. Let's go through those problems one by one:
Problems
Downgrade some heading levels
If I downgrade a heading of level 2 to 4 or 5, I'll effectively have some heading levels omitted. That violates the specification of how heading tags should be used:
Sections may contain headings of a rank equal to their section nesting level. Authors should use headings of the appropriate rank for the section’s nesting level.
Avoid skipping heading levels: always start from
<h1>
, next use<h2>
and so on.
Make headings use <p>
tags instead
As soon as we change the headings of some sections to not use <h1>
-<h6>
tags, but some other tags like <p>
, we are effectively having <section>
s without headings. The spec says:
Each section should be identified, typically by including a heading (h1-h6 element) as a child of the section element.
I could not only change the heading to <p>
but also remove the <section>
tags around that section. And while it wouldn't be a violation of the spec itself, it would downgrade the quality of our markup, because from the semantic point of view the current separation in <section>
s totally makes sense. Then each section requires a heading, and those texts are perfectly semantic headings for those sections.
Using heading tags for subtitles
For similar reasons they want some subtitles to be marked with <h1>
-<h6>
tags, because those texts are important to SEO. But then the spec says clearly:
h1–h6 elements must not be used to markup subheadings, subtitles, alternative titles and taglines unless intended to be the heading for a new section or subsection.
Question
Is there a way to solve their problems without affecting the semantics of the markup?
Maybe there is a way to stay with the current markup (<section>
and <h1>
-<h6>
untouched), but somehow tell search engine crawlers to use only some of the headings for their indexation? And to use subtitles for indexation without making them use <h1>
-<h6>
tags?