Do I need to wrap the navigation (ul tag) in a div or nav tag?

I saw how some people exchange their navigation (tag <ul>) inside <div>, and <div>it only has CSS field / padding properties that apply to it.

We can just draw the navigation without <div>and put the marker and pad into the tag <ul>. So you need to put the tag <ul>inside <div>, or is it just personal preference / benefit?

And for HTML5, which was implemented in some browsers, do I need to put the <ul> tag used to navigate in the tag <nav>?

Like, for example, Breaking the HTML5 demo page .

+5
source share
3 answers

No, there is no need to wrap the navigation <ul>external <div>. In most cases that I have seen, people use it only because they have the habit of wrapping everything in div( divitis ).

However, in some cases it becomes necessary to wrap divaround a navigation list. For example, if you want to apply several backgrounds - one on the div and the other on ul, the managed one is padded / margined yourself.

An additional div can also be used to properly structure your document.

html5 <nav>, , , , (, ), , <nav> (, , ) , , <ul> , |.

+4

HTML5, , Internet Explorer HTML5, <nav>.

( , <p> - , , .)

<div>, , .

+2

No, this is not necessary, but it depends on the layout. <div>provides more control over the positioning of document segments, so maybe they just use a div for this purpose.

0
source

All Articles