Forum Moderators: open

Message Too Old, No Replies

Why didn't the validator like my </head> and <body> tags?

Validator

         

Adam5000

2:48 pm on Jun 7, 2007 (gmt 0)

10+ Year Member



I copied a page of html code into the w3c validator and below is the Doctype I'm using.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Strict//EN"

"http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">

Here's the meta tag if that helps.

<META http-equiv=Content-Type content="text/html; charset=windows-1252">

The validator didn't like my closing head tag and opening body tag. I took them out and the page validated.

Any ideas why it didn't like my </head> and <body> tags?

Is it a good idea to leave them out?

mattur

2:59 pm on Jun 7, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi Adam,

First off, you're using a dodgy doctype. The two main HTML4.01 doctypes are:

Strict:


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

Transitional:


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

Added: see FAQ: Choosing a Doctype [webmasterworld.com] for more info.

Fix this first. Then post the relevant bit of your code, from opening <html> to opening <body> (just the brief code, not all your site specific stuff). It's generally not a good idea to leave out header and body tags; you've got a syntax error somewhere.

thecoalman

3:44 pm on Jun 7, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



If you took them out and it validates check for duplicates of the ones you removed. AFAIK it won't validate without them.

mattur

4:05 pm on Jun 7, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It *will* validate without them. Opening and closing tags for HTML, HEAD and BODY are all optional [webmasterworld.com] in HTML 4.01. But it's good practice to use them.

Adam5000

12:08 pm on Jun 11, 2007 (gmt 0)

10+ Year Member



Matt and Coal

The doctype and opening style tag were the problems

I changed the doctype and put quotes around the items in the opening style tag, repositioned a few <br> tags, then put the </head> and <body> tags back in and it worked.

I used the strict doctype and at first the style tag looked like this
<style rel=stylesheet type=text/css href=pageTwo.htm>

And I corrected it to read
<style rel="stylesheet" type="text/css" href="pageTwo.htm">

And the new doctype worked better than the one I was using.

Thank you for your help, you're fabulous.

Fotiman

3:01 pm on Jun 11, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Uh... I think you want this:
<style rel="stylesheet" type="text/css" href="pageTwo.htm">

to really be this:
<link rel="stylesheet" type="text/css" href="pageTwo.htm">

g1smd

12:52 am on Jun 13, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



The filename for a stylesheet should end in .css, too, no?

g1smd

12:55 am on Jun 13, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



The closing </head> tag error that you mentioned can also occur if you use XHTML styled <meta .... /> tags in an HTML document.

That is, in an HTML document, the first "/" seen after <head> is assumed to be the "/" of the closing </head> tag, even if it isn't.

Don't use other XHTML tags, like <hr /> or <br />, in an HTML document either. Stick to plain <hr> type tags.

Fotiman

1:02 am on Jun 13, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Good points.