Jo Smo Jo Smo - 11 days ago 4
HTML Question

Are H1 (HTML heading) allowed inside a table th or td tag?

TLDR: It's not allowed.

I found my answer here:


Permitted parent elements for h1: Any element that can contain flow elements,
hgroup.


Source: https://www.w3.org/TR/html-markup/h1.html and https://www.w3.org/TR/html-markup/th.html

Answer

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

Comments