html doctype 添加空格?
有人可以向我解释为什么文档类型为
和
在 Firefox 下以不同方式呈现以下块?
<table style="border-collapse:collapse; margin:0; padding:0;">
<tr>
<td style="border:1px solid red; margin:0; padding:0;"><img src="http://images.smh.com.au/2010/06/01/1533814/th_park-90x60.jpg" style="border:none; padding:0; margin:0;" /></td>
</tr>
</table>
使用“Transitional”,图像下方没有空白,使用“Strict”则有!
第二个问题,使用严格,是否可以删除这个空格?
can someone please explain to me why having a doctype of
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
and
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN">
render the following block differently under firefox?
<table style="border-collapse:collapse; margin:0; padding:0;">
<tr>
<td style="border:1px solid red; margin:0; padding:0;"><img src="http://images.smh.com.au/2010/06/01/1533814/th_park-90x60.jpg" style="border:none; padding:0; margin:0;" /></td>
</tr>
</table>
using 'Transitional', there is no white space below the image, using 'Strict' there is!
2nd question, using strict, is it at all possible to remove this whitespace?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
正如您在此表中看到的,第一个Doctype 在所有浏览器中触发怪异模式,第二个将触发标准模式。
这个故事的其余部分在图像、表格和神秘间隙继续:
As you can see in this table, the first Doctype triggers quirks mode in all browsers, the second will trigger standards mode.
The rest of this story is continued at Images, Tables, and Mysterious Gaps:
我怀疑标记中的空白(例如,使表代码清晰易读的换行符和制表符)有问题。我以前遇到过类似的问题,标记中的空格导致屏幕上出现烦人的空格,即使它看起来无关紧要(例如,在
标记之间)。
尝试将表格标记折叠到一条长线上。
My suspicion is that the white space within the markup (e.g., the newlines and tabs that make the table code nicely legible) are at fault. I've encountered similar issues before, where space in the markup resulted in annoying space on the screen, even where it would appear not to matter (e.g., between
<li>
tags).Try collapsing the table markup onto a single lengthy line.
不确定为什么会出现空格。就修复而言,如果您不介意显式设置表格单元格的高度,则可以添加 display:block;高度:60px;适合您的 td 风格。
Not sure why the space occurs. As far as a fix goes, if you don't mind explicitly setting a height for your table cell, you can add display:block; and height:60px; to your td styles.
第一个 DOCTYPE 将以几乎标准模式呈现您的页面:
第二个 DOCTYPE 将以标准模式呈现您的页面。
The first DOCTYPE will render your page in almost standards mode:
The second DOCTYPE will render your page in standards mode.