Search code examples
htmlcssheaderw3c

W3C Validation - Why is the <header> tag not accepted?


I am trying to validate my webpages using the W3C validator and it is returning an error whenever I use:

<header>Page Title</header>

The error message it is giving is:

element "header" undefined

I know I can use <h1> instead but was just curious why this isn't accepted?


Solution

  • The doctype you are using (XHTML 1.0 Strict) is incorrect, since the <header> tag is new to HTML 5.

    Replace:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    

    With:

    <!DOCTYPE html>
    

    Revalidate, and job's a good'un!