开发者

Why use list to do navigation menu instead of buttons?

开发者 https://www.devze.com 2023-02-23 08:02 出处:网络
I have inspected many navigation menus on the internet, and they often use lists instead of a button. What is the 开发者_运维百科reason behind this? Why use the button? Thank you.Generally lists are u

I have inspected many navigation menus on the internet, and they often use lists instead of a button. What is the 开发者_运维百科reason behind this? Why use the button? Thank you.


Generally lists are used for navigation items in HTML because they are presenting a list of navigation options to the user.

HTML5 offers a bit more semantic precision using menu and nav


There are (at least) two good reasons to use lists. Using lists can help to give an idea of your site's structure which is good in terms of SEO but also if people use either custom CSS or screen readers for accessibility reasons. The second and slightly related one is that it's rather helpful when it comes to creating stylesheets. You don't need to come up with your own way of nesting elements. Just use lists and go from there. Then you can focus on getting the stylesheet right providing different styles for different hierarchy levels, first, last, odd or even list items.


The semantics of a list make it look more like a grouped section, that's all I can think of. There is no real (dis)advantage for using list items over other methods of defining a menu.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号