Why We Need Meta charset utf-8 tag?

Posted in Tutorials

Tweet This Share on Facebook Bookmark on Delicious Digg this Submit to Reddit

In the basic HTML5 page explained here, we have an meta utf-8 tag …

meta charset utf-8

meta charset utf-8

This tag tells the browser to render using the UTF-8 character set?  UTF-8 is capable of encoding all possible characters in Unicode.

Why does this matter?  It matters if you have any international characters in your HTML.   In our above example, we have an Spanish phrase with the tilda n character.   When shown in the browser with the meta charset=”utf-8″, it looks as expected like this …

correct rendering of UTF-8

correct rendering of UTF-8

But without the meta charset=”utf-8″ tag, it renders incorrectly…

incorrect rendering without the meta charset utf-8

incorrect rendering without the meta charset utf-8

Even if you do not have any international characters right now in your documents, you should still put the meta charset=”utf-8″ tag in case you have in the future.