Log in

View Full Version : Resolved W3 Validator not recognising character encoding



Schmoopy
01-15-2009, 01:16 AM
I know it's not really a big issue, but for some reason the W3 validator doesn't pick up on my character encoding although it is in the code, the document is .php but I didn't think would change it in any way:

http://validator.w3.org/check?uri=http%3A%2F%2Fwww.bristoldnb.co.uk%2F

As you can see it's only a warning but then if you look on the site and the source code it says:



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Bristol DNB - Listing all the drum &amp; bass nights in Bristol</title>
<meta name="description" content="bristol dnb, bristol drum and bass, bristol d&amp;b, bristol d'n'b, bristol drum and bass nights, bristol dnb nights, bristol dnb clubs"/>
<meta name="keywords" content="Listings for drum and bass events in Bristol, UK"/>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />

<base target="_blank"/>
<link rel="stylesheet" type="text/css" href="styles/styles.css"/>
<link rel="shortcut icon" href="images/favicon.ico"/>
<link rel="stylesheet" href="css/lightbox.css" type="text/css" media="screen" />

<script type="text/javascript" src="js/prototype.js"></script>
<script type="text/javascript" src="js/scriptaculous.js?load=effects,builder"></script>

<script type="text/javascript" src="js/lightbox.js"></script>

<script type="text/javascript">
function DoClear(text) {
if (text.value == text.defaultValue){
text.value = "";
text.style.color = "#66cc33";
}
}

</script>

</head>



As you can see, it's there, but just not being found by the validator.

So what I want to know is - is this a problem with the validator itself or is there a flaw in my coding?

Thanks for any help given,

Jack

Snookerman
01-15-2009, 06:39 AM
Take a look at this article, it might help you out:
http://www.webdevout.net/articles/beware-of-xhtml (http://www.webdevout.net/articles/beware-of-xhtml)

It's long but it's worth a reading.

jscheuer1
01-15-2009, 06:48 AM
It's my understanding that the meta tags should come before the title tag. And that only the Content-Type meta tag may follow it, but that it may also precede it.

However, simply by adding an empty body section and a closing </html> tag to the code from your post, it validates here.

And if I validate this URL:


http://www.bristoldnb.co.uk/index.php

instead of:


http://www.bristoldnb.co.uk/

I get a different set of errors. Here is the code validated at http://www.bristoldnb.co.uk/:


Source Listing

Below is the source input I used for this validation:

1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3.
4. <html xmlns="http://www.w3.org/1999/xhtml">
5. <head>
6. <title>Bristol DNB - Home</title>
7. <meta http-equiv="Refresh" content="0;url=http://www.bristoldnb.co.uk/index.php" />
8. </head>
9. <body>
10. </body>
11. </html>


So you see, you weren't really validating the index page.

Schmoopy
01-15-2009, 10:28 AM
Ohhh, how did I forget that >.<, yea completely forgot I was redirecting it, jesus I'm dumb :(

Twey
01-15-2009, 10:46 AM
Note that a <meta> tag will always be overridden by the equivalent HTTP header, and the HTTP header is the preferable way to go (although a <meta> tag can often be useful to allow the information to be preserved if the page is saved and later accessed offline).

Don't forget to read Snookerman's article.