Jo Smo Jo Smo - 5 months ago 8x
HTML Question

H1, H2, H3, H4, H5, H6 inside table TH tags? - HTML

Can i use

H1, H2, H3, H4, H5, H6
inside the
table TH
tags? - HTML

I tryed to validate with the w3 validator, but it doesn't validate. I get this:

The element h4 must not appear as a descendant of the th element.

I use HTML5, so i think that the best idea is to use
to make a table and then put the
tags in it. Or is this a bad idea too? Because then it looks something like this:

<h4>first title</h4> <h4>second title</h4> <h4>third title</h4>
<p>first parahraph</p> <p>second parahraph</p> <p>third parahraph</p>

And i don't know how this looks, 3 heading tags that close, without any text or paragraphs between that.


The HTML living standard explicity forbids this. The th element content model is as follows (emphasis added):

Flow content, but with no header, footer, sectioning content, or heading content descendants.

"Heading content" refers to the h1, h2 etc. elements, as well as the hgroup element:

Heading content defines the header of a section (whether explicitly marked up using sectioning content elements, or implied by the heading content itself).

h1 h2 h3 h4 h5 h6 hgroup