How to set Chinese in html

下次还敢
Release: 2024-04-22 10:07:21
Original
646 people have browsed it

Setting Chinese in HTML with UTF-8 includes: setting charset in the <head> tag; using Unicode to directly input Chinese; using HTML entities to represent Chinese; specifying fonts that support Chinese in CSS; using JavaScript The document.charset property sets the character set.

How to set Chinese in html

How to set HTML Chinese

Set directly

in HTML In the document, you can set charset in the <head> tag to specify the character set as UTF-8.

<code class="html"><head>
  <meta charset="UTF-8">
  ...
</head></code>
Copy after login

Using Unicode

Unicode is an international encoding standard that covers characters for most of the world's languages. You can input Chinese directly using Unicode encoding.

For example:

<code class="html"><h1>你好,世界!</h1></code>
Copy after login

Using HTML entities

HTML entities are alternative representations of special characters. You can use the following entities to represent Chinese in HTML:

##好中世于界皶
Characters Entity
##For example

:

<code class="html"><h1>&#20320;&#20013;, &#26044;&#30390;!</h1></code>
Copy after login

Using CSS

You can use the

font-family

attribute to specify the font in CSS. The following example uses a font that supports Chinese: <div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:php;toolbar:false">&lt;code class=&quot;css&quot;&gt;body { font-family: &quot;Noto Sans CJK SC&quot;, &quot;Microsoft YaHei&quot;, &quot;SimSun&quot;; }&lt;/code&gt;</pre><div class="contentsignin">Copy after login</div></div>

Using JavaScript

You can use JavaScript’s

document.charset

property to set the character set. <div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:php;toolbar:false">&lt;code class=&quot;js&quot;&gt;document.charset = &quot;UTF-8&quot;;&lt;/code&gt;</pre><div class="contentsignin">Copy after login</div></div>

The above is the detailed content of How to set Chinese in html. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
css
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!