matt
matt

Reputation: 44293

Using <header> or <footer> tag twice?

Is it actually allowed to use the header tag twice? e.g. I have two important head-sections in my header.php where both could have header tag.

Upvotes: 106

Views: 103633

Answers (6)

Horia Dragomir
Horia Dragomir

Reputation: 2888

There's no penalty for using two header tags, but make sure it makes sense.

Upvotes: 4

Marcus Whybrow
Marcus Whybrow

Reputation: 19988

Yes you can use multiple header elements in your documents, by virtue of the w3c documentation:

A header element is intended to usually contain the section's heading (an h1–h6 element or an hgroup element), but this is not required. The header element can also be used to wrap a section's table of contents, a search form, or any relevant logos.

However ensure that it is semantically correct.

Upvotes: 17

iMarshal
iMarshal

Reputation: 76

In some situation, it is posible put two <header> in single <article>/<section> like this, so why not.

 <article>

      <!-- Feature Image on the LEFT -->
      <div class="position-left">
         ...featrue image...
        <header>
        ...H1 title ...  
        </header>
      </div>

      <!-- Content on the RIGHT with subtitle, date, etc -->
      <div class="position-right">
        <header>
          ..date, sub-title, etc...
        </header>
        ...content...
        <footer>..</footer>
      </div>

    </article>

Upvotes: 2

linusthe3rd
linusthe3rd

Reputation: 3566

Yes, but with a catch. The W3 documents state that the tags represent the header and footer areas of their nearest ancestor section. I would recommend having as many as your want, but only 1 of each for each "section" of your page, i.e. body, section etc.

From W3

A header element is intended to usually contain the section's heading (an h1–h6 element or an hgroup element), but this is not required. The header element can also be used to wrap a section's table of contents, a search form, or any relevant logos.

=========================

The footer element represents a footer for its nearest ancestor sectioning content or sectioning root element. A footer typically contains information about its section such as who wrote it, links to related documents, copyright data, and the like.

Here are links to their respective standard documentation: header and footer

Upvotes: 119

Floern
Floern

Reputation: 33904

The <header> is used to mark the header of e.g. articles in newspaper, so if you have multiple articles you can use multiple <header>.

It's like using multiple <h1>. It does only make sense in some special case.

Upvotes: 2

Scott M.
Scott M.

Reputation: 7347

You can put two <header> tags in your document, sure. Semantically, however, it is incorrect. Why not use one <header> tag and use a different tag inside it?

Upvotes: -4

Related Questions