00 Votes

HTML5: Head Meta Tags - Declare Language and Charset correctly

Question by Guest | 2014-05-31 at 17:09

At the moment, I am trying to migrate my website to HTML 5 and on this occasion I would like to rewrite my HTML in a way so that the HTML Validator isn't showing errors anymore.

Currently, the following meta tags in the head of my page are making some trouble:

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="Content-Language" content="en" />

How is it possible to declare language and character encoding in an HTML5 head without causing validation errors?

ReplyPositiveNegative
0Best Answer0 Votes

The language is stated directly in the <html>-tag, because the language refers to this element (exceptions are possible with additional language definitions on other elements in the body). The charset is declared with <meta charset="UTF-8"> in the head.

Here is a small example of the basic frame of an HTML 5 page:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
...
</body>
</html>

Important: You should specify the charset directly at the beginning of the head before writing any other text so that the browser knows how to interpret the page. Additionally, you should tell the charset directly via the HTML Response Header, for example with writing the following line into your HTACCESS file: AddDefaultCharset UTF-8
2014-05-31 at 23:28

ReplyPositive Negative
Reply

Related Topics

PHP: Sending an E-Mail

Tutorial | 0 Comments

Important Note

Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.

Participate

Ask your own question or write your own article on askingbox.com. That’s how it’s done.