Characterset Meta tag problems with XHTML

I can't get an XHTML 1.0 Strict page to validate at the W3 validator. It keeps saying it won't allow character data near the end of the META tag.<br />
<br />
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><br />
<html><br />
<head><br />
<title>Central Michigan Life PULSE</title><br />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><br />
</head><br />
<body><br />
<p>&nbsp;</p><br />
</body><br />
</html><br />
<br />
By changing the doctype to XHTML 1.1 the code on my page validates, except for a name attribute in an anchor tag. I guess this thread becomes two questions:<br />
<br />
1. How the heck can I get the code above to validate with some sort of character set...<br />
<br />
OR...<br />
<br />
2. Is there a subsitute for the name attribute in XHTML 1.1 for the <a> tag. I've got hyperlinks that jump to different parts of the page for legacy browsers that can't handle the CSS layout.<!--content-->It's the /> at the end of the meta tag.<br />
For xhtml use<br />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><br />
and for html<br />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><br />
<br />
Use name and id in <a>, it validates in xhtml1 strict<!--content-->I realize the /> is needed in XHTML. I'm using the XHTML version of the tag with an XHTML doctype and it doesn't validate.<br />
<br />
If you copy and paste the code in my first post and validate it at validator.w3.org you'll see the error I was speaking of. If you were to give that code the XHTML 1 Loose doctype it would validate, but 1.0 Strict and 1.1 does not.<!--content--><meta http-equiv="Content-Type" content="application/xhtml+xml; charset=iso-8859-1" /><!--content-->Try this:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"<br />
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><br />
<br />
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"><br />
<head><br />
<title>untitled</title><br />
<meta http-equiv="content-type" content="application/xhtml+xml; charset=iso-8859-1" /><br />
</head><br />
<body><br />
<div><br />
&nbsp;<br />
</div><br />
</body><br />
</html>If you're using XHTML, you need to include a reference to the XHTML namespace as well.<!--content-->Yeah, I had the same problem a while ago, so I had to change from utf-8 to iso-8859-1<!--content-->The character set is not the problem. The problem was that he was mixing HTML and XHTML.<!--content-->B-but... :confused:<br />
I can't get an XHTML 1.0 Strict page to validate at the W3 validator.<!--content--><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"<br />
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><br />
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"><br />
<head><br />
<title>Central Michigan Life PULSE</title><br />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><br />
</head><br />
<body><br />
<p>&nbsp;</p><br />
</body><!--content-->Originally posted by toicontien <br />
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><br />
<br />
<br />
I'm a bit lost, but I just noticed this in Toicontien's first post...<!--content-->With html the meta tag can not be closed, but with xhtml it must be closed to validate.<br />
html:<br />
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"<br />
"http://www.w3.org/TR/html4/strict.dtd"><br />
<html lang="en"><br />
<head><br />
<title>Basic HTML</title><br />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><br />
<br />
<br />
xhtml:<br />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"<br />
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><br />
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><br />
<head><br />
<title>Basic XHTML</title><br />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><br />
<br />
Strictly speaking content="application/xhtml+xml should be used but is not supported by all browsers.<!--content-->Originally posted by Fang <br />
<br />
xhtml:<br />
<br />
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><br />
<br />
lang="en" will not validate, and, according to Lavalamp I believe (maybe it was someone else, I can't remember) it is not needed in XHTML.<!--content-->It does validate and it is required (<!-- m --><a class="postlink" href="http://www.w3.org/TR/xhtml1/#C_7">http://www.w3.org/TR/xhtml1/#C_7</a><!-- m -->)<!--content-->For some odd reason, I created this geocities account, I don't currently have hosting, so this will do. Ignore all the errors except for the one at the top.<br />
<br />
<!-- m --><a class="postlink" href="http://validator.w3.org/check?uri=http%3A%2F%2Fwww.geocities.com%2Fschizophrenicstd%2Findex.html&charset=%28detect+automatically%29&doctype=%28detect+automatically%29">http://validator.w3.org/check?uri=http% ... tically%29</a><!-- m --><!--content-->That is a different DTD to the ones I gave.<!--content-->I'm not sure I follow, but you said it validates, and is required, but it doesn't validate, and I've never used it, and no one's told me it's required. I wouldn't think that it would only be required for a certain Doctype, but if it is, I don't believe you said so...<!--content-->You used:<br />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"<br />
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><br />
which is different to the one I quoted:<br />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"<br />
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><!--content-->So, lang="en" is required for the XHTML 1.0 strict Doctype, but not the XHTML 1.1 Doctype?<!--content-->That's right.<!--content-->Hmmm, that's interesting, I never even knew that :o. <br />
<br />
Heheh, anyway, thanks for putting up with me. ;)<!--content-->All right, I've got another question. Is the xml:lang="en" needed with a XHTML 1.1 Doctype? Or, better yet, is it needed at all? Also, what about the XML declaration at the top of the page? Is it needed with an HTML 1.1 Doctype? OR, once again, is it needed at all?<!--content-->Alright. I'm retarded. I just realized I had the 4.01 strict doctype in my original post when I thought I had the xhtml 1.0 strict doctype.. I have no idea why I stuck that in there. I tried my default code for an xhtml 1 strict page and it validates fine, so does my default template for xhtml 1.1:<br />
<br />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><br />
<br />
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><br />
<head><br />
<title></title><br />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><br />
<br />
</head><br />
<body><br />
<br />
</body><br />
</html><br />
<br />
<br />
...<br />
<br />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><br />
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" ><br />
<head><br />
<title></title><br />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><br />
</head><br />
<body><br />
<br />
</body><br />
</html><br />
<br />
Thanks for the replies guys. I guess it pays to proofread my code before I validate it :rolleyes:<!--content-->Paul Jr wrote:<br />
Is the xml:lang="en" needed<br />
It adds accessibility to your pages. The W3C recommendations (<!-- m --><a class="postlink" href="http://www.w3.org/TR/REC-html40/struct/dirlang.html">http://www.w3.org/TR/REC-html40/struct/dirlang.html</a><!-- m -->) explain the advantages of using it and search engines use it.<br />
It is not required, but it is useful.<br />
<br />
The XML declaration: the W3C recommends (<!-- m --><a class="postlink" href="http://www.w3.org/QA/2002/04/valid-dtd-list.html">http://www.w3.org/QA/2002/04/valid-dtd-list.html</a><!-- m -->)(template bottom of page) using it.<br />
It apparently adds/does nothing (<!-- m --><a class="postlink" href="http://www.tantek.com/XHTML/Test/minimal.html#withorwithoutxmlprolog">http://www.tantek.com/XHTML/Test/minima ... txmlprolog</a><!-- m -->) , in xhtml, to browsers that understand it,<br />
but it does put IE into "quirks mode", which is my reason for not using it. You could, of course, serve it up to understanding browsers through a SSL.<!--content-->Ooo, aight, I get it now. Thanks! :)<!--content-->
 
Back
Top