The main structure IT Band of Brothers HTML5 tutorial HTML file

374eb9579a4a4a73be3957c6b09ef133.jpg

 

Each page is a separate HTML document, each of the main structure of an HTML document and both are the same, but in such a document can only be declared once the main structure. The main structure of an HTML document can simply be divided into two parts, one is the definition of document types, HTML5 in the previous version is much simpler than the document type declaration, only 15 characters can handle that. The other part is the structural frame tag defines the body of the document, because the label is not discharged any, need to have some nested rule. Like a tree from the roots to the trunk, such a structure twigs, leaves growing, but can not grow roots to the leaves, the structure of an HTML document, too, the entire document as a whole, the outermost layer of the label is only one, the second layer has two labels, a configuration is fixed, the third layer can be arbitrarily nested later, as an inverted tree structure. as the picture shows:

6a43228d26b944fe9f2cebfcf059d1aa.png

HTML document tree diagram

 

In an HTML document, not only actively look to find each sub-layer elements through the root node, as long as starting from any element node, other elements can be found through the node relationship.

 

HTML document type definition of a new way

HTML5 in the preparation of the document, asked to specify the type of document to ensure that the browser can render in HTML5 standard mode. Deliberately do not use the version in HTML5 declaration, a document will apply to all versions of HTML, very simple, declare as follows:

<! DOCTYPE html> <-! Tag statement is not over, not case sensitive -> 

             

Declaration must be the first line of HTML documents located in <html> tag before. HTML tags are not otherwise stated, it is an indication of a Web browser instructions as to which version of the page using HTML be written. In the HTML 4.01, <! DOCTYPE> declaration referenced DTD, since HTML 4.01 based on SGML, DTD specifies the rules markup language, so the browser to render content correctly. HTML5 is not based on SGML, so no reference DTD. This is the only addition, there is in HTML5 HTML 4.01 Three in a statement <DOCTYPE!>:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"

"http://www.w3.org/TR/html4/strict.dtd">   <!--  第一种:HTML 4.01 Strict   -->

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

"http://www.w3.org/TR/html4/loose.dtd">   <!--  第二种HTML 4.01 Transitional  -->

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"

"http://www.w3.org/TR/html4/frameset.dtd">    <!--  第三种HTML 4.01 Frameset   --> 

以前的版本中不光有上面几个,基于XHTML不同版本还有好多种,所以在HTML5时代,你不需要使用上面这个既麻烦又难记的文档类型了,就用新的HTML5文档类型吧,简单明了,这就是HTML5的进步。

提示

请始终向HTML文档添加 <!DOCTYPE> 声明,这样浏览器才能获知文档类型。

 

HTML文档的主体标签

一个HTML文档的基本格式需要包含以下几个全局架构元素标签,并将HTML代码分为三部分编写,它们可以被看作文档的框架。如下所示:

15ecc7c7408e4c38829f12ae0103d652.png

 

本例在网页文件中声明的这几对标签,在每个网页文档中都是唯一的,head标签和body标签需要嵌套在HTML标签中。

Ø first part: <html> and </ html> tag is the outermost layer of the web document, HTML files of all the contents should be between the two marks. <Html> tag tells the browser starting point of this HTML file, </ html> tag tells the browser that this is the end point of the HTML file.

Ø second part: the text located between the <head> and </ head> tag is header information on the <html> using top elements, header information is not displayed in the browser window. Some statements include basic description of the current page, for some public property description and title documents of the entire file, such as the title page of the statement and keywords. Each <head> element should contain a <title> element to indicate the title of the document, it may be in any order, a <base>, <object>, <link>, <style>, <script>, <meta> element any combination.

Ø Part III: <body> tag is the tag body of the HTML file, text between the tags is text content, the user can be seen in the main browser window. For example, text, images, links, forms, and so need to be declared in this tag. It appears after the element <head> element.

Of course, in the new HTML5 standards, these subject tags can be omitted, the browser will not go wrong inclusion of this point, which is the use of flexible HTML5 place. But I believe that in the preparation of HTML5 code is not necessary to omit them, to maintain the structural integrity of the HTML document will make more readable.

Guess you like

Origin www.cnblogs.com/itxdl/p/11590390.html