homepage Welcome to WebmasterWorld Guest from 54.166.228.100
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / HTML
Forum Library, Charter, Moderators: incrediBILL

HTML Forum

    
Meta tag for encoding utf-8
Am I using the right meta tag
Adam5000




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

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?

 

not2easy




msg:4677471
 3:14 pm on Jun 4, 2014 (gmt 0)

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.

Adam5000




msg:4677472
 3:21 pm on Jun 4, 2014 (gmt 0)

Strict DOCTYPE not2

<!doctype HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

not2easy




msg:4677473
 3:38 pm on Jun 4, 2014 (gmt 0)

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.)

Adam5000




msg:4677481
 3:59 pm on Jun 4, 2014 (gmt 0)

You're a genius not2.

lucy24




msg:4677515
 5:43 pm on Jun 4, 2014 (gmt 0)

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.

mattur




msg:4677594
 11:07 pm on Jun 4, 2014 (gmt 0)

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>
...

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / HTML
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved