background preloader

Html5

Facebook Twitter

Declaring character encodings in HTML. Intended audience: HTML authors (using editors or scripting), script developers (PHP, JSP, etc.), Web project managers, and anyone who needs an introduction to how to declare the character encoding of their HTML file.

Declaring character encodings in HTML

Question How should I declare the encoding of my HTML file? You should always specify the encoding used for an HTML or XML page. If you don't, you risk that characters in your content are incorrectly interpreted. This is not just an issue of human readability, increasingly machines need to understand your data too. If you need to better understand what characters and character encodings are, see the article Character encodings for beginners. Quick answer Always declare the encoding of your document using a meta element with a charset attribute, or using the http-equiv and content attributes (called a pragma directive).

<! <! It doesn't matter which you use, but it's easier to type the first one. You should always use the UTF-8 character encoding. Details <? Additional information. Declaring Character Encoding. Now that you understand what character encoding is and why it is needed, choosen a character encoding for the web documents on the website it is time to declare the character encoding.

Declaring Character Encoding

Ways to Declare Character Encoding There are 3 ways to declare character encoding: At the server Using a meta tag XML declaration (beyond the scope of this site for more information see references and further reading at the end of this article) Declaring Character Encoding at Server Level Declaring character encoding at the server level is preferred. You will have to check with your hosting company to see if this is possible.

If the website is hosted on a web server using Apache this can be done using the htaccess file. Content-Type: text/html; charset=iso-8859-1. HTML Codes, Hexadecimal Codes & HTML Names. Character encodings for beginners. Answer First, why should I care?

Character encodings for beginners

If you use anything other than the most basic characters needed for English, people may not be able to read your text unless you say what character encoding you used. For example, you may intend the text to look like this: but it may actually display like this: Not only does inadequate encoding information spoil the readability of displayed text, but it may mean that your data cannot be found by a search, or reliably processed in a number of other ways. So what's a character encoding? Words and sentences in text are created from characters. You may not be able to see some of the characters in this page because you don't have the necessary fonts.

Characters are grouped into a character set (also called a repertoire ). Coded character set when each character is assigned a particular number, called a code point. These code points will be represented in the computer by one or more bytes. character encoding is a key to unlock (ie. crack) the code. The misleading term charset.