Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Challenge validating xhtml strict document.

Status
Not open for further replies.

JProg

Programmer
Apr 4, 2002
88
JP
Hi Everyone,

I have an xhtml file that looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "<html xmlns=" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8" />
<meta name="author" content="David Dartnell" />
<meta name="description" content="Assignment 1, Web Development 1, by David Dartnell" />
<meta name="keywords" content="Assignment 2, Web Development 1, David Dartnell's Assignment 2, Assingment 2 Index Page" />
<title>David Dartnell's Assignment 2 Index Page</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<style type="text/css">
/*<![CDATA[*/
body
{
background-image: url("background_2.jpg");
background-repeat: repeat;
}
.description
{
color: black;
font-family: 'Aachen Medium', Serif;
font-weight: bold;
text-align: center;
}
.frame_demo
{
border: 2px ridge teal;
color: #009B9B;
position: absolute;
height: 200px;
margin-left: 450px;
margin-top: 390px;
width: 300px;
z-index: 1;
}
.link_demo
{
border: 2px groove purple;
color: #004080;
position: absolute;
height: 200px;
margin-left: 10px;
margin-top: 390px;
width: 300px;
z-index: 1;
}
.list_demo
{
border: 2px groove green;
color: #005900;
position: absolute;
height: 200px;
margin-left: 10px;
margin-top: 10px;
width: 300px;
z-index: 1;
}
.student_information
{
background-image: url("background_1.jpg");
background-repeat:repeat;
border: 2px double blue;
height: 200px;
margin-left: 230px;
margin-right: 200px;
margin-top: 200px;
position: absolute;
width: 300px;
z-index: 2;
}
.table_demo
{
border: 2px ridge red;
color: #804040;
position: absolute;
height: 200px;
margin-left: 450px;
margin-top: 10px;
width: 300px;
z-index: 1;
}
ul
{
list-style-type: square;
}
/*]]>*/
</style>
</head>
<body>
<div class="student_information">
<h1>Student Information</h1>
<ul>
<li>Name: David Dartnell</li>
<li>ID Number: 4644190</li>
<li>"I declare that this assignment is my individual work. I have not worked collaboratively nor have I copied from any other student's work or from any other source."</li>
</ul>
</div>
<div class="list_demo">
<h1>List Demo</h1>
<h3>Link: &nbsp; <a href="lists.htm" title="Example List Page">list.htm</a></h3>
<h4 class="description">Description</h4>
<p>Demonstrates the use of <span class="keyword">definition, ordered &amp; unordered lists</span>. Also explains the use of the<span class="keyword">type</span> attribute in lists.</p>
</div>
<div class="table_demo">
<h1>Table Demo</h1>
<h3>Link: &nbsp; <a href="table.htm" title="Example Table Page">table.htm</a></h3>
<h4 class="description">Description</h4>
<p>Demonstrates the use of <span class="keyword">tables</span>. Also explains the use of the <span class="keyword">colspan &amp; rowspan</span> attributes in tables.</p>
</div>
<div class="link_demo">
<h1>Link Demo</h1>
<h3>Link: &nbsp; <a href="link.htm" title="Example Links Page">link.htm</a></h3>
<h4 class="description">Description</h4>
<p>Demonstrates the use of <span class="keyword">links</span>. Also explains style sheet <span class="keyword">pseudo-classes</span> that can be applied to <span class="keyword">links</span>.</p>
</div>
<div class="frame_demo">
<h1>Frame Demo</h1>
<h3>Link: &nbsp; <a href="frame.htm" title="Example Frames Page">frames.htm</a></h3>
<h4 class="description">Description</h4>
<p>Demonstrates the use of <span class="keyword">frames</span>. Also explains various <span class="keyword">frame</span> attributes including <span class="keyword">name, target &amp; source</span>.</p>
</div>
</body>
</html>

I am getting the following message from the W3C


DOCTYPE Override in effect!
The detected DOCTYPE Declaration "<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" " has been suppressed and the DOCTYPE for "XHTML 1.0 Strict" inserted instead, but even if no errors are shown below the document will not be Valid until you update it to reflect this new DOCTYPE.
Note:
The Validator XML support has some limitations.
This Page Tentatively Validates As XHTML 1.0 Strict (Tentatively Valid)!

Tip Of The Day:
Use <h1> for top-level heading

DOCTYPE Override in effect!
The detected DOCTYPE Declaration "<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" " has been suppressed and the DOCTYPE for "XHTML 1.0 Strict" inserted instead, but even if no errors are shown below the document will not be Valid until you update it to reflect this new DOCTYPE.


Can anybody explain to me what tentatively validated actually means? Also is there anything that I can do to my code to make it more than "tentative"! Thanks for your assistance.

Regards

David
 
I just uploaded a copy of your code to my website, deleted the:
Code:
/*<![CDATA[*/
...
/*]]>*/
and re-validated using the " tool.

It validated to XHTML 1.0 Strict for me.

Pete.


Web Developer & Aptrix / IBM Lotus Workplace Web Content Management (LWWCM) Specialist
w: e: Pete.Raleigh(at)lclimited.co.uk
 
Stupid question. In the validator, did you select Doctype as (detect automatically) or selected one from the list. If former, something like you describe would happen. For a document to be completely valid, validator must detect the doctype automatically.
 
Thanks guys for your excellent help. I have discovered that if I leave the extended interface with all of the options set to default (probably should just use the normal one in this instance!) then I get valid xhtml strict.

I have another question, if somebody can answer it will be really cool.

I have used the following at the very top of my document:

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

then I follow with a xhtml DOCTYPE declaration.

I have read that when a style is to be declared inside the xhtml document it must be marked as CDATA.

To this end I have done the following:

/*<![CDATA[*/
body
{
background-image: url("background_2.jpg");
background-repeat: repeat;
}
.description
{
color: black;
font-family: 'Aachen Medium', Serif;
font-weight: bold;
text-align: center;
}
/*]]>*/

As a result of information from another forum post I have included the comment characters /* .. */

Do I need this characters or should I get rid of them?

Thanks for all of your help.

Regards

David
 
In order to be valid XML, a <style> or <script> element cannot include < or & characters. If you need to use these characters (as you might if you were writing a script and wanted to make a "less than" test), you MUST do the <![CDATA[ thing to tell any XML parser that the element contains character data, and to ignore < and & signs.

You also might want to enclose the styles/scripts with comments so that old browsers ignore them. There's a problem with that - the newest browsers, if they parse the document as XML will also ignore the "comments" unless you code them just right. All the foregoing can confuse the validator - as it's expecting HTML, not XML.

According to , the bullet-proof way to enclose scripts is...
Code:
<style type="text/css">
  <!--/*--><![CDATA[/*><!--*/
    ...your styles in here...
  /*]]>*/-->
</style>
Horrible, isn't it?

Personally, I'd only declare styles in <style> elements when developing a new page layout. Once you've got 'em how you want them, move them into an external style sheet. It's easier to code, and more efficient too!

-- Chris Hunt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top