W3c validation error help, please
April 5, 2004 3:40 AM   Subscribe

I have a web page that is valid XHTML 1.1 when I upload it to the w3c validator. However, when I link to the 'check referrer' validator from it, I get "I was not able to extract a character encoding labeling from any of the valid sources for such information". Does anyone have any idea what the problem is here?
posted by reklaw to Computers & Internet (9 answers total)
 
Are you specifying the character encoding in the HTTP headers or in the html meta element? It could well be that when uploading the file and it doesn't find a charset it assumes it will be given in the HTTP headers and thus doesn't bug you about it; When you give it an actual URL it finds the server doesn't give an encoding either. Or perhaps the encoding in the meta tag and HTTP header are in disagreement?

It would probably help if you posted a simple example of a HTML file that triggered your problem.
posted by fvw at 4:14 AM on April 5, 2004


Response by poster: Here you go (hope this works...)

<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">

<head>
<title>x</title>
<link rel="stylesheet" type="text/css" href="x.css" />
</head>

<body>

...

</body>

</html>

So you think it's a problem with the HTTP headers... I'm not altogether sure I can fix that very easily. Looking again, the page does seem to say you can specify a charset in the XML declaration or a meta tag, but I have no idea of the syntax for that.
posted by reklaw at 4:27 AM on April 5, 2004


At which point the wonder that is google kicks in.
posted by fvw at 4:40 AM on April 5, 2004


Response by poster: Aha, thanks. This page (second Google result) solves the problem more easily than using meta tags, I reckon, as it lets me just replace

<?xml version="1.0"?>

with

<?xml version="1.0" encoding="UTF-8" ?>

Thanks again!
posted by reklaw at 4:58 AM on April 5, 2004


Try adding:
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
to the head.
posted by yerfatma at 4:59 AM on April 5, 2004


Myself, I like:

<meta http-equiv="content-type" content="text/html; charset=us-ascii"/>

Because you can throw it in to HTML 4.01 transitional. However, you have to be careful with that / ... on some DTDs, the validator will trip over that trailing close / and tell you something weird like you didn't close the body.
posted by weston at 8:32 AM on April 5, 2004


Reklaw, you may want to reconsider using the xml prologue because some Web browsers really don't like it. A meta-tag is the safer route.
posted by hyperizer at 12:46 PM on April 5, 2004


Response by poster: hyperizer: Hmm... good point. Also, I think weston's version of the meta tag is quite good (doesn't have a set of numbers in it), so I might use that.

Do you know which browsers choke on the xml declaration, exactly? Just out of curiosity.
posted by reklaw at 12:59 PM on April 5, 2004


I could be wrong, but I believe IE for Mac panics when faced with that particular xml declaration.
posted by tenseone at 3:42 PM on April 5, 2004


« Older Why is nitrogen part of so many explosives?   |   Can anyone suggest the title/ author of a book of... Newer »
This thread is closed to new comments.