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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Validating your HTML source

Status
Not open for further replies.
Dec 8, 2003
17,047
GB
Just a quick tip when validating your HTML source that I came across a few days ago.

If you use the W3C validator ( to validate your source, there could be potential errors that go unreported that other validators may pick up on. This could mean that pages you believe to be valid may not show up as being so in other validators (which could be embarrasing if clients check your work using stricter validators).

One example is if you use the HTML 4.01 Strict DOCTYPE, and have HR or BR elements with XHTML-style closing slashes. Take the following code:

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "[URL unfurl="true"]http://www.w3.org/TR/html4/strict.dtd">[/URL]
<html lang="en">
<head>
	<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
	<meta http-equiv="content-language" content="en">
	<title>Validation test</title>
</head>

<body>
	<div>
		<p>Some text</p>
		<hr />
		<p>Some more<br />text</p>
	</div>
</body>
</html>

The W3C validator reports this as being perfectly valid against the HTML 4.01 Strict DOCTYPE.

Using the validator at htmlhelp.com, however, shows these as problems:


Another nice feature of the htmlhelp validator is that it can validate entire sites in one go.

I'll be checking all of my work in both from now on.

Dan

Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Which one is right then?

The validator created by the people that created the spec or this one created by... er, a third party? Who's got a better grasp on the spec?

I can see that there may be some initial explaining to do, but I could sway most clients with "well W3C invented it, and they say it's right. It's right. But kudos to you, Mr client for checking it. By the way, as a reminder, my payment terms state 15 days. Cheers".

Then again, who would use XHTML syntax with a HTML 4 doctype? ;-)

<honk>*:O)</honk>
Foamcow Heavy Industries - Web site design in Cheltenham and Gloucester
Ham and Jam - British & Commonwealth forces mod for Half Life 2
 
...Then again, who would use XHTML syntax with a HTML 4 doctype?
Dan did [smile] because I convinced him to change from XHTML back to HTML and the w3c validator didn't choke. It's a weird one alright, though.

Cheers,
Jeff

[tt]Jeff's Page @ Code Couch
[/tt]

What is Javascript? FAQ216-6094
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top