Welcome to WebmasterWorld Guest from 54.167.144.170

Forum Moderators: incrediBILL

Meta tag for encoding utf-8

Am I using the right meta tag

   
2:16 pm on Jun 4, 2014 (gmt 0)

10+ Year Member



I'm beginning to validate my pages, an I'm getting the message " UTF-8 character encoding assumed."

I'm using the meta tag
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
and I'm thinking that declares UTF-8 encoding, and it wouldn't need to be assumed.

Am I using the correct tag?
3:14 pm on Jun 4, 2014 (gmt 0)

WebmasterWorld Administrator 5+ Year Member Top Contributors Of The Month



What's your DOCTYPE? That does affect the correct format for the tag. The tag in the format you have is correct for
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

though "Content-Type" doesn't need caps.
3:21 pm on Jun 4, 2014 (gmt 0)

10+ Year Member



Strict DOCTYPE not2

<!doctype HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
3:38 pm on Jun 4, 2014 (gmt 0)

WebmasterWorld Administrator 5+ Year Member Top Contributors Of The Month



That would be the same as for 4.01 Trans. This is exactly what I get for a new page setup using 4.01 Strict:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">

The only difference I see is the capitalization differences. (I'm using BBEdit to give me that and haven't had validation issues - though I never used a 4.01 Strict because it seemed "overly picky" to me.)
3:59 pm on Jun 4, 2014 (gmt 0)

10+ Year Member



You're a genius not2.
5:43 pm on Jun 4, 2014 (gmt 0)

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



Little-known detail: the w3 validator is actually far stricter haha than the HTML4 standard. So, for example, it will kick up a fuss about capitalized tags like <H1> or <BR>, and will point out when a <p> or <td> isn't closed, even though they aren't strictly required. Conversely, one time I accidentally left off the closing
</body>
</html>

and the validator didn't say a word. Go figure.
11:07 pm on Jun 4, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'd recommend using the latest version of the W3C validator, which uses the same HTML parser as that used in all modern browsers (the same parser code is actually used in Firefox). The old W3C validator is no longer maintained, and is DTD-based so cannot check all HTML constraints.

[validator.w3.org...]

You could also switch to the the HTML5 doctype <!doctype html> - the way browsers process your pages will not change, as they are already parsing it as "HTML5", but it does affect the rules validators use to check your pages. You could also use the charset parameter instead of the "content-type" directive, as the text/html bit is ignored anyway.

[developer.mozilla.org...]

Again this shouldn't affect your pages as this is the way browsers are already parsing your pages, it's just cleaning up some old SGML talismans from 1999 that don't affect anything :) So the start of your pages would be:

<!doctype html>
<html lang=en>
<head>
<meta charset=utf-8>
<title>Page Title</title>
</head>
...
 

Featured Threads

Hot Threads This Week

Hot Threads This Month