Is it possible to create more heading styles, like h7, h8, and so on?
Is it possible to have more than six different types of headings on a website?
Is it possible to create more heading styles, like h7, h8, and so on?
Is it possible to have more than six different types of headings on a website?
You can create any element you want on a page, but I think your question is whether it will be interpreted correctly by a user agent like a browser. Browsers will allow you to create, apply styles to, and access arbitrarily-created elements on the DOM regardless of whether they conform to the spec implied by your declared DOCTYPE
.
However, in general, it's best to avoid creating deeply nested structures; users find such hierarchies difficult to follow. In addition, as other answers linked in the comments have pointed out, there may be unintended consequences with page accessibility, SEO, or script compatibility. I have yet to find a use case that actually needs such deeply nested hierarchies, except when posting long legal documents as a single HTML page.
The HTML specification defines six headings. Browsers recognize six headings. If you start using <h7>
and so on, then you'll be using an invalid element.
If you find yourself needing an <h7>
then you should probably take a look at how you're structuring your site. Not every single title deserves a heading element.
<H7>
–
Mcmillian <p class="title">
would be a fine element for a title, especially if that title isn't the main concern of the page. The objective is to balance SEO and semantic markup. There are certainly pages that will contain only heading elements, and others that will have a big mix. Depends on what you're creating. –
Chink <h7 role="heading" aria-level=7">
provides the missing semantics for any h7 you may need. I suggest also styling it with display:block;
and a specific font size. This is entirely valid. –
Desireedesiri You can create any element you want on a page, but I think your question is whether it will be interpreted correctly by a user agent like a browser. Browsers will allow you to create, apply styles to, and access arbitrarily-created elements on the DOM regardless of whether they conform to the spec implied by your declared DOCTYPE
.
However, in general, it's best to avoid creating deeply nested structures; users find such hierarchies difficult to follow. In addition, as other answers linked in the comments have pointed out, there may be unintended consequences with page accessibility, SEO, or script compatibility. I have yet to find a use case that actually needs such deeply nested hierarchies, except when posting long legal documents as a single HTML page.
Generally speaking, you can create as many headings as you want, but they must be defined as classes. So if you are looking at making more than six headings for organization purposes do something like:
.h7{
color: #111111;
font-size: 16px;
text-transform: uppercase;
}
<p class="h7"> I'm an extra heading </p>
© 2022 - 2024 — McMap. All rights reserved.
<h2 class="subcat1"></h2>
, and<h2 class="subcat2"></h2>
then add the css classes likeh2.subcat1 {}
andh2.subcat2 {}
so that they are styled differently? – Tamaru<h#>
elements. However doing so will likely result in non or less accessible html. The html would also be questionably semantic due to its deviation from the standard. – Hesson