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?
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.
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.
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.
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.
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>
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With