Jump to content
Sign in to follow this  
jwwlw2008

question about the <!DOCTYPE>

Recommended Posts

I just don't know whether I should use the strict one or transitional one, or just <!DOCTYPE html >? And also what if I don't use any of these, just start with <html>? I know it's kind of a stupid question, please help me!

Share this post


Link to post
Share on other sites

you should definitely use a DOCTYPE. At this point, I would recommend using the H5 DTD.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post
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

Share this post


Link to post
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)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...