LeonH
LeonH

Reputation: 1037

My nav is undefined, even with my document type declared

http://jsfiddle.net/cEv2S/ - My index page, fails to validate via xhtml 1.1 standards

I receive the validation error " Line 38, Column 6: element "nav" undefined "

<div id="header">Leon's CS150 Assignment</div>
    <nav>   <!-- this is the line quoted in my error message -->
        <div>
            <a class="Menu-Item" href="#">Home</a>
            <a class="Menu-Item" href="about.html">About</a>
            <a class="Menu-Item" href="cv.html">CV</a>
            <a class="Menu-Item" href="../wordpress">Wordpress</a>
            <a class="Menu-Item" href="../webshop/catalog">Webshop</a>
        </div>
    </nav>

My nav is clearly defined in my CSS and has been fine until I tried to validate, does anybody know why this is happening? I've even declared the document type.

Thanks in advance.

Upvotes: 3

Views: 3132

Answers (3)

Soturi
Soturi

Reputation: 1496

You are using the incorrect DOCTYPE for HTML5.

The <nav> element is defined in the HTML5 spec, but your document is not using HTML5.

You need to use the following doctype

<!DOCTYPE html>

Upvotes: 3

Olly Hodgson
Olly Hodgson

Reputation: 15785

<nav> is an HTML5 element. You are trying to validate against XHTML 1.1, which is a completely different thing.

You should use the HTML5 doctype (<!DOCTYPE html>) and the validator at http://validator.w3.org/

Note you can still use XML syntax: http://www.w3.org/TR/html5/the-xhtml-syntax.html

If you need to use XHTML1.1, try using a div with the WAI-ARIA navigation role instead of nav: <div role="navigation">. See http://www.marcozehe.de/2014/03/27/what-is-wai-aria-what-does-it-do-for-me-and-what-not/

Upvotes: 1

MStrutt
MStrutt

Reputation: 819

It's because nav is an HTML5 element, and you are validating to XHTML 1.1 standards. The nav element doesn't exist within XHTML 1.1. To use HTML5 elemnets you should use the HTML5 doctype:

<!DOCTYPE html>

Upvotes: 1

Related Questions