省略 </TD> 是否安全?和</TR>标签? [英] Is it safe to omit </TD> and </TR> tags?

查看:39
本文介绍了省略 </TD> 是否安全?和</TR>标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据w3c </TD></TR> 标签是可选的,因此下表完全有效.

According to w3c </TD> and </TR> tags are optional, so the following table is perfectly valid.

<table>
  <tr>
    <td>google
    <td>chrome
</table>

我测试过的所有浏览器都可以很好地呈现表格.我只是想问问这是否通常被认为可以安全使用,或者我无法访问的旧浏览器是否会导致问题.谢谢.

And all browsers I've tested it with render the table fine. I just wanted to ask if this is generally considered safe to use, or if older browsers, which I don't have access to, cause problems. Thanks.

它可以将包含许多表格的页面上的 gzip html 大小减少几个百分点.

It reduces gzip html size on a page with many tables by a few percent.

推荐答案

这是安全的,因为标准中的可选性意味着所有浏览器(至少那些甚至是远程重要的浏览器)都会实现这一点 - 以及浏览器标准合规性通常会反其道而行之,即尝试使用即使是无效的 HTML 也能正常工作,而不是在缺少可选标签时失败.

It is safe, since optionality in the standard means that all the browsers (at least the ones which even remotely matter) would have implemented this - and the browser standards compliance usually runs to the opposite side, into trying to work correctly with even invalid HTML as opposed to failing on missing optional tags.

话虽如此,我发现省略这些标签会使内容更难阅读,如果目标是大小优化,这对您来说可能重要也可能无关紧要.

Having said that, I find that omitting such tags makes things harder to read, which may or may not matter to you if the goal is size optimization.

附言另外,如果您有非常大的表,我想知道在处理此类构造时浏览器的 HTML 解析器是否会产生任何开销?如果没有基准测试或深入思考 HTML 解析器的详细工作原理,我不确定,但如果发生这种情况,这可能是一个因素.

P.S. Also, if you have very large tables, I wonder whether there's any overhead incurred by the browser's HTML parser when dealing with such constructs? I am not sure without benchmarking or really deep thinking about how HTML parser works in detail, but it is something that could possibly be a factor if it happens.

这篇关于省略 &lt;/TD&gt; 是否安全?和&lt;/TR&gt;标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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