w3 html 验证器会告诉我这是错误的:
<a href="http://www.bla.com>
<div>something</div>
<ul>
<li>first</li>
<li>second</li>
</ul>
</a>
为了获得严格的 HTML 4 验证(或者只是为了正确编写内容)
什么是更好的编写方法:
-
没有 div 和 ul - 只是带有类的 span我需要设计:
某事;
第一个
第二个
-
without
something
<li>first</li>
<li>second</li>
====================== ===
抱歉,代码看起来不是最好的 - 我有处理本网站上的“代码采样器”时遇到麻烦。
w3 html validator will tell me that this is wrong:
<a href="http://www.bla.com>
<div>something</div>
<ul>
<li>first</li>
<li>second</li>
</ul>
</a>
in order to get a validated as HTML 4 strict (or just for writing things correctly)
What is the better way to write it:
-
no div's and ul's - just span's with classes that I need to design:
<a href="http://www.bla.com>
<span class="div">something</span>
<span class="ul">
<span class="li">first</span>
<span class="li">second</span>
</span>
</a>
-
without <a>
<div id="actAsLink" onclick="javascript:window.open('http://www.bla.com')>
<div>something</div>
<ul>
<li>first</li>
<li>second</li>
</ul>
</div>
=========================
sorry that the code doesn't look at its best - I had troubles handling the "code sampler" on this website.
发布评论
评论(2)
我投票支持选项 1:锚点 + 描述性类名称:
、
不过,您的结构看起来有点奇怪:为什么要在锚中嵌套列表?
I vote for option 1: Anchor + descriptive class names:
<ul>
,<li>
elements. These elements can be styled using CSS.Your structure looks a bit odd though: Why do you want to nest a list in an anchor?
实际上,您应该在每个
div
、ul
和li
标签内添加标签:
这是有效的标记,但显然有一个缺点,就是你有三个链接而不是一个。我不确定为什么你想在链接内有一个列表 - 更常见的是看到链接列表。
Really you should have
<a>
tags inside each of thediv
,ul
andli
tags:This is valid markup, but obviously with the downside that you have three links instead of one. I'm not sure why you want to have a list inside a link though - it's more common to see a list of links.