为什么要使用列表进行导航? [英] Why use lists for navigation?

查看:227
本文介绍了为什么要使用列表进行导航?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

自从我开始学习css和html(现在记住,只有几个星期),我一直使用inline-block锚点我的导航菜单,没有列表。只是一个div与锚标签。原因是第一个例子,我看到使用所述的方法,我没有理由从它旅行。

Since I've started learning css and html (now bear in mind that has only been a few weeks) I've been using inline-block anchors for my navigation menus, no lists. Just a div with anchor tags in. Reason being the first example I saw used said method and I've not had reason yet to journey from it.

现在几乎所有指南我已经看到使用列表,与inline / inline-blocks串联。

Now pretty much all guides I've seen use lists, in tandem with inline/inline-blocks.

现在基本上,我想问:为什么列表?它看起来像是我的额外加价。

Now basically, I'd like to ask: why lists? It just seems like extra mark-up to me.

这真的!

谢谢

推荐答案

:总是尝试使用那些描述最好你想表达的元素。菜单通常是条目的列表。所以使用列表。

As a rule of thumb: always try to use those elements that describe best what you want to express. A menu typically is a list of entries. So use a list.

你可以使用其他元素模仿这样的列表的事实是没有错的。但它不改变一件事。列表是一个列表,应该写成列表。它对于其他人来说更直观和更容易理解。也为你自己,当你回来你的代码很多。

The fact that you can mimic such a list using other elements is not wrong. But it does not change a thing. A list is a list and should be written as a list. It is more intuitive and easier to understand for others. Also for you yourself when you come back to your code much later.

同样的原则适用于其他情况。一个例子:为什么不使用表布局的目的?它已经做了至少二十年的网络编程和工作相当不错。有些人还是这样做。但布局通常不处理表。它通常涉及二维布局,其中元素被定位为绝对或相对于彼此。所以清洁的解决方案是做到这一点。使用标记,定位,浮动,清洁,容器等。不要错过使用的东西,当你可以实现一个干净的解决方案。

The same principle applies in other situation. An example: why not use tables for layout purposes? It has been done for at least two decades of web programming and works pretty well. Some people still do it. But layout typically does not deal with tables. It typically deals with a 2 dimensional layout, where elements are positioned absolute or relative to each other. So the clean solution is to do exactly that. Using markup, positioning, floats, cleans, containers and the like. Do not miss use things when you can implement a clean solution.

这篇关于为什么要使用列表进行导航?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆