How to dynamically append li to ul?

Are the <ul> and <li> tags necessary in the HTML5 <nav> element?

  • Is there any benefit to creating a navigation menu like... <nav> <ul> <li><a href="#">...</a></li> <li><a href="#">...</a></li> </ul> </nav> ...or is that just a relic from older HTML versions?  With HTML5, is it more effective to just do... <nav> <a href="#">...</a> <a href="#">...</a> </nav> ...as shown on W3School's HTML5 tutorial?  Can't the <ul> and <li> tags be dropped completely?

  • Answer:

    As usual, do what semantically makes sense! Forget about the nav for a second, if it makes sense to put your navigation in an unordered list, then do it. For instance, if I had an introductory h1 tag at the top of my site and the navigation followed shortly afterward, I might want to put that in a list as it may briefly describe my entire website. If these items were not in a list, they would be indifferentiable contextually. But nav kind of solves that problem by saying elements on this level belong to some sort of navigation. But the nav doesn't tell a whole lot. It doesn't even guarantee that we only have anchor tags in it. Maybe our navigation consists of buttons or some links and some helper text. So, I think it kind of makes sense to be explicit and put your links in your navigation in a unordered-list. Because nav doesn't replace the list element, it's just further content organization. Also, what if you have sub-menus? Lists describe menus with sub-navigation pretty well and they give a clear hierarchy. So, in short, it's all about the meaning. This: <nav> <a href="...">...</a> <a href="...">...</a> </nav> Has different meaning than this: <nav> <ul> <li><a href="...">...</a></li> <li><a href="...">...</a></li> </ul> </nav> Lists summarize some content.

John Fawcett at Quora Visit the source

Was this solution helpful to you?

Other answers

If you want to make a table by unordered list then <li> tag is the right choice. item list will be marked by bulltes.Its syntax is:- (For make table in HTML)<ul><li></li><li></li><li></li></ul>If you are also searching for IT company then I think http://www.joviinternational.com/ is the right place. This is providing the affordable services for web design & development, Android Apps development, etc. in all over India.

Suresh Kumar

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.