Why do we need to include the meta content type tag in HTML head like this?
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
Why do we need to include the meta content type tag in HTML head like this?
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
Whenever the webpage is been opened locally (from disk file system), the
text/html
part will instruct the webbrowser of which type the document is so that it knows how to parse it and thecharset=UTF-8
will instruct the webbrowser which character encoding should be used to display the characters on the webpage so that it won't use the platform default encoding (which may not necessarily be the right one which would thus potentially end up as mojibake).Important detail is that this HTML meta header isn't been used when the page is served over the web by HTTP. Instead, the
Content-Type
one in the HTTP response header will be used. So if this lacks thecharset=UTF-8
part while the content is actually decoded as UTF-8, then it will likely go mojibake. You can determine theContent-Type
header with for example Firebug, in the Net panel.So that the browser would know how to decode the page - for example: depending on the language, the end-result may differ a lot.
Meta elements are typically used to specify page description, keywords, author of the document, last modified, and other metadata.
The meta tag you have posted, will instruct the browser to have
text/html
type of document with character set or language set toUTF-8
.See this for more info: