Home  >  Article  >  Web Front-end  >  Detailed introduction to the basic format of HTML documents

Detailed introduction to the basic format of HTML documents

黄舟
黄舟Original
2017-04-24 10:12:433247browse

1. Basic format of HTML document:

<!DOCTYPE html>  //文档类型声明
<html lang=&#39;zh-cn&#39;>                  //表示HTML文档开始
<head>              //包含文档元数据开始
<meta charset=&#39;utf8&#39;>           //声明字符编码
<title>基本</title>     //设置文档标题
</head>     //包含文档元数据结束
<body>     //表示HTML文档内容
</body>     //表示HTML
<a href="http://wwww.baidu.com">百度</a>
</html>      //表示HTML文档结束

2. Document structure analysis:

1. Doctype

Document Type Declaration, also Called Doctype), it mainly tells the browser the type of document being viewed.

<!DOCTYPE html>  不区分大小写

2. HTML element

First of all, element means tag, and html element is html tag. The html element is the element at the beginning of the document and at the end of the document. It is a double tag that echoes the beginning and the end. The html element has an attribute and value

lang='zh-cn', which means that the document language is Simplified Chinese

<html>   如果为英文则,lang="en"

3. Head element

is used to contain metadata content. Metadata includes: 2cdf5bf648cf2f33323966d7f58a7f3f, e8e496c15ba93d81f6ea4fe5f55a2244, da581d5a9873ed3d35632116ab586a49, 3f1c4e4b6b16bbbd69b2ee476dc4f83a, c9ccee2e6ea535a969eb3f532ad9fe89, b2386ffb911b14667cb8f0f91ea547a7. These contents are used by the browser to provide information, such as link providing CSS information. script provides JavaScript information, title provides page title, etc.

<head>...</head>   //这些信息在页面不可见

4. meta element

This element is used to provide information about the document. In fact, the structure has an attribute: charset='utf8'. Tells the browser what encoding the page uses. Under normal circumstances, use utf8. Of course, the file is also saved in utf8, and the browser also sets utf8 to display Chinese correctly.

<meta charset=&#39;utf-8&#39;>

5. Title element

This element is very simple. As the name suggests: set the title in the upper left corner of the browser

<title>标题</title>

6. Body element

is used to The element that contains the content of the document, which is the visible area of ​​the browser. All visible content should be added here.

<body>...</body>

7. The a element

is a hyperlink, which will be discussed in detail later.

<a href=&#39;http://www.baidu.com&#39;>百度</a>

3. Discussion of element tags:

HTML is a markup language. We have discussed the structure just now in detail. Here, we will analyze the following "marks", or How is the label formed?

1. Element

An element is a set of tags that tell the browser how to process some content. Each element has a keyword, such as 6c04bd5ca3fcae76e30b72ad730ca86d, b2386ffb911b14667cb8f0f91ea547a7, e8e496c15ba93d81f6ea4fe5f55a2244 are all elements. Different label names represent different meanings. Later, paragraph tags, text tags, link tags, image tags, etc. will be involved.

Elements

are generally divided into two types: single label (empty element) and double label. But tags are usually used to declare or insert an element. For example, use e8e496c15ba93d81f6ea4fe5f55a2244 to declare character encoding. Use 62c09581e8b6314bd76391014da14c50 to insert pictures. Double tags are generally used to set the content of a region and include it. For example, paragraph:

<p>...</p>

2, attributes and values ​​

In addition to odd and even elements, the content of the element can also set attributes and values. These attribute values ​​are used to change some aspect of the element's behavior. For example, hyperlink: href attribute in 3499910bf9dac5ae3c52d5ede7383485. You can link to different websites by replacing the URL inside. Of course, you can set multiple attributes in one element, or even customize attributes.

The above is the detailed content of Detailed introduction to the basic format of HTML documents. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn