IMB
IMB

Reputation: 15889

Is <header> and <footer> required in an HTML5 document?

If you want to build a page with no "fancy" header and go plain like this:

<body><h1>title</h1>content</body>

Is it Ok?

Upvotes: 1

Views: 900

Answers (5)

JK.
JK.

Reputation: 5136

From the HTML5 specification:

Documents must consist of the following parts, in the given order:

  1. Optionally, a single "BOM" (U+FEFF) character.
  2. Any number of comments and space characters.
  3. A DOCTYPE.
  4. Any number of comments and space characters.
  5. The root element, in the form of an html element.
  6. Any number of comments and space characters.

As you can see, the problem is not the absence of the <header> and <footer> tags, but rather the root element and the DOCTYPE.

Upvotes: 0

kolin
kolin

Reputation: 2344

Yes, However you'll probably want to start learning the semantics and newer features of the HTML5 tags, as they are likely to become more and more commonplace now.

if you require backwards compatibility with older browsers, you can always use a HTML5Shim that uses javascript to provide structure to the new tags in older browsers. (Specifically IE6,7,8)

Upvotes: 0

Yinian Chin
Yinian Chin

Reputation: 98

No, semantic element should only be used where matches the semantic meaning in HTML5.

Upvotes: 0

Maurice
Maurice

Reputation: 27632

No this isn't valid. 1 Error, 4 warning(s): Element head is missing a required instance of child element title. The lack of a header or footer is fine though.

See the W3C Validator

This makes it valid:

<!DOCTYPE html><head><title>title</title></head><body><h1>title</h1>content</body>

Upvotes: 2

Brett Zamir
Brett Zamir

Reputation: 14345

Yes, HTML5 just formalizes existing behaviors, and adds optional new features.

Upvotes: 0

Related Questions