Log in

View Full Version : Validating XHTML Question



Markxxx
10-12-2009, 07:24 PM
OK I am using the W3C validator and I just started out making a simple website.

I test the page and the validator passes it with a warning.

"No Character encoding declared at document level"

So I went in and used a meta tag and it worked perfectly.

But then, I read on the W3C site, that instead of using a meta tag on all your pages you could just put an htaccess in the root directory.

So I tried this

I created a file called .htaccess and put it in the root directory, called "cold"

So now in the "cold" directory I have two files

index.html
.htaccess

The htaccess says:

AddType 'text/html; charset=ISO-8859-1' html

And that is all.

When I use this form it fails to validate or rather it validates but gives me the warning back - "No Character encoding declared at document level"

Am I using the right words in my .htaccess file? I use 1and1 for my webhost and I've used htaccess files for passcodes and they work fine. I've never used the file for something like this. Any ideas what is up? Or perhaps it doesn't work with 1and1?

Thanks

jscheuer1
10-13-2009, 08:21 AM
I'm not sure about the .htaccess file (though that looks about right - I'd generally prefer UTF 8 encoding if workable in your host environment). But here's how it works from the validator's point of view - The validator doesn't know what you have like that, so it will continue to give the warning regardless of any server side code. It is after all just a warning. So if you have followed all of the instructions for the .htaccess file properly and are allowed by your host to be using one, everything should be fine, just ignore the warning.

However, various encodings allow for certain characters and not others. To get the validator to check the validity of your code in the encoding that you have set for the page in .htaccess or by other server side methods, you must tell the validator what encoding you are using. There is a place on the validator form where you may select the encoding that the validator should use when checking your page.