嵌套 HTML 定义列表 () 是否正确?
Is it semantically correct to nest definition lists, or should they simply be a 'flat list of name/value pairs'.
The specs don't seem to forbid it.
Further to this question.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
好吧,规范似乎允许这样做,前提是只有
包含嵌套列表。 规范规定
Well the spec seems to allow it, provided that only the
<dd>
contains nested lists. The spec states that a<dt>
is an inline element, so it can't contain a nested list. A<dd>
is a block element, so an inner list inside one of these is fine.当然。 嵌套 DL 没有任何问题。 您可以在语义上拥有“子定义”。
Sure. There's nothing wrong with nested
DL
s. You can semantically have "subdefinitions."有趣的问题。
确实,DefList 旨在表示键和值,但它们的重数不是 1,而是 1+。 如果允许这种复杂性,并且记住 dt 是内联的,那么我认为用其他事物的树来表示定义某些事物没有语义问题。
Interesting question.
It's true that DefLists are intended to represent Keys and Values, but the multiplicity on those isn't 1 it's 1+. If that complexity is allowed, and bearing in mind that dt's are inline, I see no semantic problem with representing defining something in terms of a tree of other things.
我通过用无序列表或有序列表替换嵌套定义列表来解决这个问题,例如。
I solved that by replacing nested definition lists by unordered or ordered list, eg.
如果它在所有浏览器中都有效,那么就这样做。
我知道这可能会引起争议,很多人可能会告诉你这不是它应该使用的方式。 网页设计的不成文规则,比如几乎所有东西都使用列表,正是人们决定做的事情。 没有理由应该使用浮动(其目的是将图像浮动在文本块内)来布局网站上的每个小细节。 但如果你尝试使用表格,那么你显然是泡沫前时代的白痴,而且你不知道如何设计。
所以,做你想做的事,不要为了解决问题而让事情变得更复杂。
If it works in all the browsers, then do it.
I know this might be controversial, and a lot of people will probably tell you it isn't the way it's supposed to be used. The unwritten rules of webdesign, like using lists for almost anything, are just what people have decided to do. There is no reason why you should be using float (which purpose is to float an image inside a block of text) to layout every little detail on a website. But if you try to use tables you are an apparently an idiot from the pre-bubble era, and you have no idea how to design.
So, do what you want to do, and don't make things more complicated just to fix the problem.