How To Specify Encoding

Table of contents:

How To Specify Encoding
How To Specify Encoding

Video: How To Specify Encoding

Video: How To Specify Encoding
Video: Code Pages, Character Encoding, Unicode, UTF-8 and the BOM - Computer Stuff They Didn't Teach You #2 2024, December
Anonim

The source code of web pages should include an indication of the character encoding table for use by the browser when displaying content. The way this should be done is described in the W3C (World Wide Web Consortium) standards.

How to specify encoding
How to specify encoding

Instructions

Step 1

To indicate the encoding of an HTML document, the META tag is used, which should be placed inside the header part of the page source code. A block marked with and tags is called a heading block. In order for this meta tag to be perceived by the browser as a pointer to an encoding table, the "codeword" charset must be placed in its content attribute, and a link to the required encoding must be specified after the equal sign. For example, it may look like this: Here is a link to the windows-1251 code table containing the letters of the Russian alphabet - it is she who is most often used in the Russian-speaking part of the Internet. You need to write your value after charset =. This can be, for example, a UTF-8 Unicode character table, or other encoding containing Cyrillic characters (koi8-r, iso-ir-111, koi8-u, x-cp866, iso-8859-5, x-mac-cyrillic, ibm855). If your document is written in XHTML standards, you must add a space and a slash ("/>") before the last character (">"). This entire tag should be placed as close as possible to the beginning of the heading part of the document (). Typically, it follows a tag.

Step 2

To add an indication of the encoding that the browser should use when displaying the content of the document, open the page source for editing. In the HTML source, you first need to determine which syntax standard is used to write the tags. This information is usually placed in the very first line, in a tag starting with <! DOCTYPE … Depending on whether the standard is referenced in it (XHTML or HTML), you need to correct the meta tag code, which will indicate the encoding. With the line of code ready for insertion, find the tag, and on the next line, add your meta tag. If there is no such tag in your document, then insert the encoding indication immediately after the tag. Then save the edited page.

Step 3

The encoding should also be specified in external style files if they contain elements that use national language characters. Add this definition to the first line of your CSS file: @charset "windows-1251"; Of course, you need to replace windows-1251 with your own value.

Step 4

There is also a way in HTML to specify the encoding of the document that the hyperlink points to. The charset attribute is used for this. For example: How Simple!

Recommended: