Reputation: 9393
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
I have written my HTML and it is not working the way i wanted in all the browsers.When i gone through the google I found doctype should be declared at the starting of every HTML page.I have seen many wesbites some use HTML4.01 and some say XHMTL 1.0 . and some other webiste I found HTML 5.I dont know which is better to use.Im just learning these stuff from w3schools and some other websites.
Could anyone tell me which is better at the moment and powerful? and what the transitional , strict and loose mean in the doctype?
"http://www.w3.org/TR/html4/loose.dtd">
and what the above line stands for?If I have my own HTMl what should i put at that place? or it should be always the same http://w3..../ please clarify me. Thank You in advance friends.
Upvotes: 0
Views: 86
Reputation: 34164
http://www.w3schools.com/tags/tag_DOCTYPE.asp somewhat explains the differences between various DOCTYPEs. Basically, if you choose the strict doctype, you have to write a neater HTML/XHTML because many clumsy markup such as text directly within body element, framesets, etc. are not allowed.
Transitional doctype is less restrictive. Loose doctype is even less restrictive as the name suggests.
Having said that, these days, HTML5 is getting popular and it has a very simple doctype. Just <!DOCTYPE html>
. It is worth learning HTML5 if you have just begun learning because it is supposed to be neater with more powerful features (especially for audio, video, images, etc.).
Upvotes: 2
Reputation: 723388
HTML 4 is better for compatibility with older browsers. "loose" and "transitional" mean the same thing: "not strict", and are used when some deprecated attributes and elements are in use (e.g. presentational attributes). The part of the old doctype declaration that contains the URI points to the source URI of the original DTD file supported by the declaration. In this case, http://www.w3.org/TR/html4/loose.dtd is the location of the HTML 4.01 Transitional DTD.
HTML5 is more powerful, but all the new features of HTML5 need extra stuff like the HTML5 shiv to get working barely properly in some browsers.
The HTML5 doctype declaration is <!DOCTYPE html>
. There is no PUBLIC
keyword or URI as these aren't needed. The declaration is only there for the sake of standards mode. You can (and should) for the most part just use the HTML5 doctype in your existing old HTML documents, and they should still validate, even if you don't wish to try any of the new features yet on account of browser compatibility. 99% of browsers including IE6 understand the syntax of the HTML5 doctype itself and will render pages with it in standards mode.
Upvotes: 2
Reputation: 1666
The doctype stuff has always been pretty confusing, which is why HTML5 simplified it to this:
<!DOCTYPE html>
No more muss or fuss about DTDs or anything like that. Going on, I'd probably stick with this simplified form, since it's recognized by just about every browser nowadays.
To answer your question about the loose.dtd file, it's a "Document Type Definition" file. It's a special file that explains how HTML is formatted, and some validators will use it to see whether or not your HTML file is valid. Since there's been several versions of HTML (html 4.0, 4.01, XHTML 1.0 loose/transitional/strict, XHTML 1.1) each one has a different DTD.
That's the theory. In practice, it was rarely used that way. But as it happens, doctypes came around the same time as browsers started trying to follow standards in a consistent way. But the problem was that browsers needed some way to tell the difference between an old "quirky" webpage, and a new-fangled standards-compliant webpage. This is what DTDs were really used for: if a browser saw a DTD, it assumed the page should use the new rules instead of "quirks mode".
According to this Wikipedia page on the subject, the new HTML5-style doctype is recognized as standards-compliant (or "almost" standards-compliant) in just about any browser that's relevant, so for the most part, the confusion is over now.
Upvotes: 2
Reputation: 8699
I do not think this syntax is easily understandable. You might get bests results with HTML5:
<!doctype html>
Upvotes: 1