Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between <nav> and <div>?

Tags:

html

css

Let's say I have a set of links, can I use <div> instead of <nav>?

<div>
  <ul>
   <li class="head_divider">...</li>
   <li class="head_divider">Text<br />Here</li>
   <li class="head_divider">...</li>
 </ul>

What is the difference between the two? they yield the same format/answer for me

like image 639
Matthew Francis Avatar asked Mar 19 '16 04:03

Matthew Francis


2 Answers

  • <nav> meant for more semantic markup (letting the browser know) that those links aren't just normal links, they are a navigation menu. This can be useful for accessibility (tabs, mobile devices,browsers, such as screen readers for disabled users, can use this element to determine whether to omit the initial rendering of this content.) and other things.

    For More reference on <nav> : https://www.w3.org/TR/html51/sections.html#the-nav-element

  • The <div> tag defines a division or a section in an HTML document. It is a block-level element that is commonly used to identify large groupings of content, and which helps to build a web page’s layout and design using CSS.

    For more reference on <div> : http://www.html-5-tutorial.com/div-tag.htm

When it comes to styling there is no big difference,

<nav>

<div>

like image 147
AVI Avatar answered Sep 27 '22 16:09

AVI


Technically they work the same way, but for search engines that tells them there is a navigation area.

like image 32
dnviveros Avatar answered Sep 27 '22 17:09

dnviveros