Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the purpose of the <nav> tag

I have read a whole bunch of questions regarding where and how nav tags should be used and I get that we are meant to put "major" navigational elements within it but what is it's purpose?

I can see that w3schools says that

"Browsers, such as screen readers for disabled users, can use this element to determine whether to omit the initial rendering of this content."

but does it have any further use, are there any other implications of omitting the <nav> tag?

like image 460
Maxim Gershkovich Avatar asked Oct 08 '13 15:10

Maxim Gershkovich


People also ask

What is the purpose of the NAV tag in bootstrap?

The <nav> HTML element represents a section of a page whose purpose is to provide navigation links, either within the current document or to other documents. Common examples of navigation sections are menus, tables of contents, and indexes.

How does NAV work in HTML?

The <nav> element in HTML provides a set of navigation links, either within the current document or to other documents. Common navigation sections that use the <nav> element include indexes, table of contents, menus, etc. It is important to note that all links within a document do not need to be within a <nav> element.

Where is NAV tag in HTML?

Any HTML document is usually divided into two sections; the head section and the body section. The HTML nav element must be included in the body section of your HTML document, so any code you write should be inserted there.

What is the purpose of header and NAV?

By using a <header> tag, our code becomes easier to read. It is much easier to identify what is inside of the <h1> 's parent tags, as opposed to a <div> tag which would provide no details as to what was inside of the tag. A <nav> is used to define a block of navigation links such as menus and tables of contents.


1 Answers

It's a semantic improvement in HTML. A random section of the page with

<div>
    <div>
        <div>
            <ul>
                <li>...</li>
                <li>...</li>
                <li>...</li>
...

doesn't mean much in and of itself, and is only understood as being a "navigational" component when viewed by a user on the graphical page. Someone who is using a screen reader, or a text browser, or any kind of assistive technology would not know be easily able to understand the meaning behind the tag soup.

On the other hand, by enclosing your markup in meaningful, semantic tags, it would be very easy for a screen reader to understand that a specific part of the document is meant to be used as a nav, and take the necessary action.

In addition, it's also easier for a developer to look at the markup and immediately recognize what it is for.

<nav>
    <ul>
        <li>...</li>
...
like image 51
voithos Avatar answered Nov 03 '22 00:11

voithos