Click to See Complete Forum and Search --> : XHTML 1.0 Strict Validation Error in Page header


CarolW
03-11-2008, 03:12 PM
After years (perforce), I'm trying to fix up and work on my web site. I went to fix one page (contact info that needs updating), uploaded it, and then went to validate it with the W3C Markup service. I got this error:

Validation Output: 1 Error

1. Error Line 3, Column 1: Missing xmlns attribute for element html. The value should be: http://www.w3.org/1999/xhtml.

<html lang="en-us" xml:lang="en-us">

?

Many Document Types based on XML need a mandatory xmlns="" on the root element. For example, the root element for XHTML will look like:
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">


Here's the start of my document (the page). I don't remember a thing from my previous efforts, where I was working beyond my capabilities anyway. I have dozens of pages to fix, just for this ONE error! That's okay; I plan to change them anyway - change to PHP, so I'll have to edit every page anyway.

I know I'm SUPPOSED to understand what these words mean (that is, what W3C says), but I don't. Help!

Quoting the first three lines of the page as I submitted it (so the error is present there):



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="en-us" xml:lang="en-us">



So how do I fix this?

Exactly what should I change, and how?

(Do you need more lines from the header? well, in case you do, I'll quote the entire header.)


So, it looks like this:



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="en-us" xml:lang="en-us">
<head>
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="pragma" content="no-cache" />
<meta content="text/html; charset=utf-8" http-equiv=
"content-type" />
<title>CoDog Contacts: dog behavior and care, calming signals</title>
<link rev="made" href="mailto:cwhitney@islandnet.com" />
<meta http-equiv="Content-Type" content=
"text/html; charset=utf-8" />
<meta name="author" content="Carol Whitney" />
<meta name="description" content=
"CoDog: Carol's most highly-recommended sources for information on dogs, their nature and behavior, care and teaching" />
<meta name="keywords" content=
"CoDog, calming signals, dog-care, nature of dogs, behavior, clicker-training" />
<link rel="stylesheet" href="codog.css" type="text/css" />
</head>



Thanks!
Tue, 11 Mar 2008 13:09:29
Disoriented Granny again!

dtm32236
03-11-2008, 03:29 PM
<html lang="en-us" xml:lang="en-us">
no need for that, just do:

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

felgall
03-11-2008, 03:43 PM
To be valid with an XHTML doctype you need:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

the lang attribute in the html tag is optional, the xmlns one is mandatory.

If you don't want to include the xmlns then you need to switch to an HTML doctype instead where that attribute doesn't exist.

dtm32236
03-11-2008, 04:01 PM
yeah - he's right.... you do need xmlns

it's been a while since i've used XHTML - i don't really see the point...

CarolW
03-11-2008, 05:51 PM
Hi Stephen,

To be valid with an XHTML doctype you need:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

the lang attribute in the html tag is optional, the xmlns one is mandatory.

If you don't want to include the xmlns then you need to switch to an HTML doctype instead where that attribute doesn't exist.

Ha! I know your name well; so of course, you came through with the solution - THANK YOU! (The new pages all validated.) I have to edit every page anyway; actually, there are well over a hundred - then do it all over again to change to PHP - what fun. Than after that, I can start on the serious updating work!

Eek!

Anyway, I made that change quickly on about six pages; now I have one other series of tests to do - the include files have to go in there - modified. I hope they validate again after I change the included material!

I sing the praises of these forums on my web site, with good reason! Thanks a million! (and thanks others, too, for your replies - surely we all learn together).

Tue, 11 Mar 2008 15:48:00