DylRicho
DylRicho

Reputation: 915

Inside a <section> element; if <header> is used, is <footer> a requirement, or not?

Here is my code, at the moment:

<section id="one">
    <h2>Section Title</h2>
    <p>Lorem ipsum...</p>
    <p>Lorem ipsum...</p>
    <p>Lorem ipsum...</p>
</section>
<section id="two">
    <h2>Section Title</h2>
    <p>Lorem ipsum...</p>
    <p>Lorem ipsum...</p>
    <p>Lorem ipsum...</p>
</section>
<section id="three">
    <h2>Section Title</h2>
    <p>Lorem ipsum...</p>
    <p>Lorem ipsum...</p>
    <p>Lorem ipsum...</p>
</section>

I was contemplating using the <header> element to surround each section's <h2>, but would I then also have to use a <footer> element at the bottom of each section, as well? I have a feeling that the <footer> element of each section would more often than not be empty, unless footnotes were necessary, such as a source of information, or notes about the information provided in a paragraph, etc.

Is this part of the specification's rules, or am I purely basing this on the assumption that "if you have one, you should have the other"?

Upvotes: 1

Views: 257

Answers (3)

ROMANIA_engineer
ROMANIA_engineer

Reputation: 56626

No, you don't have to use both of them.

It's ok to use:

  • both of them
  • none of them
  • only header
  • only footer

It's similar to Microsoft Word. You can create a document that has only the title as header, only the page number as footer, both of them or none of them.

Upvotes: 2

amon
amon

Reputation: 57600

No, you do not have to use both a header and a footer if you use one. They are similar, but completely independent. The HTML5 specification adds no such restrictions.

Content model: Flow content, but with no header, footer, or main element descendants.

The header element represents introductory content for its nearest ancestor sectioning content or sectioning root element. A header typically contains a group of introductory or navigational aids.

<header> spec

Content model: Flow content, but with no header, footer, or main element descendants.

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.

When the footer element contains entire sections, they represent appendices, indexes, long colophons, verbose license agreements, and other such content.

<footer> spec

Upvotes: 4

CMPS
CMPS

Reputation: 7769

HTML tags are only used to describe your content, you don't have to use any of header/footer tags or you can use one of them, or both together, it's really up to you.

Edit: Also you can use them multiple times in a single html file

Upvotes: 0

Related Questions