我可以在代码中间放置Doctype吗?

时间:2022-07-01 21:05:29

Hi this is my first time here, so thanks for any help/advice you can give!

嗨,这是我第一次来这里,所以感谢您提供的任何帮助/建议!

I started work somewhere that has a CMS and as such we work by templates. But these templates don't have Doctypes delcared at the top (And we're not allowed to change that :( ) and so it throws anything we develop into Quirks mode when it's viewed in IE. It means front-end coding is "very" difficult to cope with.

我开始在有CMS的地方工作,因此我们通过模板工作。但是这些模板没有顶部显示的Doctypes(并且我们不允许更改它:()因此它会在IE中查看时将我们开发的任何内容抛出到Quirks模式。这意味着前端编码“非常” “很难应付。

So my question is, can I cheat somehow and put in a Doctype halfway through a document? Would iframing it in help? How can I make my code look at least similar in each browser?

所以我的问题是,我可以以某种方式作弊并在文档的中途输入Doctype吗?会不会有帮助?如何在每个浏览器中使我的代码看起来至少相似?

I know the best solution is to get a Doctype at the top of the document. But I don't have control of that, as of yet.

我知道最好的解决方案是在文档顶部获取Doctype。但是到目前为止我还没有控制。

Any advice is appreciated! :)

任何建议表示赞赏! :)

1 个解决方案

#1


1  

The <!DOCTYPE html> decoration must be at the top of any page and cannot be within <html> tag.

装饰必须位于任何页面的顶部,并且不能位于标记内。

Please see the article. http://www.w3.org/wiki/Doctypes_and_markup_styles. It should be declared somewhere, like in a head file or some such.

请看文章。 http://www.w3.org/wiki/Doctypes_and_markup_styles。它应该在某个地方声明,比如头文件或其他类似文件。

Edit: Format + Added up to date relevant documentation.

编辑:格式+添加最新的相关文档。

#1


1  

The <!DOCTYPE html> decoration must be at the top of any page and cannot be within <html> tag.

装饰必须位于任何页面的顶部,并且不能位于标记内。

Please see the article. http://www.w3.org/wiki/Doctypes_and_markup_styles. It should be declared somewhere, like in a head file or some such.

请看文章。 http://www.w3.org/wiki/Doctypes_and_markup_styles。它应该在某个地方声明,比如头文件或其他类似文件。

Edit: Format + Added up to date relevant documentation.

编辑:格式+添加最新的相关文档。