正在使用< li>不包围< ul>标签危险? [英] Is using <li> without enclosing <ul> tags dangerous?

查看:122
本文介绍了正在使用< li>不包围< ul>标签危险?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

< li> ...< / li> 插入网页时没有将项目放入< ul> block?例如:

 < div style =border:solid 1px red;> 
< li>项目< / li>
< li>另一项目< / li>
< li>另一个项目< / li>
< / div>

验证是我最担心的问题,我想知道这可能会在浏览器中终止用户能够按预期浏览该页面。

解决方案

完全不是有效的标记。得到正确显示,这只是运气的问题。

由于您似乎通过浏览器中断了终端用户按预期查看页面的能力来定义危险,因此它是危险的。



浏览器正尽全力弥补无效标记,但并不保证 页面正确显示。



您认为验证是您关注的问题中最少的,请重新考虑并查看为什么验证?。如果你关心你的页面正确显示没有怪癖,然后验证。



最后, HTML Tidy 可以帮助您修复现有的html。

编辑:我将你的片段提交给了browsershots.org,看看它是如何被不同浏览器渲染的。


What are the dangers of inserting <li>...</li> into a page without enclosing the item(s) in a <ul> block? For example:

<div style="border:solid 1px red;">
    <li>Item</li>
    <li>Another Item</li>
    <li>Yet Another Item</li>
</div>

Validation is the least of my concerns, I'm wondering what this might break in browsers for the end user's ability to view the page as intended.

解决方案

It's not valid markup at all. If it gets displayed correctly, it's only a matter of luck.

As you seem to define dangerous by "break in browsers for the end user's ability to view the page as intended", then yes it's dangerous.

Browsers are trying their best to compensate for invalid markup but there is no guarantee at all your page gets displayed correctly.

You say validation is the least of your concerns, please reconsider and have a look at Why Validate?. If you care about your page being displayed correctly with no quirks, then validate.

Finally, HTML Tidy may help you fixing existing html.

EDIT: I submitted your fragment to browsershots.org to see how it gets rendered by different browsers.

这篇关于正在使用&lt; li&gt;不包围&lt; ul&gt;标签危险?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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