basic html5
html4 doctype
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
HTML5 doctype:
<!DOCTYPE html>
In this example page, the root element looks like this:
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
The first thing to discuss is the xmlns attribute. This is a vestige of XHTML 1.0.
It says that elements in this page are in the XHTML namespace, http://www.w3.org/1999/xhtml.
But elements in HTML5 are always in this namespace, so you no longer need to declare it explicitly.
Your HTML5 page will work exactly the same in all browsers, whether this attribute is present or not.
Dropping the xmlns attribute leaves us with this root element:
<html lang="en" xml:lang="en">
Why two attributes for the same thing? Again, this is a vestige of XHTML. Only the lang attribute has any effect in HTML5.
You can keep the xml:lang attribute if you like, but if you do, you need to ensure that it contains the same value as the lang attribute.
Are you ready to drop it? It’s OK, just let it go. Going, going… gone! That leaves us with this root element:
<html lang="en">
Example page:
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>My Weblog</title>
<link rel="stylesheet" type="text/css" href="style-original.css" />
<link rel="alternate" type="application/atom+xml"
title="My Weblog feed"
href="/feed/" />
<link rel="search" type="application/opensearchdescription+xml"
title="My Weblog search"
href="opensearch.xml" />
<link rel="shortcut icon" href="/favicon.ico" />
</head>
对于
<META HTTP-EQUIV="Content-Type" CONTENT="text/html;" charset="ISO-8859-1">
可以简化成
<meta charset="utf-8" />
对于
<link rel="stylesheet" href="style-original.css" type="text/css" />
可以简化成
<link rel="stylesheet" href="style-original.css" />
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。