在怪异模式下无法正常工作的所有内容的列表?

发布于 2024-08-13 17:10:05 字数 1539 浏览 6 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

白馒头 2024-08-20 17:10:05

以下是浏览器特定怪癖模式行为的汇总:

某些 HTML5 功能不受某些版本的 IE 支持。例如,IE 9 无法识别 Quirks 模式下的 canvas 元素。

盒子模型不正确(与 CSS 规范不同,尽管直观上可能更自然)。这意味着 width 和 height 属性指定整个元素框的尺寸,包括填充和边框,而不仅仅是元素的内容。 (本文档后面有一个演示。)

非替换内联元素(例如默认的span元素)的尺寸受宽度和高度属性的影响(而根据CSS规范,它们应被忽略)。

应用元素的百分比高度(例如,HTML 中的

或 CSS 中的 table { height: 100% }) ,使用可用高度作为参考,即使封闭块的高度为:auto(默认值)。标准模式下,高度根据内容要求确定;但当封闭块的高度设置为特定值时,百分比高度起作用。

body 元素的高度为 100%,这与由内容决定的高度相反。 (如果您希望标准模式下的 body 高度为 100%,请在 CSS 中设置 html, body { height: 100% }。)

文本区域宽度的计算方式不同。例如,在 IE 9 上,cols=5 使该区域在标准模式下为 5 个字符宽,但在怪异模式下仅为 4 个字符宽。

通过展开框来处理溢出。当元素的内容不适合为其指定的尺寸(显式或隐式)时,overflow:visible(默认)意味着内容溢出,而框尺寸符合指定。在 Quirks 模式下,尺寸会发生变化;这很容易看出,例如,如果盒子有背景颜色或边框。

当图像未显示时,替代文本并不总是显示为图像的替换。当 img 元素的尺寸小于文本所需的尺寸时,例如 Some alt text 当 x.png 不存在时。 Firefox 会忽略文本并仅针对损坏的图像显示通用图标。

根元素是 Quirks 模式下 IE 上的 body 元素。根据规范,它是 html 元素。例如,设置正文的边距或宽度在 Quirks 模式下不起作用。另一个例子,IE 默认情况下有一个垂直滚动条,尽管当没有任何内容可滚动时它处于非活动状态(暗淡),并且您可以通过设置 body { Overflow: 在 Quirks 模式下将其删除(不需要时):汽车; },但在标准模式下,需要添加 html { Overflow: auto; } 也是如此。

某些版本的 IE 上默认显示灰色 2px 页面边框。在某些情况下,可以通过设置 html 元素的 border 属性(例如 html { border: 0; })来更改或删除它。

id 属性值的匹配不区分大小写,因此 CSS 选择器 #foo 会匹配 id="Foo" 的元素。根据规范,匹配必须区分大小写:#foo 仅匹配 id="foo" 的元素。

在 CSS 中为 img 元素或 input type="image" 元素设置时,图像的填充将被忽略。
浮动图像的默认水平边距是三个像素(而不是零)。也就是说,如果img元素具有属性align =“left”或align =“right”,或者如果CSS规则float:left或float:right适用于它,则浏览器的行为就像img元素具有属性hspace = “3”(或其 margin-left 和 margin-right 属性的值为 3px)。这适用于 IE;在其他浏览器上,Quirks 模式可能只会导致图像一侧出现额外边距,并且其宽度可以是 2 像素而不是 3 像素。

在某些条件下,图像的垂直对齐是与封闭框的底部对齐,而不是与文本的基线对齐。当图像是元素(通常是表格单元格)中的唯一内容时,就会发生这种情况。这意味着,例如,在怪异模式下,表格单元格中的图像默认位于单元格的底部(这通常是作者想要的),而在标准模式下,图像下方有几个像素间距(除非设置例如垂直对齐:img 元素的底部)。

在 Quirks 模式下,IE 9 上的文本渲染不会使用浏览器中的一些新功能。这可能例如使得一些文本所需的宽度在不同模式下不同,从而影响文本到行的划分。请参阅 Microsoft 的关于 Windows Internet Explorer 9 中的文本呈现。

使用例如 margin: 0 auto 将 CSS 中的块居中不起作用。注意:在 IE 至 IE 7 上,在 HTML 中设置align=“center”或在 CSS 中为 div 设置 text-align:center 会错误地将任何内部块元素作为一个整体居中,即使在标准模式下也是如此。在 IE 8 上,这种情况仅发生在 Quirks 模式下,

字体属性不会从正文或其他封闭元素继承到表中。这种情况尤其适用于字体大小,但也可能适用于字体、颜色和行高。例如,如果您设置 body { font-family: Arial },表格单元格中的字体可能会保留浏览器默认字体。

在表格单元格的字体大小设置中,百分比值被解释为相对于浏览器的基本字体大小,而不是相对于 CSS 规范应用于封闭元素(表格行)的字体大小。

字体大小关键字的解释不正确,因此“中”大于浏览器的基本字体大小,“小”等于该基本字体大小。同样,关键字 xx-small、x-small、small、large、x-large、xx-large 的整个范围被系统性地解释为错误:每个值都被解释为比应有的值大一级。

IE 9上的字体渲染有所不同。在标准模式下,它应用了更先进的技术。这会导致可能很重要的微小差异,影响文本的宽度等。请参阅关于 Windows Internet Explorer 9 中的文本呈现。

边框宽度关键字“thin”、“medium”和“thick”在 IE 上具有不同的含义。例如,thin 在标准模式下为 1px,在 Quirks 模式下为 2px。

bordercolor 属性是非标准但得到广泛支持的属性,IE 在 Quirks 模式与标准模式中的处理方式有所不同。颜色看起来不同,但这似乎是由边框样式的影响引起的。

单选按钮和复选框在 Quirks 模式下的 IE 中的总尺寸为 20 x 20 像素,而标准模式和其他浏览器中的总尺寸为 13 x 13。图形按钮或框的大小相同,但周围的间距不同。它是元素渲染的一个组成部分,不受 padding 或 margin 属性影响,但受 width 和 height 属性影响。

格式错误的属性值通常会根据猜测进行解释,例如,将 margin: 10 解释为 margin: 10px,将 color: ffffff 解释为 color: #ffffff。这违反了 CSS 中的强制错误处理规则:使用语法不正确值的规则将被忽略。

浏览器无法识别的不正确属性值可能会导致该属性的早期设置被忽略。例如,设置 h1 { color: red;颜色:废话; } 可能会导致整个规则被忽略;根据规格,以正确设置颜色:红色为准。此类重复设置通常用于尝试在使用高级 CSS 值时提供后备,而在 Quirks 模式下这通常会失败,因为后备会被忽略。该问题仅出现在 CSS 规则中,因此将规则分为两部分会有所帮助。例如,代替 h1 { color: #ccc;颜色: rgba(255, 255, 255, 0.7); } 你会使用 h1 { color: #ccc; } h1 { 颜色: rgba(255, 255, 255, 0.7); }

CSS 中的类和标识符选择器中字母的大小写被视为无关紧要。因此,选择器 .foo 与 class="Foo" 或 class="FOO" 的元素匹配。根据 CSS 规范,这种情况在这些上下文中具有重要意义。
类和标识符选择器接受格式错误的名称。具体来说,接受以句点或数字符号开头的名称(例如在选择器 .123a 和 #42 中)。

声明空白:pre 被忽略。

不支持固定定位:声明position:fixed被视为position:static(在IE 7上)。

IE 7 中对 CSS 支持的许多标准 (CSS 2.1) 添加(例如 max-width 属性和属性选择器)未使用 Quirks 模式。也就是说,有许多 CSS 功能在 IE 6 中不支持,而在 IE 7 中支持,但仅在标准模式下支持。请参阅 Microsoft 的博客文章有关 IE7 的 CSS 更改的详细信息。

某些非标准 CSS 功能(CSS 2.1 中没有的功能),例如滚动条属性,可以在 Quirks 模式下被某些版本的 IE 和 Opera 识别,但在标准模式下会被忽略。在 IE 8 及更高版本上,这也适用于 expression() 构造。

在许多浏览器中,设置 rowspan=0 或 colspan=0 会被忽略,即使它们在标准模式下支持这些设置。 (它们意味着单元格跨越行或列的其余部分。这是最近在浏览器中实现的。)

标签汤解析。例如,如果文档包含标记

文本<表格>...
那么例如,Firefox 在 Quirks 模式下将 p 元素视为包含 table 元素。在标准模式下,表的开始标记隐式关闭打开的 p 元素。例如,如果您在 p 元素上设置边框,则可以看到差异。同样,例如,Firefox 接受 font 元素内的 ul 元素。在此类问题中,即使在标准模式下,IE 也总是按照错误的规则工作,但是通过使用有效的标记并始终使用显式的结束标记(例如

)可以实现符合标准的行为,即使它们是正式可选。

不同标签的汤处理。或多或少的一个相反的问题是,在 Quirks 模式下,像

...

这样的标记不会影响表格内文本的颜色。在标准模式下,它确实如此 - 即使标记是非标准的(根据所有 HTML 规范无效)!

元素之间的空白可能很重要。例如,假设您有一个链接列表。通常,您可以在列表项、li 元素之间(即

  • 标记之间)编写带有换行符的标记:< /p>
  •     <ul>
        <li><a ...>...</a></li>
        <li><a ...>...</a></li>
        ...
        </ul>
    

    但是,如果您设置 display: block 和链接元素的边框,则可能会在框之间出现垂直间隙(空行)。这种情况发生在怪异模式下的 IE 7 上,并且总是发生在早期版本的 IE 上。另一方面,对于上面的标记,如果为 li 元素设置 display: inline ,则 Quirks 模式下 IE 上的元素框之间没有空格。在标准模式和其他浏览器中,空白对应于一个空白,这被某些人视为符合标准。

    在某些浏览器中,表单的默认下边距为 1em 左右。 (在 IE 7 上,两种模式都有这样的边距。)这显然是为了延续 Web 浏览器在表单下方留出这么大间距的传统。如何去掉表单后的空行曾经是一个常见问题。

    默认垂直边距在某些情况下会被抑制,例如当 ap 元素作为 td 元素中的第一个元素出现时。这或多或少是浏览器中的传统行为,并且在 IE 7 的两种模式下都会发生(在 IE 8 上,仅在 Quirks 模式下)。如果相关元素在 CSS 中明确设置了垂直边距,则不会出现此问题。

    img 元素的工具提示效果基于某些旧式浏览器上的 alt 属性,包括怪异模式下的 IE 8,但标准模式下则不然。

    尊重换行机会的 wbr 标记。浏览器已广泛支持它,但 IE 8 已停止在“标准模式”下这样做。这是个坏消息,因为 标签是为网页上其他不可破坏的字符串建议换行机会的唯一有效方法。

    Mozilla 浏览器(如 Firefox 和 Seamonkey)有一些附加功能,记录在 quirk.css 文件中。例如,表格边框的默认颜色是灰色(与大多数其他浏览器一样),这与标准模式中使用表格的前景色相反。注意:并非该文件中的所有设置都适用于 Mozilla 的所有版本。

    某些 DOM 功能不可用。例如,在 Quirks 模式下,IE 9 无法识别 getElementsByClassName 方法(其他浏览器很好地支持该方法并包含在 HTML5 中)。

    所谓的 Window 对象命名访问,例如使用(在 JavaScript 中)window.foo、window['foo'] 或仅 foo 来引用 id="foo" 的元素,仅在 Quirks 模式下可行在某些版本的 Firefox 中。 (然而,在版本 15 中,它在两种模式下恢复了对这一旧功能的支持。)

    在 Firefox 中,document.all 集合(JavaScript 中)仅在 Quirks 模式下被识别。

    在 Firefox 中,在怪异模式下,即使指定了高度,没有行/行组的表的高度也为零

    在 Firefox 中,在 FRAMESET 列/行规范的怪异模式下,0* 被视为 1*

    以及一些 CSS 怪异:

    无哈希十六进制颜色怪癖

    无单位长度怪癖

    行高计算怪癖

    这些块忽略行高怪异

    百分比高度计算怪癖

    html 元素填充了视口的怪癖

    body元素填补了html元素的怪癖

    表格单元格宽度计算怪癖

    表格单元格现在包裹最小宽度计算怪癖

    折叠表的怪癖

    文本装饰不会传播到表格怪癖中

    表格继承了身体怪癖的颜色

    表格单元格高度框大小调整怪癖

    :active 和 :hover 怪癖

    参考

    Here is an aggregate of browser specific quirks mode behaviors:

    Some HTML5 features are not supported some versions of IE. E.g., IE 9 does not recognize the canvas element in Quirks Mode.

    The box model is incorrect (different from CSS spec­i­fi­ca­tions, though perhaps intuitively more natural). This means that the width and height properties specify the dimen­sions of the entire element box, including padding and border, and not just the element’s content. (There is a demo later in this document.)

    Dimensions of non-replaced inline elements (e.g., span elements by default) are affected by width and height properties (while by CSS specifications, they shall be ignored).

    Percentage heights for elements (e.g., <table height="100%"> in HTML or table { height: 100% } in CSS) are applied, using the available height as reference, even when the enclosing block has height: auto (the default). In Standards Mode, the height is determined by the require­ments of the content; but percentage heights work when the enclosing block has its height set to a specific value.

    The height of the body element is 100%, as opposite to being determined by its content. (If you want 100% height for body in standards mode, set html, body { height: 100% } in CSS.)

    Textarea widths are calculated differently. E.g., on IE 9, cols=5 makes the area 5 characters wide in Standards Mode but only 4 characters wide in Quirks Mode.

    Overflow is treated by expanding a box. When the content of an element does not fit into the dimensions specified for it (explicitly or implicitly), then overflow: visible (the default) means that the content overflows while the box dimensions are as specified. In Quirks Mode, the dimensions change; this can easily been seen e.g. if the box has a back­ground color or a border.

    Alt text is not always shown as a replacement for an image when the image is not shown. When the img element has dimensions smaller than needed for the text, e.g. as in <img src="x.png" alt="Some alt text" width="8" height="9"> when x.png does not exist. Firefox omits the text and shows a generic icon for a broken image only.

    The root element is the body element on IE in Quirks Mode. By the specifications, it is the html element. For example, setting a margin or width for body has no effect in Quirks Mode. As another example, IE has a vertical scrollbar by default, though it is inactive (dim) when there is nothing to scroll, and you can remove it (when it is not needed) in Quirks Mode by setting body { overflow: auto; }, but in Standards Mode, you need to add html { overflow: auto; } as well.

    A gray 2px page border appears by default on some versions of IE. It can in some cases be changed or removed by setting the border property of the html element (e.g., html { border: 0; }).

    The id attribute values are matched case-insensitively, so that e.g. the CSS selector #foo matches an element with id="Foo". By the specifications, the match must be case-sensitive: #foo matches only an element with id="foo".

    Padding for an image is ignored when set in CSS for an img element or an input type="image" element.
    Default horizontal margin for a floated image is three pixels (instead of zero). That is, if the img element has the attribute align="left" or align="right" or if the CSS rule float: left or float: right applies to it, the browser behaves as if the img element had the attribute hspace="3" (or its margin-left and margin-right properties had the value 3px). This applies to IE; on other browsers, Quirks Mode may cause the extra margin on one side of the image only, and its width can be 2 pixels instead of 3.

    Vertical alignment of an image is under certain conditions to the bottom of the enclosing box, not to the baseline of text. This happens when the image is the only content within an element, typically a table cell. This means that e.g. an image in a table cell is by default at the bottom of the cell in Quirks Mode (which is often what the author wants), whereas in Standards Mode there is a few pixels spacing below the image (unless one sets e.g. vertical-align: bottom for the img element).

    Text rendering on IE 9 does not use several new features in the browser, when in Quirks Mode. This may e.g. make the width needed by some text different in different modes, thereby affecting the division of text into lines. See Microsoft’s About Text Rendering in Windows Internet Explorer 9.

    Centering a block in CSS using e.g. margin: 0 auto does not work. Note: On IE up to IE 7, setting align="center" in HTML or text-align: center in CSS for a div incorrectly centers any inner block element as a whole, even in Standards Mode. On IE 8, this happens in Quirks Mode only,

    Font properties are not inherited from body or other enclosing elements into tables. This happens especially for font-size but may happen for font face, color, and line height as well. For example, if you set body { font-family: Arial }, it is possible that the font in table cells remains the browser default.

    In a font size setting for a table cell, a percentage value is interpreted as relative to the browser’s basic font size, not to the font size that applies to the enclosing element (the table row) by CSS specifications.

    Font size keywords are interpreted incorrectly so that medium is larger than the browser’s basic font size and small equals that basic font size. Similarly, the entire scale of keywords, xx-small, x-small, small, large, x-large, xx-large is interpreted systematically wrong: each value is interpreted as one step larger than it should.

    Font rendering is different on IE 9. In Standards Mode, it applies more advanced technologies. This causes small difference that may matter, affecting the width of text among other things. See About Text Rendering in Windows Internet Explorer 9.

    Border width keywords thin, medium, and thick have different meanings on IE. For example, thin is 1px in Standards Mode, 2px in Quirks Mode.

    The bordercolor attribute, which is nonstandard but widely supported, is treated differently in Quirks Mode vs. Standards mode by IE. The colors appear differently, though this seems to be caused by an effect on border style.

    Radio buttons and checkboxes have total dimensions 20 by 20 pixels in IE in Quirks Mode, as opposite to 13 by 13 in Standards Mode and in other browsers. The size of the graphic button or box is the same, but the spacing around it is different. It is an integral part of the element rendering, not affected by padding or margin properties, but affected by width and height properties.

    Malformed property values are often interpreted on the basis of guesswork, e.g. margin: 10 as margin: 10px and color: ffffff as color: #ffffff. This violates mandatory error processing rules in CSS: a rule using syntactically incorrect value shall be ignored.

    Incorrect property values that are not recognized by a browser may cause an earlier setting for the property to be ignored. For example, setting h1 { color: red; color: nonsense; } may cause the entire rule to be ignored; by the specifications, the correct setting color: red shall prevail. Such duplicate settings are often used in an attempt to provide a fallback when using advanced CSS values, and this often fails in Quirks Mode, because the fallback gets ignored. The problem only appears within a CSS rule, so dividing a rule into two parts would help. For example, instead of h1 { color: #ccc; color: rgba(255, 255, 255, 0.7); } you would use h1 { color: #ccc; } h1 { color: rgba(255, 255, 255, 0.7); }

    Case of letters is treated as insignificant in class and identifier selectors in CSS. Thus, the selector .foo matches an element with class="Foo" or class="FOO". By CSS specifications, the case is significant in these contexts.
    Malformed names are accepted in class and identifier selectors. Specifically, names starting with a period or a number sign (e.g. in selectors .123a and #42) are accepted.

    The declaration white-space: pre is ignored.

    Fixed positioning is not supported: the declaration position: fixed is treated as position: static (on IE 7).

    Many standard (CSS 2.1) additions to CSS support (such as the max-width property and attribute selectors) in IE 7 are not in use Quirks Mode. That is, there are many CSS features that were not supported in IE 6 and are supported in IE 7, but only in Standards Mode. See Microsoft’s blog entry Details on our CSS changes for IE7.

    Some nonstandard CSS features (features not in CSS 2.1) such as scrollbar properties are recognized by some versions of IE and Opera in Quirks Mode but ignored in Standards Mode. On IE 8 and newer, this also applies to the expression() construct.

    Setting rowspan=0 or colspan=0 is ignored in many browsers, even if they support these settings in Standards Mode. (They mean that the cell spans the rest of the row or column. This was implemented in browsers relatively lately.)

    Tag soup parsing. For example, if a document contains the markup
    <p>text<table>...</table>
    then e.g. Firefox treats, in Quirks Mode, the p element as containing the table element. In Standards Mode, the start tag of table implicitly closes the open p element. The difference can be seen if you e.g. set a border on the p element. Similarly, for example, Firefox accepts a ul element inside a font element. IE always works by wrong rules in such issues, even in Standards Mode, but standards-conforming behavior can be achieved by using valid markup and always using explicit end tags like </p> even when they are formally optional.

    Different tag soup processing. An opposite issue, more or less, is that in Quirks Mode, markup like <font color=red><table>...</table></font> does not affect the color of text inside the table. In Standards Mode, it does – even though the markup is nonstandard (invalid according to all HTML specifications)!

    White space between elements can be significant. For example, let’s say you have a list of links. Typically you would write the markup with line breaks between the list items, the li elements (that is, between </li> and <li> tags):

        <ul>
        <li><a ...>...</a></li>
        <li><a ...>...</a></li>
        ...
        </ul>
    

    However, if you set display: block and a border for the link elements, you may wind up with vertical gaps (empty lines) between the boxes. This happens on IE 7 in Quirks Mode, and always on previous versions of IE. On the other hand, for the markup above, if you set display: inline for the li elements, then there is no white space between the element boxes on IE in Quirks Mode. In Standards Mode, and on other browsers, there is white space corresponding to one blank, and this is regarded as standards-conforming by some.

    Forms have a default bottom margin of 1em or so in some browsers. (On IE 7, there is such a margin in both modes.) This is apparently meant to continue the tradition of web browsers to leave that much spacing below a form. It used to be a frequently asked question how to get rid of the empty line after a form.

    Default vertical margins are suppressed in some contexts, e.g. when a p element appears as the first element in a td element. This is more or less traditional behavior in browsers and takes place on IE 7 in both modes (on IE 8, in Quirks Mode only). The issue does not arise if the relevant elements have their vertical margins set explicitly in CSS.

    Tooltip effects for img elements are based on alt attributes on some old-style browsers, including IE 8 in Quirks Mode but not in Standards Mode.

    The wbr markup for a line breaking opportunity is honored. Browsers have widely supported it, but IE 8 has stopped doing so in “standards mode.” This is bad news, since <wbr> tags have been the only effective way to suggest line break opportunities for otherwise unbreakable strings on web pages.

    Mozilla browsers (like Firefox and Seamonkey) have some additional features, documented in the quirk.css file. For example, the default color for table borders is gray (as in most other browsers), as opposite to using the foreground color of the table as in Standards Mode. Note: Not all the settings in that file apply to all versions of Mozilla.

    Some DOM features are not available. For example, in Quirks Mode, IE 9 does not recognize the method getElementsByClassName (which is well supported by other browsers and included in HTML5).

    The so-called named access on the Window object such as using (in JavaScript) window.foo, window['foo'] or just foo to refer to the element with id="foo" is possible in Quirks Mode only in some versions of Firefox. (In version 15, it however restored support to this legacy feature in both modes.)

    In Firefox, the document.all collection (in JavaScript) is recognized in Quirks Mode only.

    In Firefox, in quirks mode tables with no rows/rowgroups have zero height even when a height is specified

    In Firefox, in quirks mode in a FRAMESET cols/rows specification 0* is treated as 1*

    And some CSS quirks:

    The hashless hex color quirk

    The unitless length quirk

    The line height calculation quirk

    The blocks ignore line-height quirk

    The percentage height calculation quirk

    The html element fills the viewport quirk

    The body element fills the html element quirk

    The table cell width calculation quirk

    The table cell nowrap minimum width calculation quirk

    The collapsing table quirk

    The text decoration doesn’t propagate into tables quirk

    The tables inherit color from body quirk

    The table cell height box sizing quirk

    The :active and :hover quirk

    References

    ~没有更多了~
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文