Valid HTML?

  fourjays 16:56 31 Aug 2005

How the hell do you write "valid HTML"?!

I have tried on several occasions, and each time I have failed with pretty much the same problems!

I write a peice of html, and put the doctype, and everything. I then stick it through the W3s "validator" which ALWAYS gives errors that don't exist!

For example:

Line 6 column 6: end tag for "HEAD" which is not finished.

My code (so far - its going to be a template for a php program):

!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"click here">
meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

The head tag clearly opens and closes. I get the same error for the closing html tag.

What am I missing about this whole validation thing?

  Taran 18:10 31 Aug 2005

<title></title> and <body></body> tags are a requirement for a valid XHTML document of the sort you are playing with.

All I did with your code was insert the <title></title> and <body></body> tags, wrap the tags in the relevant angle brackets and validate it straight away.

Put this lot below your DOCTYPE declaration:



<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>






Save and re-test on the validator.

Job done.

<head></head> is a parent element and is considered incomplete without the necessary child elements which, in this case, is the <title></title> tag set. Without the required child element, the parent element is considered incomplete or 'not finished', hence the error message you are seeing when trying to validate your code.


  Taran 18:12 31 Aug 2005

When I said to "Put this lot below your DOCTYPE declaration: ...." I meant my code to replace the code you currently have below the DOCTYPE as you list it in your post.

Sorry if that seems completely obvious, but, well, I just wanted to be clear :o)

  Taran 18:15 31 Aug 2005

There's an overview of XHTML, DOCTYPES, required tags and optional tags at this page:

click here

It describes what must be included to make your page code valid, and what is recommended to include, as well as components that may be optional.


  fourjays 19:18 31 Aug 2005

Thanks. :) Makes more sense now.

This thread is now locked and can not be replied to.

Elsewhere on IDG sites

HP Envy x2 review: Hands-on

How Sketch and InVision have revolutionised our design workflow

The best tech gifts for Christmas 2017

Les meilleurs jeux de société (2017)