W3C Validation Question

Associate
Joined
20 Sep 2003
Posts
2,384
Location
Scotland
I have been doing a lot of W3C error fixing for the websites that we look after at work. Recently the W3C validator was updated and ever since that happened a lot of my pages have been failing asking me to add the line…

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

First question I have is what does this line of code do and why were my pages passing fine without it ?

I don’t want to go back through all my sites just adding this line of code as they cover the whole of Europe and are in different languages. For example for a Swedish site should I be adding the line….

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="se” lang="se">

If anyone can enlighten me on this subject I would appreciate it.


Thanks.
 
DezUk said:
I have been doing a lot of W3C error fixing for the websites that we look after at work. Recently the W3C validator was updated and ever since that happened a lot of my pages have been failing asking me to add the line…

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

First question I have is what does this line of code do and why were my pages passing fine without it ?

I don’t want to go back through all my sites just adding this line of code as they cover the whole of Europe and are in different languages. For example for a Swedish site should I be adding the line….

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="se” lang="se">

If anyone can enlighten me on this subject I would appreciate it.


Thanks.
It's to give the document an XML namespace and define the primary language. I have no idea why it would all of a sudden stop validating as it has always been part of the XHTML spec.

Which document type are you declaring? Did you recently change it? XHTML is bad for your health; consider changing the document type instead (which will be constant, so no need to change it based on language). That said, it's still a good idea to include the language being used in the html element.
 
I am always declaring XHTML and the documents were un changed, working fine one day and then the next again morning it was being reported as unvalid. All of my pages start like this

<?xml version="1.0" encoding="UTF-8"?>
<!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">


Any of the pages that now fail the check only have <html> on the third line.
 
Quick question, how come you didn't just put the starting html/head tags in the index page of the site and then just use the index as a master include for all other pages on the web site? Was there something more at play?

Reason I ask is that any site I do, I do it this way, and would appreciate your thoughts if something like this should be approached differently.
 
Well I had the joys of working with pages other people had already coded and it was my job to make the pages w3c compliant. I agree with you though as I would do the same and code all pages with these lines of code in to start with.
 
Well the pages need to be viewable across all differnt media types like pda's etc so XHTML is what is required.
 
Back
Top Bottom