i have started validating the pages on my site (i know i should have done this first, but give me a break, its my first website.. :lol: )

im using http://validator.w3.org/ to do the validating and i have 2 issues i need help with.

ok, this is what the begining of my first page looks like:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Male Pattern Baldness, Androgenetic Alopecia</title>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">
<META NAME="keywords" CONTENT="Hair loss, Male pattern baldness, Androgenetic Alopecia">
<META NAME="description" CONTENT="Elaborate and up-to-date information about Hair loss and its possible treatment options.">
<link rel="stylesheet" type="text/css" href="external.css"/>
</head>

<body>

this is the validation error i get:

Line 9, column 6: end tag for element "HEAD" which is not open

</head>

Line 11, column 5: document type does not allow element "BODY" here

<body>

if i try to move the <link rel="... line above the meta tags i also get this:

Line 6, column 72: document type does not allow element "META" here

...Type" CONTENT="text/html; charset=ISO-8859-1">


apart from that i get another strange error:

Line 18, column 12: there is no attribute "HEIGHT"

<TR height="5"><TD></TD></TR>

i checked on an HTML tutorial and there IS such attribure. furthermore, i even use it a few more times and there no mention of it.

any idea why i get those errors?? :cry:

Dani AI

Generated

Short diagnosis and a practical way forward. The validator messages you posted usually mean the parser isn’t seeing the document the way you think it is. Common causes are: a mismatch between the DOCTYPE and the markup style (mixing HTML4 and XML/XHTML syntax), invisible bytes or whitespace before the DOCTYPE (a BOM), or the server sending a different Content-Type than your meta tag. ’s observation about the markup style is useful — the page is likely mixing two different flavours, which confuses the validator.

Troubleshooting steps (in order)

  • Validate the exact source the server is returning: use the validator’s “direct input” or validate the live URL so you’re not chasing forum copy/paste artefacts.
  • Check for invisible bytes (BOM) or stray characters before the DOCTYPE. Open the file in an editor that shows encoding (Notepad++, a hex viewer) and re-save without a BOM if present.
  • Confirm the server’s Content-Type header (browser dev tools → Network or curl -I) and make sure it matches the markup you declare. Serving as XML vs. text/html changes how the document is parsed.
  • Pick one model and stick with it: either make the page plain HTML4/HTML5 (drop XML-style empty-element syntax) or switch fully to XHTML (correct DOCTYPE, xmlns, well-formed XML, appropriate content-type).

Fixes for the two errors you mentioned

  • Stylesheet link: be consistent with the chosen markup. For example, in HTML use a normal link element (no XML-only ending).
  • Table row spacing: don’t rely on a deprecated height attribute on <tr> — use CSS instead. Example:
tr.spacer td { height:5px; padding:0; line-height:1px; font-size:1px; }

Remove presentational attributes and migrate to CSS for predictable, standards-compliant results.

Quick checklist before re-validating

  • Save without BOM, confirm server Content-Type, make the markup consistent with the chosen DOCTYPE, replace deprecated attributes with CSS, then re-run the validator on the live URL. This sequence usually clears the “HEAD not open” and misplaced-META/BODY errors.

The / at the end of the link tag is an XHTML 1.0+ requirement but is not valid for earlier versions such as HTML 4.0 which is how you have defined your page.

The height attribute is implemented by browsers but is not part of the "official" standard. Browsers implement a lot of non-standard attributes and depending on the tutorial/reference site this may or may not be taken into account in the documentation depending on how aware the author is of the actual standards. Basically any non-standard attributes such as height may not be handled as you expect by all browsers - particularly those that are more compliant to the standards (which includes all version 7 browsers).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.