html5 The statement to set the character set is ""; the meta tag is used to provide metadata about the HTML document. When the charset attribute is added to the tag, it can be specified The character encoding of the HTML document.
The operating environment of this tutorial: Windows 7 system, HTML5 version, Dell G3 computer.
In HTML5, you can use the tag to set the character set.
tag is used to provide metadata about the HTML document, such as page validity period, page author, keyword list, page description, etc. The data defined by the tag will not be displayed on the page, but will be parsed by the browser.
tag defines the syntax of the character set:
<meta charset="字符编码">
The charset attribute is used to specify the character encoding of the HTML document, for example, added in the
tag The following statement:<meta charset="UTF-8">
can set the character encoding of the document to "UTF-8".
Differences between HTML 4.01 and HTML5
The charset attribute is a new attribute in HTML5 and replaces:
<meta http-equiv="Content-Type " content="text/html; charset=UTF-8">
Still allows the use of the http-equiv attribute to specify the character set, but using the new method can reduce the amount of code.
Commonly used values for the charset attribute:
UTF-8 - Unicode character encoding
ISO-8859 -1 - Character encodings for the Latin alphabet
In theory, any character encoding can be used, but not all browsers understand them. The more widely a certain character encoding is used, the more likely browsers are to understand it.
To see all available character encodings, visit IANA Character Sets.
http://www.iana.org/assignments/character-sets
Expand knowledge: Other uses of tags
1. Define page description
<meta name="description" content="php中文网提供大量免费、原创、高清的php视频教程,并定期举行公益php培训!可边学习边在线修改示例代码,查看执行效果!php从入门到精通,一站式php自学平台!">
Defining the description information of the page is beneficial to search engines.
tag defines the document title, name="description" defines the document description, and the description is usually longer than the title.
2. Define keywords
<meta name="keywords" content="php教程,php入门教程,php视频教程,php源码下载,php手册">
Keywords are used to provide search engines with information related to the page.
3. Define page author
<meta name="author" content="PHP中文网">
Author information can be automatically extracted through some content management systems.
4. Refresh the page
<meta http-equiv="refresh" content="30">
The code in the above example is used to send an instruction to the browser so that the browser automatically refreshes the page after a specified time interval (30 seconds). In addition to specifying the time interval in the content attribute, you can also specify a link. In this case, the page will redirect to the page pointed to by the link after the specified time, as shown in the following example:
<meta http-equiv="refresh" content="10; url=https://www.php.cn/">
Related recommendations : "html video tutorial"
The above is the detailed content of What is the statement to set the character set in html5. For more information, please follow other related articles on the PHP Chinese website!