Is there an easy way to figure out which doctype is the correct type when using the http://validator.w3.org validator?

Dani AI

Generated

Short, practical guide to picking and fixing a doctype for legacy pages (grounded in this thread with and )

Choosing a doctype is mostly about two things: matching the kind of markup already used, and getting browsers into standards mode so rendering is predictable. For new work the modern choice is the HTML5 doctype because it is simple and widely supported; for older, unchanged sites it is acceptable to keep a legacy doctype as long as the markup actually conforms to it.

A minimal HTML5 starter (safe, modern doctype):

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Document</title>
</head>
<body>
  <!-- existing markup -->
</body>
</html>

Practical validation workflow and troubleshooting

  • Run a validator and fix the first reported error first; many later errors are cascade effects.
  • Look for structural problems (mismatched or missing end-tags, bad nesting, broken attribute syntax) rather than presentation-only issues.
  • Use the browser’s Elements inspector to see how the parser reconstructed the DOM — it often shows where tags were implicitly closed or moved.
  • For quick automated fixes, run HTML Tidy or a linter; it can catch encoding, quoting, and nesting problems.
  • When stuck, prefer small, non-visual fixes first (close tags, add a charset meta near the top) so presentation stays the same while markup becomes valid.

Notes and context

  • Validation is a tool, not an absolute rule: some deprecated presentational markup can remain if project constraints require it, but cleaning structural errors prevents surprising cross-browser differences. More background on doctypes and browser modes is available from the HTML Living Standard and MDN: WHATWG spec and .

Recommended Answers

All 9 Replies

Meaning did you run the validator and one of your errors is no doctype??

one of them was no doc type, and now that i added the html 4.0 transitional doctype, i have 3 errors... i uploaded a screen shot of the errors

what doctype do i need if i want to include <h1> and <h2> etc. tags?

All doctypes support ALL html tags, however there are variances on how they're closed, where they are used, and whether they're all caps or not.

Can you post a live link to your site? Then I can see exactly what the errors are and maybe whats going on.

If you read the explaination of the error and possible reasons for the error, you can get some ideas about whats wrong.

Block level elements cant be placed inside inline elements.


as well as the price list link page.

Thanks

You have a doctype of 4.01 Transistional. Not sure then what you're asking. The only error on your page you linked above is that you didnt close the <center> tag with </center>

Which by the way is way out dated(deprecated) and shouldn't really be used. Along with your table based layout, but all that is another discussion.

If you add </center> right above the last </div> tag, the page validates.
The other page passes as well. So what are you asking/looking for??

Well i was trying to figure out if i had used the correct doctype in the first place, which i guess i did. Thank you, lol

But the center tag needs to be closed.. i missed that completely.

(yeah, i know its all outdated, BUT it's the layout my boss created like 10 years ago, and he does not want to change it...he's very happy with it... so im working with what i've got to work with. lol)

Thank you veryyy much for your help. I appreciate it!

BUT it's the layout my boss created like 10 years ago, and he does not want to change it...he's very happy with it... so im working with what i've got to work with. lol)

Yes, I too face a similar dilema every day with regards to employers having outdated crazy page layout and website ideas.

Glad to help! Good luck.

btw, unless your going to be dealing with xml or MathXL, then HTML 4.01 should suffice for all your needs. More can be read here.

commented: Thank you! +1

A bazillion times, Thank you! :)

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.