什么是怪异模式?

发布于 2024-08-10 14:47:29 字数 50 浏览 10 评论 0 原文

在很多关于设计的文章中,都提到了怪异模式。 有人对这件事有纯文本和发展前景的想法吗?

In a lot of articles about design, quirks mode is mentioned.
Anybody have an idea about this thing in plain text and in a development prospective?

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

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

发布评论

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

评论(6

‖放下 2024-08-17 14:47:29

你可以在这个链接中阅读

http://en.wikipedia.org/wiki/Quirks_mode

http://www.quirksmode.org/css/quirksmode.html

http://www.cs.tut.fi/~jkorpela/quirks-mode.html

现代浏览器通常尝试
根据以下内容渲染 HTML 内容
W3C 建议。然而,为了
提供与旧版网络的兼容性
页面,并提供额外的
“直观”的功能,全部
浏览器支持替代方案
“怪癖模式”。

然而,Quirks 模式并不是一种
标准。任意页面的渲染
不同浏览器中的怪异模式可能
有所不同。只要有可能,它就是
更好地遵守 W3C 标准
并尽量避免依赖于任何
过去或现在的浏览器怪癖。

一般情况下,怪癖模式都是开启的
当没有正确的 DOCTYPE 时
声明,并在存在时关闭
是一个 DOCTYPE 定义。然而,
无效的 HTML - 关于
选择 DOCTYPE - 也会导致
浏览器切换到怪异模式。

有关不同内容的更多信息
不同浏览器中的怪异模式可以
可以在 QuirksMode.org

找到

you can read in this links
:

http://en.wikipedia.org/wiki/Quirks_mode

http://www.quirksmode.org/css/quirksmode.html

http://www.cs.tut.fi/~jkorpela/quirks-mode.html

Modern browsers generally try to
render HTML content according to the
W3C recommendations. However, to
provide compatibility with older web
pages, and to provide additional
"intuitive" functionality, all
browsers support an alternative
"quirks mode".

Quirks mode is not, however, a
standard. The rendering of any page in
quirks mode in different browsers may
be different. Whenever possible, it is
better to adhere to the W3C standards
and try and avoid depending on any
past or present browser quirks.

Generally, quirks mode is turned on
when there is no correct DOCTYPE
declaration, and turned off when there
is a DOCTYPE definition. However,
invalid HTML - with respect to the
chosen DOCTYPE - can also cause the
browser to switch to quirks mode.

More information on the different
quirks modes in different browsers can
be found at QuirksMode.org

红衣飘飘貌似仙 2024-08-17 14:47:29

Quirks 模式意味着您的页面在没有声明文档类型的情况下运行,文档类型在页面的最顶部定义,它表示浏览器应如何读取 HTML。这是 StackOverflow 的文档类型:

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

w3.org 指定 Web 标准和文档类型,因为 Stack Overflow 使用此文档类型,所以它必须遵守 该文档类型的规范

这是 HTML 4.01 严格 DTD,
排除表示属性
以及 W3C 期望分阶段实施的元素
作为对样式表的支持
成熟。作者应该使用严格的
如果可能的话,DTD,但可以使用
支持时的过渡 DTD
表示属性和元素是
必填。

Quirks mode means your page is running without a document type declared, the document type is defined at the very top of a page and it denotes how the browser should read the HTML. This is StackOverflow's doctype:

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

w3.org specifies web standards and document types, because Stack Overflow uses this doctype it must adhere to the specification of that doctype.

This is HTML 4.01 Strict DTD, which
excludes the presentation attributes
and elements that W3C expects to phase
out as support for style sheets
matures. Authors should use the Strict
DTD when possible, but may use the
Transitional DTD when support for
presentation attribute and elements is
required.

妥活 2024-08-17 14:47:29

在过去,当 Web 浏览器没有完整/正确的 CSS 实现时,开发人员依靠这些特性来使他们的页面正确呈现。然而,随着浏览器变得更加符合标准,这些页面不再正确呈现,因为它们基本上是为不同类型的 CSS 编写的。这就是怪癖模式的用武之地,因为它处理为这些损坏的 CSS 实现编写的页面。

因此,在 2009 年,您实际上不需要担心怪异模式,除非您正在处理较旧的 CSS 或较旧的浏览器。只需按照当前的 Web 标准编写 CSS 即可。

In past days when web browsers did not have full/correct implementations of CSS, developers relied on these idiosyncrasies to make their pages render properly. However, as browsers became more standards-compliant, these pages no longer rendered correctly, as they were written for what bascially was a different type of CSS. This is where quirks mode comes in, as it handles pages written for these broken CSS implementations.

So in 2009, you don't really need to worry about quirks mode unless you're handling older CSS, or older browsers. Just write your CSS to current web standards, and you be OK.

吃不饱 2024-08-17 14:47:29

怪异模式也称为兼容模式 - 意味着您的页面在没有声明文档类型的情况下运行(这是老派,所以很可能不再需要)
怪异模式的全部意义在于它是 IE5 的兼容模式。这意味着除了改变布局模式之外,它还关闭了自IE5以来发明的大部分浏览器功能。
在怪异模式下,网络浏览器尝试根据“最佳猜测”来呈现/制作代码,这包括对可能非标准或格式不良的代码的慷慨解释。
如果您不声明文档类型,浏览器将不得不猜测您正在运行的 HTML/CSS 版本
Quirks 模式使旧的 HTML 文档仍然可以“工作”
它是网络浏览器用来保持与旧网页的向后兼容性的一种技术。

如果您编写正确的文档类型,则会触发标准模式而不是怪异模式
Netscape 4 等较旧的浏览器永久锁定在怪异模式

怪异模式使您的浏览器的行为就像旧版浏览器一样

。在这种模式下,浏览器不守法。它在此模式下接受任何格式错误的标记,并且对语法、标签和元素不严格
基本上意味着即使代码编写不正确,它也会接受您的代码。

在怪异模式下,浏览器的行为就像网络早期的行为一样。这样做是为了防止旧网站在新浏览器中破坏太多。

编写在所有浏览器中看起来都相同的页面是很困难的。事实上,这是不可能的。许多浏览器都是用只有它们才能处理的特殊功能编写的。或者他们有特殊的处理方式与其他浏览器处理方式不同
使用非标准将导致每个浏览器都以怪异模式运行。但并非所有浏览器在怪异模式下的行为都相同,每个浏览器都会恢复到自己独特的渲染引擎,这就是为什么很难在不同的浏览器中获得看起来相似的页面。

另外,您的所有 html5 css 都将无法工作,因为它不兼容

Quirks 模式支持 IE6 的 JavaScript 功能,它类似于 IE5 的行为以及 IE6、IE7 和 IE8 的 Quirks 模式行为。

在怪异模式下,document.body(body 元素)是根元素,在标准模式下,它是 html 元素(document.documentElement)。
怪异模式是针对浏览器的旧规则的,他们这样做是为了让万维网出现之前和 HTML5 发明之前编写的旧网站不会被破坏。所以怪异模式只是为了支持那些CSS特性不正确的网站。所以现在开发商有一个选择。使用标准(当今的浏览器)或适用于旧版浏览器和网站的怪异模式。在怪异模式下,我们今天拥有的许多 CSS/HTML 功能无法正常工作。

Quirks mode also known as Compatibility Mode - means your page is running without a document type declared(this is old school, so this is most likely not needed anymore)
The whole point of quirks mode is that it's a compatibility mode for IE5. This means that in addition to changing the layout mode, it also switches off most of the browser features that have been invented since IE5.
In quirks mode, the web browser attempts to render/make code based on a ‘best-guess’, this includes a generous interpretation of code that may be non-standard or poorly-formed.
if you don't declare a doctype, the browser will have to guess what version of HTML/CSS you're running
Quirks mode enables older HTML documents to still ‘work
its a technique used by web browsers to maintain backward compatibility with older webpages.

if you write a correct doctype, that will trigger standard mode and not Quirks mode
older browsers like Netscape 4, are permanently locked in quirks mode

Quirks mode enables your browser to behave as if it is an older browser

It's a mode in which the browser is not law-abiding. It accepts any malformed mark-up in this mode and is not strict with syntax, tags and elements
basically means it'll accept your code even if its not-correctly written

In quirks mode, browsers behave as they did in the early days of the web. This was done to prevent old sites from breaking too much in new browsers.

there is a difficulty in writing a page that looks the same in all browsers. In point of fact, that's impossible. Many browsers were written with special features that only they could handle. Or they have special ways of handling things that are different from how other browsers handle them
Using a non-standard will cause every browser to run in quirks mode. But not all browsers behave the same in quirks mode, each browser reverts to its own unique rendering engine which is why it's very difficult to get a page looking alike in different browsers.

also all your html5 css won't work because it won't be compatible

Quirks mode supports the JavaScript functionality of IE6, It is similar to the behavior of IE5 and the Quirks mode behavior of IE6, IE7 and IE8.

in quirks mode, document.body (the body-element) is the root element and in standard mode it's the html-element (document.documentElement).
quirks mode is for the old rules of browsers, they made it so that old websites that were written before the world wide web came and before HTML5 was invented don't break. so quirks mode is just to support those websites that had incorrect CSS features. so now developers had a choice. go with standard (todays browsers) or quirks mode for older browsers and websites. in quirks mode a lot of CSS/HTML features that we have today don't work correctly.

调妓 2024-08-17 14:47:29

除了其他答案之外,还可以通过

javascript:window.alert('You are in ' + (document.compatMode==='CSS1Compat'?'Standards':'Quirks') + ' mode.')

检查模式

In addition to other answers, the mode can be checked by

javascript:window.alert('You are in ' + (document.compatMode==='CSS1Compat'?'Standards':'Quirks') + ' mode.')

尐偏执 2024-08-17 14:47:29

http://www.motive.co.nz/glossary/quirks-mode。 php

  • 在怪异模式下,Web 浏览器尝试根据“最佳猜测”呈现代码,这包括对可能非标准或格式不良的代码的慷慨解释。
  • 如果网页没有文档类型声明或文档类型声明不完整(例如,如果省略了 DTD 的 URI),Web 浏览器可能会切换到怪异模式。
  • Quirks 模式使旧的 HTML 文档仍然可以“工作”,并且当已知所使用的代码不符合当代技术标准时(并且没有意图/预算来修改遗留内容时),应该触发 Quirks 模式。

http://www.motive.co.nz/glossary/quirks-mode.php

  • In quirks mode, the web browser attempts to render code based on a ‘best-guess’, this includes a generous interpretation of code that may be non-standard or poorly-formed.
  • A web browser may switch to quirks mode if a webpage has no document type declaration or has an incomplete document type declaration (for example, if the URI to the DTD is omitted).
  • Quirks mode enables older HTML documents to still ‘work’, and should be triggered when the code that has been used is known to fail contemporary technical standards (and when there is no intention/budget to revise legacy content).
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文