Jump to content

Doctype: HTML4 vs HTML5, what's better to use?


fablau

Recommended Posts

Hello everyone.I have a question about HTML4 vs HTML5 which is about the used doctype, at the top of the HTML page.I am currently using the HTML4 doctype definition on my website:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"*"http://www.w3.org/TR/html4/loose.dtd">And that’s because "most" of the code used on the page is pre-HTML5, but I am also using some new HTML5 definitions such as the <NAV> tag, the <AUDIO> tag, and others.... so, I plan to update all my pages by cleaning the code to make them fully HTML5 compliant, but what's better doing during this "transition" phase? To update my entire website will take several months, therefore my question is: During this "working" period, is it better to stick with the HTML4 doctype definition I have been using so far (even though I have some HTML5 elements in my pages), or use the newest HTML5 doctype (<!DOCTYPE html>) even if there are tons of deprecated attributes and tags?What really concerns me is what's better for modern browsers. If I try to validate my page with the current used HTML4 doctype like in this testing page below:Download Sheet Music at Virtual Sheet Music® | Classical, Traditional and MoreThe W3 validator at Validation Results - W3C Markup Validator gives me around 10 errors... but if I change the doctype to HTML5 for the exact same page, the validator gives me over 70 errors, mostly because of "obsolete" tags and definitions in the page.Here is the same exact page with the HTML5 doctype I have used for this test:Download Sheet Music at Virtual Sheet Music® | Classical, Traditional and MoreThen… until I don’t really get rid of all old “obsolete” stuff on my pages, what do you think is better doing in my case? Stick with HTML4 doctype or use the newest HTML5 one?Thank you in advance for any thoughts.Best,Fab.

Link to comment
Share on other sites

If you're getting errors even with an HTML 4.01 transitional doctype you really should fix them. Transitional is the most forgiving doctype, if you have errors there your page probably is in need of updating.

 

I would recommend using HTML 5. The longer you wait to upgrade the more work it's going to take when you inevitably have to move on.

 

HTML 5 is compatible with old elements, if you're using any HTML 5 elements at all then use the HTML 5 doctype, even if the page isn't validating.

Link to comment
Share on other sites

  • 3 weeks later...
  • 1 month later...

For e-mails? It doesn't really matter what you use. e-mail HTML code is really different than website code.

 

For a real website stick to HTML 5.

Link to comment
Share on other sites

From a browser standpoint the errors are an issue. The perception that browsers ignore errors is not correct. Every error the validator is finding; the browser also finds during parsing. It then has to execute additional code to create what it "thinks" is the intended code so it can serialize it to the DOM. If it just left the errors and went into the DOM with it, then during layout or painting the rendering engine might encounter an uncaught exception that would hang or crash the browser.

 

So the best way to proceed is to use both doctypes depending on whether a page has been converted, and to validate and FIX THE ERRORS for whatever doctype you are using. If you leave errors, it is just a ticking time bomb and sooner or later a minor change will turn the page to mush because one or more browsers can no longer figure out how to parse it.

 

If it is a commercial site then there is also an SEO issue with the errors, because the crawlers parse the same way a validator does, but unlike a browser, the crawler just keeps going and lowers the quality rating. If they get lost or confused, the simply quit indexing the page.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...