Jump to content

question about the <!DOCTYPE>


jwwlw2008

Recommended Posts

Thank you thescientist!Do you mean I should use <!DOCTYPE html >? I thought if I don't use a DOCTYPE, there would be some problem viewing my website in different browser, is it right? Is H5 DTD backwards compatible? Because my code is mainly H4.01.

Link to comment
Share on other sites

Most HTML 4.01 tags remain in HTML 5. HTML 5 has mostly added content and not removed it. If your page is HTML 4.01 it still is probably better to use the HTML 4.01 doctype:

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

This table shows a list of elements and the HTML version that supports them: http://www.w3schools.com/tags/ref_html_dtd.asp

Link to comment
Share on other sites

Thank you very much Foxy Mod! What will happen if I use one element and a wrong DOCTYPE which doesn't support the element? The browser will not render the content correctly? When I don't use a DOCTYPE, everything seems all right. I haven't seen the importance of such a declaration.

Link to comment
Share on other sites

It actually wouldn't matter much if you use an element that the HTML version doesn't support. Browsers let you do almost whatever you want. If you forget the DOCTYPE, though, the browser will render in "quirks mode". All browsers work basically the same in standards compliant mode, but in quirks mode they all behave differently.

Link to comment
Share on other sites

Thank you!So I better just use one doctype , it's not a big deal. One last thing I promise ;-), do you mean that I can use the strict type declaration and also use elements like <frameset>, and the browsers will still render it correctly and the website will still work well as I expected? The only problem would be some warnings and errors, when I check my webpage with http://validator.w3.org/#validate_by_uri

Link to comment
Share on other sites

Yes, the tags work regardless of which doctype you chose to use. But this is non-standard behavior of browsers which you can't count on happening forever (though it probably will, anyways, since the browsers that render most websites are the ones people like best)

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...