简体   繁体   English

将DOCTYPE从html 4.01过渡到html时,我应该寻找什么?

[英]what should I look for when switching DOCTYPE from html 4.01 transitional to 'html'?

According to Firefox, my pages are rendered in 'standards compliance mode' using the following doctype... 根据Firefox,我的页面使用以下文档类型以“标准合规性模式”呈现...

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

I'm changing it to <!DOCTYPE html> and I see some differences in the rendering of the page. 我将其更改为<!DOCTYPE html>并且看到页面呈现方面的一些差异。 I thought the doctype was mainly for validators as long as the rendering was 'standard' and not 'quirks' but guess I was wrong. 我认为文档类型主要用于验证程序,只要渲染是“标准的”而不是“怪异的”即可,但是我猜我错了。

I'm seeing things like a 100px height <img> inside an <a> was 100px high before, but now it's 105px. 我看到像<a>内高度为100px的<img>之前的高度为100px,但现在为105px。 If I set such <img> via css to display:block now it's fine, but why the difference? 如果我现在通过CSS将<img>设置为display:block那很好,但是为什么会有区别呢? again, supposedly the page was already in standards mode, not quirks (if I remove the 4.01 DOCTYPE it really messes things up and Firefox says it's in quirks mode). 再次,据说该页面已经处于标准模式,而不是古怪的(如果我删除了4.01 DOCTYPE,它确实搞砸了,而Firefox则说它处于古怪的模式)。 Or are there several 'standards' modes? 还是有几种“标准”模式? What else should I look for, is there a list somewhere? 我还要寻找什么,那里有清单吗? (I Googled for it and all I found was some deprecated things that don't seem to apply to my differences) (我为此搜索了Google,发现的所有内容似乎已不适用于我的差异)

4.01 Transitional with a system identifier triggers almost standards mode in Firefox. 具有系统标识符的4.01 Transitional在Firefox中几乎触发标准模式

what differs in almost-standards mode is roughly this: inline boxes that have no non-whitespace text as a child and have no border, padding, or margin: 几乎标准模式的不同之处大致在于:内联框没有子级的非空白文本,也没有边框,内边距或边距:

  • do not influence the size of the line box (that is, their line-height is ignored) 不影响线框的大小(也就是说,其线高被忽略)
  • do not get a height (eg, for their background) larger than that of their descendants, even if their font size is larger (if they have no descendents, they are zero-height positioned at their baseline) 即使字体大小较大(例如,如果没有后代,则它们的基线高度也为零),其高度(例如,对于背景而言)不会大于其后代的高度

Almost standards mode and the two you mentioned in your question are the only three modes you need to worry about. 几乎标准模式和您在问题中提到的两种模式是您唯一需要担心的三种模式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM