Difference between nav vs div.navbar in Bootstrap

前端 未结 2 690
隐瞒了意图╮
隐瞒了意图╮ 2021-01-02 00:39

Some of Bootstrap\'s examples use div.navbar to hold the navigation bar, and other examples (e.g., in the Components documentation page) use nav.navbar

相关标签:
2条回答
  • 2021-01-02 01:28

    Both will output same design but using nav tag is more semantic in approach. It represents main navigation of your page. using nav tag helps search engine recognize which is your main navigation on the page. there might be other links too but your top menu is the main menu. Hope this helps

    0 讨论(0)
  • 2021-01-02 01:43

    Nav is semantically more correct and is preferred over Div. As to some answers I have read, Div is often regarded as the last option to use in any element but we often see the opposite.

    MDN Definition Nav

    The HTML <nav> 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. Here's the MDN Page Link for Nav Element

    As I searched some more on the internet for Navbar, all I can get from that is Navbar is specifically for Links and Button Elements. It is used inside Nav, as we see it being used in bootstrap docs.

    0 讨论(0)
提交回复
热议问题