Is it absolutely necessary to use lists inside of <nav> tags? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 23

Is it absolutely necessary to use lists inside of <nav> tags?

This question may be silly but I saw a lot of navigation sections that don't look like lists. ALL the links are on a single line. I saw a youtube tutorial on creating homepages. The instructor in that video made a flat navigation. He used an unordered list like in the lesson on Sololearn https://www.sololearn.com/learn/HTML/2199/ Then he spent time styling the list to make it NOT LOOK LIKE A LIST. Why? is there any rule, conventions about nav in html5?

1st Aug 2019, 10:44 AM
Dron Solarice
Dron Solarice - avatar
4 Answers
+ 25
Well, the short answer is NO. The reason they did that in those tutorials is simple: they wanted to manipulate a set of block level elements, logically grouped together. Web devs used to do that way before the <nav> element was introduced. Typically the code would look like this: <div> <ul> <li>Home</li> <li>Contacts</li> <li>About</li> </ul> </div> So they just replaced div tags with nav tags. More like a habit than a rule. It's just easier to select specific child elements that way. You can style your elements however you like, but I insist you should use classes for styling.
12th Feb 2020, 11:34 PM
🇺🇦 Vitya 🇺🇦
🇺🇦 Vitya 🇺🇦 - avatar
+ 20
Thanks again Rincewind for providing me a good resourse at https:seespsrkbox.com I honestly read both articles and made my conclusions. It is all about personal preferences not rules or conventions and I guess I've made my choise alredy. I mark your answer as the best one. Good luck.
4th Aug 2019, 11:00 AM
Dron Solarice
Dron Solarice - avatar
+ 15
Thank you Vitya :) ! This explanation is much better. Now I know more.
13th Feb 2020, 11:38 AM
Dron Solarice
Dron Solarice - avatar
+ 4
This is a great question, and I found an article here arguing for lists in navs (with a link at the bottom to someone arguing against them): https://seesparkbox.com/foundry/why_i_like_lists_in_nav_elements It makes a good argument - it's easier to add a submenu if your nav is structured like a list.
1st Aug 2019, 10:57 AM
Rincewind
Rincewind - avatar