html doctype添加空格? [英] html doctype adds whitespace?

查看:150
本文介绍了html doctype添加空格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以向我解释为什么有一个文档类型

<!DOCTYPE HTML PUBLIC - // W3C // DTD HTML 4.0 Transitional // EN>





<!DOCTYPE html PUBLIC - // W3C // DTD XHTML 1.0 Strict // EN>



呈现以下内容在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.jpgstyle =border:none; padding:0; margin:0; />< / TD>
< / tr>
< / table>

使用'Transitional',图像下方没有空白,使用'Strict'!



第二个问题,使用strict,是否有可能删除这个空格?

解决方案

正如你可以在这张表中看到的,第一个Doctype 触发怪癖模式在所有浏览器中, second 会触发标准模式。 / p>

这个故事的其余部分继续在图片,表格和神秘的差距


设置图像为块



第一个选择,一个将
工作大多数图形密集
设计,是将图像从
作为一个内联元素转换为一个
块级元素。这样做,它
不再生成一个线框,所以
的问题消失 - 假设
图像是唯一的
占据该表格单元格。在
最简单的情况下,我们可以像下面这样添加一个样式

$ b $ $ $ $ $ $ $ c $ t $ im $ {display:块;}



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?

解决方案

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:

Setting images to be blocks

The first choice, and one that will work for most graphically-intense designs, is to convert the image from being an inline element to a block-level element. Do that, and it no longer generates a line box, and so the problem goes away-- assuming that the image is the only thing that occupies that table cell. In the simplest case, we might add a style like this:

td img {display: block;}

这篇关于html doctype添加空格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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