什么<!doctype html>做? [英] What does <!doctype html> do?

查看:178
本文介绍了什么<!doctype html>做?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个标记是干什么的?



<!doctype html>



我能看到的是,在这个标签的顶部,我的html以另一种方式运行而不是没有。
我怎么知道我是否需要这个标签?

它是规范中定义的HTML:


8.1.1 DOCTYPE

DOCTYPE是必需的序言。

由于遗留原因,DOCTYPE是必需的。省略时,浏览器倾向于使用与某些规范不兼容的不同渲染模式。在文档中包含DOCTYPE可确保浏览器尽力尝试遵守相关规范。 b $ b

编辑添加:


这个安全带是做什么的?





我能看到的是的,这个安全带上,我的汽车行为方式与没有。我怎么知道我是否需要这个安全带?


您不知道在出现问题之前您是否需要它,没有它。


What does this tag do?

<!doctype html>

What I can see is that with this tag on top my html behaves in another way than without. How do I know if I need this tag?

解决方案

It's an integral part of HTML as defined in the specification:

8.1.1 The DOCTYPE

A DOCTYPE is a required preamble.

DOCTYPEs are required for legacy reasons. When omitted, browsers tend to use a different rendering mode that is incompatible with some specifications. Including the DOCTYPE in a document ensures that the browser makes a best-effort attempt at following the relevant specifications.


Edit to add:

What does this seatbelt do?

What I can see is that, with this seatbelt on, my car behaves the same way as without. How do I know if I need this seatbelt?

You wont know if you'll need it until something goes wrong and you don't have it.

这篇关于什么&lt;!doctype html&gt;做?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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