There are two ways to specify the encoding of an HTML page, one is in the HTTP header, and the other is in the HTML page header.
Specifying the Encoding in the HTTP Header
Include the Content-Type
HTTP header in the HTTP specification. It specifies the content type and character set as shown in Example 9-4.
The charset
parameter specifies the encoding for the HTML page. The possible values for the charset
parameter are the IANA names for the character encodings that the browser supports.
Specifying the Encoding in the HTML Page Header
Use this method primarily for static HTML pages. Specify the character encoding in the HTML header as shown in Example 9-5.
The charset
parameter specifies the encoding for the HTML page. As with the Content-Type
HTTP Header, the possible values for the charset parameter are the IANA names for the character encodings that the browser supports.
Example 9-4 Specifying Page Encoding in the HTTP Specification
Content-Type: text/html; charset=utf-8
Example 9-5 Specifying Page Encoding on an HTML Page
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">