Jump to content

which DOCTYPE


ev66
 Share

Recommended Posts

which is the correct Doc type for java script and html, is it -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">or<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml">or<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">or<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">or<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html xmlns="http://www.w3.org/1999/xhtml">Thanks

Link to comment
Share on other sites

In my little knowledge of this world I dont think that JavaScipt files need a DOCTYPE

Link to comment
Share on other sites

You don't need one. The only thing that needs a DOCTYPE (To my knowledge) is XHTML. You can use one for HTML but it isn't required.
You are correct. An HTML file does not "require" a DTD, but in order to have the Browsers play well with the html code, it is very highly reccomended that you use a DTD in order to avoid the Browser using "quirks" mode when it renders your page. A correct DTD will standardize the rule the Browser uses. A faulty DTD, or lacking a DTD, lets the Browser define its own rules about the rendering and you will lose any consistency between pages. In short, use any DTD you wish, but code to the DTD you have selected.As for javascript, there is not any single DTD which javascript requires, but the more demanding the DTD, the less likely that the html validators will approve of the code. The best way to "validate" an html file using javascript is to seperate the javscript into a seperate external file.
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
 Share

×
×
  • Create New...