nav

Удобный тег, объединяющий элементы навигации по сайту.

Время чтения: меньше 5 мин

Кратко

Скопировать ссылку «Кратко» Скопировано

В контейнере можно собрать ссылки для навигации по сайту.

Пример

Скопировать ссылку «Пример» Скопировано

    , поскольку элементы меню однотипные по смыслу и связаны между собой:

Как понять

Скопировать ссылку «Как понять» Скопировано

В контейнер помещаются основные ссылки, по которым пользователь сможет быстро перейти на нужный раздел сайта.

Как пишется

Скопировать ссылку «Как пишется» Скопировано

Тег парный, всегда нужно закрывать < / nav>.

На странице можно использовать несколько .

Атрибуты

Скопировать ссылку «Атрибуты» Скопировано

У нет уникальных атрибутов, применяются все глобальные атрибуты.

Подсказки

Скопировать ссылку «Подсказки» Скопировано

💡 — это один из ориентиров (landmark), которые скринридеры могут использовать для навигации по странице. То есть можно перейти прямо в блок навигации по сайту, это очень удобно.

💡 Спецификация рекомендует не увлекаться разметкой всех ссылок на странице с помощью , достаточно указать самые важные.

Ещё пример

Скопировать ссылку «Ещё пример» Скопировано

Создадим так называемые «хлебные крошки» — ссылки на страницы, указывающие на разделы, в которых находится текущая страница:

 nav  border-bottom: 1px solid black;> .crumbs ol  list-style-type: none; padding-left: 0;> .crumb  display: inline-block;> .crumb a  position: relative;> .crumb a::after  content: ">"; position: absolute; padding: 0 5px; color: #ffffff; font-size: 80%;> nav  border-bottom: 1px solid black; > .crumbs ol  list-style-type: none; padding-left: 0; > .crumb  display: inline-block; > .crumb a  position: relative; > .crumb a::after  content: ">"; position: absolute; padding: 0 5px; color: #ffffff; font-size: 80%; >      

На практике

Скопировать ссылку «На практике» Скопировано

Дока Дог советует

Скопировать ссылку «Дока Дог советует» Скопировано

🛠 — это набор функционально важных ссылок по разделам сайта. Важно выделить , чтобы поисковик понял, что находится в блоке навигации.

Алёна Батицкая советует

Скопировать ссылку «Алёна Батицкая советует» Скопировано

🛠 Навигация может быть не только по страницам внутри сайта, но и по внешним ресурсам. Например, блок с перечислением компаний-партнёров со ссылками на их сайты. В этом случае также вполне уместно использовать .

Источник

: The Navigation Section element

The 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.

Try it

Content categories Flow content, sectioning content, palpable content.
Permitted content Flow content.
Tag omission None, both the starting and ending tag are mandatory.
Permitted parents Any element that accepts flow content.
Implicit ARIA role navigation
Permitted ARIA roles No role permitted
DOM interface HTMLElement

Attributes

This element only includes the global attributes.

Usage notes

  • It’s not necessary for all links to be contained in a element. is intended only for a major block of navigation links; typically the element often has a list of links that don’t need to be in a element.
  • A document may have several elements, for example, one for site navigation and one for intra-page navigation. aria-labelledby can be used in such case to promote accessibility, see example.
  • User agents, such as screen readers targeting disabled users, can use this element to determine whether to omit the initial rendering of navigation-only content.

Examples

nav class="menu"> ul> li>a href="#">Homea>li> li>a href="#">Abouta>li> li>a href="#">Contacta>li> ul> nav> 

The semantics of the nav element is that of providing links. However a nav element doesn’t have to contain a list, it can contain other kinds of content as well. In this navigation block, links are provided in prose:

nav> h2>Navigationh2> p> You are on my home page. To the north lies a href="/blog">my bloga>, from whence the sounds of battle can be heard. To the east you can see a large mountain, upon which many a href="/school">school papersa> are littered. Far up this mountain you can spy a little figure who appears to be me, desperately scribbling a a href="/school/thesis">thesisa>. p> p> To the west are several exits. One fun-looking exit is labeled a href="https://games.example.com/">"games"a>. Another more boring-looking exit is labeled a href="https://isp.example.net/">ISP™a>. p> p> To the south lies a dark and dank a href="/about">contacts pagea>. Cobwebs cover its disused entrance, and at one point you see a rat run quickly out of the page. p> nav> 

Result

Specifications

Browser compatibility

BCD tables only load in the browser

Источник

HTML Tag

The tag is an HTML5 element used to define a section of navigation links within a web page. This tag helps with both the structure and semantics of the webpage, making it more accessible for users and search engines alike. The element can be used to group the main navigation links, such as links to different sections or pages of a website.

The tag is one of the HTML5 elements. It is used to specify a block of navigation links, either within the current document or to other documents. Examples of navigation blocks are tables of contents, menus, and indexes.

nat tag example

One HTML document may contain several tags, for example, one for site navigation and one for intra-page navigation.

Note that not all links in the HTML document are placed inside the element, it includes major navigation blocks. The tag can be placed for defining links in the footer of the website, but the tag is usually used in such cases.

Syntax

The

Оцените статью