View Full Version : A different question about doctypes
08-29-2010, 07:41 PM
When something goes wrong in a website and someone has suggested changing my doctype, often it works out...
The trouble with this, is I am simply parotting their advice and doing what they say, without knowing why I am doing it.
Where do I start to learn for myself about how to troubleshoot a document at the doctype level and to understand why a certain doctype is having the effect it has on the code?
Otherwise, I just keep coming back and asking "why doesn't this work" and someone says "use this doctype instead" then I'll design another page and that doesn't work and so I have to come back with the same question.... again and again...
Is there just one doctype I can stick to, that will work with all kinds of layouts?
So far all of the information on doctypes has been grossly technical and uses definitions and terms I am not familiar with.
The people who say: "use this doctype" or "that doctype" must know why they are saying it so, if you know about all this stuff, how did you come to learn it in the first place?
I have read the information at the W3C Webschools but am none the wiser, as the doctype itself contains very complicated stuff. When I try reading the lessons, I find I get stuck in a minefield of information and get lost in all the links.
Any help in understanding the basic concepts of this subject will be very gratefully appreciated.
08-29-2010, 09:45 PM
Here is a easy explanation of the doctypes
However I now use the HTML5 doctype
As I write my sites in HTML 5 now.
Hope that helps
08-29-2010, 10:02 PM
HTML 5?! Where did that come from...? Where was 3 & 4?
Must have missed them, trying to code with HTML 2.
What browsers can read HTML 5 then?
Thanks for the link but that's exactly the stuff I've read and already said I can't understand. I'm looking for explanations as to what the stuff in the doctype means. The stuff written about them gets me no closer to knowing which one I should use, which is why I'm asking the question here.
Is that supposed to be a doctype? If so, where's all the other stuff?
08-29-2010, 10:17 PM
Dr. V, keep in mind that this whole web technology is relatively new, and the languages used for the various pieces of it are still evolving. Thus you get new versions of HTML as people decide there are good new features to add, or as people decide a prior feature was a mistake and should be tossed out. Once you've got that in mind, you can see why there would be a "version" of the HTML language (current is 4.01), and that older versions still need to work because not everyone is going to go update their web sites to keep up to speed with old versions.
So as a general rule, a web developer should be keeping up with whatever the current version is, and that means coding to a "strict" doctype. If you've got an older site that you don't want to bring up to date, they provide "transitional" (ie, "the code on this web site is not current, it transitions between old and new code") and "frameset" (specific for sites that use frames. As time moves on, something like <font> for example, is "deprecated" (meaning, "it's in the old language, we wish it weren't, it is no longer supported in the strict definition of HTML"). If you use those deprecated elements, you can, but you need to choose the transitional doctype to do it. You can look at any tag at W3schools (http://www.w3schools.com/tags/tag_font.asp for example) and see what DOCTYPE that tag is legal for, and should of course use the correct DOCTYPE for the style of coding you're going to write.
HTHML 5 is coming down the pipe in the next years (10 years I think?) and the structure around the doctype is available to use even though many of the actual language changes need to be avoided because they're not implemented in browsers yet.
Then there's the choice of XHTML vs. HTML, and XHTML has the same kind of story as I just listed above for HTML. If you're planning on implementing some XML components into your web page, you may want to look at that, but if your intention is to use HTML, then XHTML gets you nowhere.
08-29-2010, 10:54 PM
A “document type declaration” basically tells the browser what kind of language you are using and it’s supposed to read. It contains a URL to a text document that contains the definition of all valid tags and attributes of that specific language.
For example in <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> we see the URL “http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd” which points to the file xhtml1-strict.dtd on the W3C server. If you look into this file you’ll see all the definitions of the tags and attributes that are allowed in that language.
Theoretically you can create your very own doctype and define your very own tags and attributes. But this is only relevant for real XML based applications.
08-30-2010, 12:07 AM
Tracknut, thank you very much for taking the time. That was very concise and easy to understand.
Thank you also, Stephan. I wondered why the doctype contained a 'url'! Now that makes sense and thanks for explaining.
So, would I be right in thinking that if all I really intend for my page is words and pictures (no fancy scripts and computer languages) with a clever expanding div layout expressed in em measurements, that writing my HTML with proper closed tags etc could just be saved as .html and... job done?
Like... I don't need to save it as .XHTML do I?
08-30-2010, 12:40 AM
Don't save as .xhtml because not all servers are configured to serve it properly.
For argument's sake, you have a choice between two DTDs: HTML 4.01 Strict and XHTML 1.0 Strict. The only real difference between the two are that you have to write in an XML serialisation for XHTML. If you don't know what that means, go for HTML 4.01 Strict.
08-30-2010, 03:40 PM
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.