Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where should I specify my charset if not on a meta element?

I'm getting an HTML validation error for the following line, I'm not sure where I should specify my charset if I don't do it within the meta tag.

Line 5, Column 70: Attribute charset not allowed on element meta at this point.

<meta http-equiv="Content-Type" content="text/html" charset="utf-8"/>
like image 912
Luke Avatar asked Oct 25 '13 15:10

Luke


People also ask

Where do I put charset in HTML?

It needs to be inside the <head> element and within the first 1024 bytes of the HTML, as some browsers only look at those bytes before choosing an encoding.

Does UTF-8 need meta charset?

Furthermore, most browsers use UTF-8 by default if no character encoding is specified. But because that's not guaranteed, it's better to just include a character encoding specification using the <meta> tag in your HTML file. There you have it.

What is the default character for a meta tag charset?

DOCTYPE html>, the charset defaults to UTF-8. This is usually the desired setting making the meta charset setting unnecessary.

Do you need meta charset HTML?

It is not necessary to include <meta charset="blah"> . As the specification says, the character set may also be specified by the server using the HTTP Content-Type header or by including a Unicode BOM at the beginning of the downloaded file.


2 Answers

This is because you put it in a Content-type meta tag, this is not allowed.

simply make a seperate meta tag, e.g.

<meta charset="utf-8" />

this should validate for you.

like image 71
SidOfc Avatar answered Sep 19 '22 23:09

SidOfc


Yes. You should use as this is recommended in html5 and it is a new recommendation.

Below is a simple html5 layout:

<!DOCTYPE html>
<html> 
<head> 
<meta charset="UTF-8"> 
<title>Title of the document</title> 
</head>

<body> 
Content of the document...... 
</body>

</html>
like image 36
user1199842 Avatar answered Sep 16 '22 23:09

user1199842