请问我的HTML5的doctype必须在第一行? [英] Does my HTML5 doctype have to be on the VERY first line?

查看:273
本文介绍了请问我的HTML5的doctype必须在第一行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直想知道是否前的DOCTYPE问题,但我似乎空白无法找到网络上的任何明确的信息。人们说,不这样做,但我看不出什么效果,它很可能有,或者即使规范说一定是这样的。我无法弄清楚它是否触发在IE兼容模式或任何讨厌这样。

I've always wondered whether whitespace before a DOCTYPE matters, but I can't seem to find any definitive information on the web. People say not to do it, but I can't see what effect it's likely to have, or even if the spec says it must be like that. I can't figure out if it triggers compatibility mode in IE or anything annoying like that.

原因是,在我的(蹩脚asp.net)code,我更preFER写的:

The reason is, in my (crappy asp.net) code, I would much prefer to write:

<%@ Page language="c#" Codepage="65001" AutoEventWireup="true" %>
<%@ OutputCache Location="None" VaryByParam="none" %>
<!doctype html>

<%@ Page language="c#" Codepage="65001" AutoEventWireup="true" %><%@ OutputCache Location="None" VaryByParam="none" %><!doctype html>

由于第一个是整洁。但是,最上面的一个结果是在你的HTML渲染一些空行。

Because the first is neater. But the result of the top one is a few blank lines in your rendered html.

不是一个巨大的问题。如果它很重要,我只是一直在想:)

Not a huge issue. I've just always wondered if it matters :)

推荐答案

如果你想,官方的回答,请访问W3C的官方文件和阅读有关语法那里。

If you want the official answer, go to the W3C's official documents and read about the syntax there.

评论和空间可能是第一位的。

Comments and spaces may come first.

下面的链接:<一个href=\"http://www.w3.org/TR/html-markup/documents.html#conformant-documents\">http://www.w3.org/TR/html-markup/documents.html#conformant-documents.

这篇关于请问我的HTML5的doctype必须在第一行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆