适当的 DTD 可以解决这个问题吗?

发布于 2024-11-17 07:22:20 字数 662 浏览 1 评论 0原文

我遇到了跨浏览器兼容性问题,并找到了一个名为“浏览器兼容性检测器”的 Chrome 插件。它建议添加 DTD 以在标准模式下呈现页面。

我添加了这一点:

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

它带来了新问题并修复了其他问题,但至少现在所有浏览器的工作方式都差不多。

然而,它仍然建议为另一个问题添加 DTD:

In IE6 IE7(Q) IE8(Q), the container will be enlarged when its 'width' or 'height' is not big enough to hold all its contents
Content box's size in Chrome: 1366 * 0, in IE: 1366 * 653.
Suggestion: Use a DTD that makes the page rendered in Standards Mode, so that only IE6(S) will be affected.

我应该添加什么类型的文档类型?直到 5 分钟前我什至不知道它们的存在,所以我不知道该写什么。

I was having problems with cross-browser compatibility and found out a plugin called "Browser Compatibilty Detector" for Chrome. It recommended adding a DTD to renders the page in standards mode.

I added this:

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

It brought new issues and fixed others but at least now all browsers are working kinda the same.

However it's still recommending adding a DTD for another issue:

In IE6 IE7(Q) IE8(Q), the container will be enlarged when its 'width' or 'height' is not big enough to hold all its contents
Content box's size in Chrome: 1366 * 0, in IE: 1366 * 653.
Suggestion: Use a DTD that makes the page rendered in Standards Mode, so that only IE6(S) will be affected.

What type of doctype should I add? I didn't even know they existed until 5 minutes ago so I have no idea what to write.

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

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

发布评论

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

评论(2

坏尐絯 2024-11-24 07:22:20

我建议您仅添加 HTML5 docytype

以便您的代码将来友好,然后开始查明并修复出现的跨浏览器问题。

另外,如果您不需要支持 IE6 和 IE7 等旧版浏览器,那么您可以开始忽略它们。检查你的统计数据,看看支持是否值得。

I suggest you add the HTML5 docytype only

<!DOCTYPE html>

so that your code will be future friendly AND then start pinpointing and fixing the cross-browser issues that crop up.

Also, if you do not need to be supporting legacy browsers like IE6 and IE7, then you can start to ignore them. Check you stats to see if support is even merited.

太阳哥哥 2024-11-24 07:22:20

最初是一个 SGML 指令,它定义(直接或通过引用)文档的语言及其可能的结构。如今,在讨论它在浏览器中激活的渲染/解析模式时可能最常提到它。

http://hsivonen.iki.fi/doctype/

这是一篇关于不同 doctype 声明的总体不错的文章对于 HTML 文档。它有一些关于不同模式的背景信息和一个表示什么文档类型激活什么模式的表格。一般来说,最佳实践是使用与您的 HTML/XHTML 版本匹配(或与您的版本兼容)的文档类型声明并触发浏览器中的标准模式。

<!DOCTYPE ... > was originally an SGML directive that defined (directly or by reference) the language of the document and its possible structure. Nowadays it is probably most often mentioned in discussions on what rendering/parsing mode it activates in the browser.

http://hsivonen.iki.fi/doctype/

That is a generally nice article on different doctype declarations for HTML documents. It has some background information about different modes and a table denoting what mode is activated by what doctype. Generally the best practice is to use a doctype declaration that matches your HTML/XHTML version (or one compatible with yours) and triggers the standards mode in browsers.

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