The new element tag in HTML5 is used to divide links with navigation properties together, making the code structure more accurate in semantic and at the same time for the screen Support for devices such as readers is also better. We have always been accustomed to using codes such as or
to write page navigation; in HTML5, we can directly The navigation link list is placed in the tag: <nav>
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="/about/">About</a></li>
<li><a href="/blog/">Blog</a></li>
</ul>
</nav> Copy after login
According to the W3C definition specification:
nav element is a element that can be used as page navigation A link group; navigation elements within it link to other pages or other parts of the current page. Not all link groups need to be put into the element; for example, there is usually a group of links in the footer, including terms of service, home page, copyright statement, etc.; in this case, it is most appropriate to use the element. , without the need for the element.
A page can have multiple elements as navigation for the entire page or different parts; the following is a code example given by W3C:
<body>
<h1>The Wiki Center Of Exampland</h1>
<nav>
<ul>
<li><a href="/">Home</a></li>
<li><a href="/events">Current Events</a></li>
...more...
</ul>
</nav>
<article>
<header>
<h1>Demos in Exampland</h1>
<p>Written by A. N. Other.</p>
</header>
<nav>
<ul>
<li><a href="#public">Public demonstrations</a></li>
<li><a href="#destroy">Demolitions</a></li>
...more...
</ul>
</nav>
<div>
<section id="public">
<h1>Public demonstrations</h1>
<p>...more...</p>
</section>
<section id="destroy">
<h1>Demolitions</h1>
<p>...more...</p>
</section>
...more...
</div>
<footer>
<p><a href="?edit">Edit</a> | <a href="?delete">Delete</a> | <a href="?Rename">Rename</a></p>
</footer>
</article>
<footer>
<p><small>© copyright 1998 Exampland Emperor</small></p>
</footer>
</body> Copy after login
In this example, we can see that can not only be used as the global navigation of the page, but can also be placed within the tag to link to other locations on the current page as a navigation related to the content of a single article.
The above is the detailed content of Detailed explanation of the function and use of html nav tag. For more information, please follow other related articles on the PHP Chinese website!
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn