Should we put the <ul> tag inside the <nav> tag?

Interestingly, many websites place a tag inside a tag, from the specification, the nav tag has anchored tags, and here is an example in w3schools why many sites do it this way:

<nav> <ul> <li><a href="#">Home</a></li> <li><a href="#">About</a></li> </ul> </nav> 

Is this right or should we do just that

 <nav> <a href="#">Home</a> <a href="#">About</a> </nav> 
+4
source share
5 answers

In general, this is not required, but it’s very common practice to put your navigational elements in a list and use CSS to display their inline elements (if necessary). This is not only advice for HTML5 - if you disable the CSS example in the browser, your menu will display as:

get in touch with me (can you read this?)

with the list will be:

  • start
  • about me
  • contact

Think about which version you would like to see in case of problems with the display of the design.

+4
source

It is important to note that new tags have been developed, such as nav, section, header, footer, etc. By themselves, these tags behave just like a div. The reason people start using them on their html5 sites is to provide context to the document. Although I roll my eyes when I hear terms like β€œWeb 2.0,” these terms convey changes in thinking about how we use the Internet. Whenever you hear "Web 3.0" ... ugh, all of this actually means that people are trying to think about how to make the web more semantic, which means that the user interface is more customizable based on user behavior and preferences. Tagging your document with these tag types helps provide that context. However, the implementation of how it will be presented is still up to you, and I believe that both of the examples you provided are absolutely correct.

There is a decent article here that discusses this in more detail:

http://html5doctor.com/lets-talk-about-semantics/

+2
source

I always thought that any tag that exists solely to host another, one tag is extraneous.

However, semantic and reasonable design is an inaccurate science, so people have different views.

+1
source

According to the specification of the nav element, it represents a section of a page that links to other pages or parts of a page. The specification does not provide for any specific structure in the nav element. The ul block, on the other hand, combines navigation links for logical and / or practical purposes. Using lists for navigation blocks helps users who surf the Internet with assistive technology because a screen reader can skip entire blocks of navigation by jumping from one level of navigation to another.

Literature:

+1
source

I would say: Yes, if there is a multi-level nav (so it will have hierarchical ordering). No, in all other cases: you save data, get speed and readability .

IMHO UL should be used to display the actual unordered list, the same is said for tables that should display tabular data.

0
source

All Articles