当前位置: 动力学知识库 > 问答 > 编程问答 >

html - Why use inline list items for tabs?

问题描述:

When making tabs on a website, I always used an unordered list with inline-block list items. Why is this generally considered the correct way over something like a few divs with the same inline-block display setting?

.tabs li {

display: inline-block;

}

<ul class='tabs'>

<li>Tab one</li>

<li>Tab two</li>

...

</ul>

vs

.tabs > div {

display: inline-block;

}

<div class="tabs">

<div>Tab 1</div>

<div>Tab 2</div>

...

</div>

I realize this question can be subjective, but I think there exists an objective answer.

网友答案:

Unstylized content:

When stripped of the CSS, the <ul> format will give the viewer a better understanding of the purpose of the elements.

网友答案:

That gives it more semantic meaning and is the perfect element for navbars and tabs..divs per se don't carry any semantic meaning with them..

网友答案:

semanticaly, ideologically, and when viewing as unstyled content, unordered list is more close to what you're trying to achieve than just bunch of divs.

网友答案:

With HTML5, this is even the only way you should go, because your list should be included inside a <nav> element. See documentation on MDN. So the answer is, for semantic. With a list, the items are linked to each other, which improves accessibility.

分享给朋友:
您可能感兴趣的文章:
随机阅读: