IT Band of Brothers HTML5 syntax of the HTML language tutorial 1

5ad10fbc88e84c32b353feb8d2253eec.jpg

 

HTML is the language of the text type, and any one other language, compared syntax is the simplest. However, when writing HTML file, you must follow the rules of grammar of HTML. A full HTML document by the headings, paragraphs, lists, tables, text, i.e., consisting of various embedded objects, these objects are known logically consistent elements, HTML tags used to describe this element. In fact, the entire HTML file is a text file composed by the elements and labels can be directly interpreted by the browser execution, they show wonderful parse web pages, without having to compile. When the web browser is opened, the browser reads the HTML code pages, analyze the grammatical structure, then to display web content according to the result of interpretation. For this reason, the page display speed has a great relationship with the quality of web page code, stay lean and efficient HTML source code is very important. Also you can open a browser page by "View Source" command to view web pages in HTML code.

 

HTML tags and elements

d356565126414ba3adb42b647e59da18.png

在HTML文件中是以标签来标记网页结构和显示内容资料的。以“<标签名>”表示标签开始,以“</标签名>”结束。大部分标签都是成对出现的,成对的标签也称为容器。在一对标签中也可以嵌套其他标签。一个HTML标签及标签中嵌套的内容就是网页中的一个“HTML元素”。例如,在<body>和</body>之间的是主体元素;又如,<title>和</title>是标签,而<title>itxdl</title>则是标题元素。也有极少的标签不需要与之配对的结束标签,也称为空标签,即空元素,例如<br>、<hr>等。</body>和</title>关闭它们各自的标签。所有的HTML标签都要关闭。尽管老版本的HTML允许某些标签不关闭,但最新的标准要求所有的标签都要关闭。无论如何,闭合标签是一个好习惯。并不是所有的标签都像<html></html>一样关闭,有的标签不用绕在内容外面,它们是自关闭的。比如断行的标签是这样的:<br />。需要记住的是,所有的标签都必须关闭,以及大部分的内容都在标签之间,它们的格式是这样的:起始标签-内容-闭合标签。如图2.6所示为一个HTML区块元素。

 

HTML语法不区分字母大小写

HTML标签名和属性都是不区分字母大小写的,例如<body>、<BODY>或<Body>都是定义相同的标记,但推荐全部使用小写字母书写。在HTML5中也不区分关键字大小写,引号也不区分是单引号还是双引号。

 

HTML标签属性

Additional attribute information is provided by HTML element, always come in the form "name = value" in the HTML tags, for example <tag name = "value">. Most HTML tags have their own attributes, write in the start tag for further change the effect of the display. If there are multiple attributes, then separated by spaces, no order among the attributes, and each attribute in the HTML tags are optional, and can also be omitted, the default value. Value of the property may be in double quotes in English ( "") or single quotation marks ( ''), quotes may not be used, it is recommended to use double quotes (W3C specification). For example, <body bgcolor = "black" color = '# ffffff "> tag uses two attributes, namely the <body> tag content background is set to black, the text is set to white.

Guess you like

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