user3527894
user3527894

Reputation: 285

Does h1 require header as parent?

Does a h1 tag always needs a header tag?

Like the following?

<main>
    <header>
        <h1>Title</h1>
    </header>
</main>

Or is this enough?

<main>
    <h1>Title</h1>
</main>

Upvotes: 0

Views: 453

Answers (3)

Daniel
Daniel

Reputation: 379

"Does h1 require header as parent?" NO, it doesn't

"A header element is intended to usually contain the section's heading (an h1–h6 element), but this is not required." source: web spec

see also h1 parents

Upvotes: 1

KhorneHoly
KhorneHoly

Reputation: 4766

Any html tag does not need a parent except the table and form tags.

As long as your <h1></h1> is within the <body></body> Tags everything works fine.

But: You shouldn't put any content in the tags, just imports and metadata!

So this is perfectly fine

<html>
    <body>
        <h1> Text </h1>
    </body>
</html>

Upvotes: 0

Meet Mehta
Meet Mehta

Reputation: 4909

Its not mandatory. But semantically, its good.

Check this link for more info.

Upvotes: 0

Related Questions