声明HTML5 Doctype的正确方法是什么? [英] What is the correct way to declare an HTML5 Doctype.

查看:1000
本文介绍了声明HTML5 Doctype的正确方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用HTML5创建时使用开始标记的正确方法是什么?

What is the correct way to use start tag when creating with HTML5

IE:HTML 4 Strict是这样的

IE: HTML 4 Strict is like this

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


推荐答案

标准已被简化,因为之前的文档类型也是如此神秘。新的文档类型只是<!DOCTYPE html> 。您可能想知道为什么它不是<!DOCTYPE html5> ,但它仅仅是因为它只是HTML标准的更新而不是新版本的任何东西。您可以在下面看到,所有元素现在都可以拥有语言属性。

The standard has been simplified because the previous doctypes were too cryptic. The new doctype is simply <!DOCTYPE html> . You may wonder why it is not <!DOCTYPE html5> but it is simply because it is just an update to the standard of HTML and not a new version of anything. As you can see below, all elements can now have a language attribute.


< html> 元素是文档的根元素。每个文档
必须以该元素开头,并且它必须包含< head>
< body> 元素

The <html> element is the root element of a document. Every document must begin with this element, and it must contain both the <head> and <body> elements.

使用lang属性在这个元素上指定
文档的主要语言被认为是一种很好的做法。 / p>

It is considered good practice to specify the primary language of the document on this element using the lang attribute.



<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title>Hello World</title>
    </head>
    <body>
        <h1>Hello World</h1>
        <p>
            Jamie was here.
        </p>
    </body>
</html>

更多信息: https://dev.w3.org/html5/html-author/#doctype-declaration

这篇关于声明HTML5 Doctype的正确方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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