HTML 4.01 vs. XHTML 1.0 - html

Which one is better and why for a new project? I'm assuming all will be strict, as I see no reason to go transitional for a new project.

HTML 4.01 vs. XHTML 1.0
The problem with both of these is that they have been effectively rendered obsolete by HTML5.
In fact, you're really asking the wrong question. HTML4, XHTML and HTML5 are basically the same language, but with certain features missing from one to the other.
The really important thing (and probably the reason why you may feel like you have to choose) is that it is important to specify a doctype, in order to prevent older browsers dropping into quirks mode. At the point where you find you have to specify a doctype, you also find yourself presented with a choice of which one to use, and the syntax makes it look like you have to get it absolutely perfect or it'll all stop working.
But you don't need to worry about that. The following doctype is sufficient to make all current browsers (including IE6) run in standards mode:
<!DOCTYPE html>
Simple, eh? No need to worry about HTML4 vs XHTML at all.
The thing is, the above doctype also happens to be the doctype for HTML5. It was chosen deliberately because it works in existing browsers.
If you need to support older browsers, you don't have to use HTML5's flashy new features, but using this doctype means that you will be ready to use them when the time comes. And if you do feel like dipping your toe in the water, a lot of the new features will degrade gracefully in older browsers, so you can use them; they may not work in IE6, but they won't break the browser either.
I hope that helps.

If you are using an XML toolchain, and it can handle HTML compatibility (which is needed for IE 6-8) then you might consider going with XHTML, otherwise go with HTML.
If any of the features added in HTML 5 are going to be useful to you, and browser support for those features is mature enough then go with (X)HTML 5, otherwise go with HTML 4.01 / XHTML 1.0 as they have more mature QA tools.

If it's for a new project, start reading up on HTML5. It has the best of both, without the tag soup and doctype madness of XHTML.

XHTML (or HTML 5, for that matter).
We're talking about +10 years in web evolution. If you're the web developer or designer, go Strict and validate your code - it will assure that your site (given valid CSS) will display correctly in most operating systems and web browsers. It will be easier to maintain. It will make you a better webdev because you'll know and understand semantics. It will be easier to migrate to HTML 5 in the future too.

Related

Technical reasons for using HTML5 doctype, instead of 4.01 strict

I'm working on a new website, and I want to support as many old browsers and operating systems as possible, as easily as possible. From what I've been reading, I know I'm better off avoiding quirks mode, so I need to decide on the best doctype. And everyone seems to be recommending the HTML5 version:
<!DOCTYPE html>
But according to this website, that also recommends the HTML5 version:
https://hsivonen.fi/doctype/, that doctype will trigger quirks mode in Netscape 6, and maybe in Konqueror 3.2. But this one:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
won't trigger quirks mode in any browser listed on that website.
So my question is, is there any reason why I shouldn't use the 2nd doctype? I know those are really old browsers I'm concerned about, but I've seen recent statistics saying Netscape 6 is still in use, at least in Russia. And where I live, I still see a lot of people using Windows XP. So while I don't want to spend a lot of time supporting obsolete browsers, I'm wondering if there are any disadvantages to using the 2nd one, other than it's longer and looks complicated.
edit: All the answers and comments posted so far, have been really helpful. Now I'm starting to see that it's a tradeoff between:
1) being semantically correct, and
2) putting more of the very old browsers into standards mode, instead of quirks mode
In most cases #1 is probably more important, since not many people use those really old browsers. And if they do, they're probably used to things looking a little off. But if you're more concerned about things looking better in really old browsers, then #2 could be a better choice.
Anyway, I'll wait a while to see if anyone adds any more answers or comments. Thanks!
edit 2: All 3 answers were helpful. And 2 of them helped me understand specifically what I needed, so I selected one of those. But I would have selected both, if I could have.
The only reason I can think of is that if you want or need to use HTML 5 in the future you'll be able to with more ease already doing everything in HTML 5.
And browsers should have no problem dealing with the fact that it's strict 4.01 and will display it just as if it didn't have the doctype anyways.
Basically from a "what the page looks like" point of view your strict 4.01 will look the same in a html 5 doctype as it will in a strict.
Having said that, it does depend on your HTML there are certain times that you'll need to do it but chances are it shouldn't matter
Really good link for further info on doctype declarations:
http://www.htmlgoodies.com/html5/markup/the-doctype-tag-and-its-effect-on-page-rendering.html#fbid=JCm-bKCUNc6
There are several reasons:
Old browsers(those that doesnt support html5) wont be forever, one day the will be gone but those browsers that can support html5 will take long time in order to be a "old browser". So try to take advantages of all those new html5 feactures.
HTML5 has some new tags that are better for S.E.O
HTML5 Introduced new video codecs that will improve the audio and video experience.
HTML5 introduced a really drag and drop feature!
So what I suggest you is to use html5 and try do your best to make "old browsers" run your html5 website.
I would just use the , but not use any HTML 5 specific features, I think that would work nicely. Older browsers try to render the page as good as they can. In any case, if you DO want to use HTML 5 features, you can always see if they are available in your javascript code or use a framework such as modernizr.
According to me main reason is that :
<!DOCTYPE html>
Html5 : Supports header, footer and section tag. And this tags are easily readable to google for "Search Engine Optimization". So, google takes it as important content on our page.
And for "4.01 strict" :
These header, footer and section tags are not supported.

Should a production site use HTML5 or XHTML1 Strict?

I'm designing a small buiness's website, and I'm windering if I should use HTML5 or XHTML1. I know that HTML5 is more advanced, but it is still a changing spec, while XHTML1 is finalized, so there won't be any compatibility issues in the future. Which one should I use?
HTML 4.01 Strict is the best toy to play with. HTML 5 is not ready, and while it doesn't hurt to include some of its features to enhance your site, where they are supported in some browsers and don't cause others to fall over, it isn't worth investing too much time and effort when the spec could still change significantly.
Unless you know that no-one wanting to visit your site will be using any form of Internet Explorer (up to and including IE8), there's no point in worrying about XHTML. You can only serve it as XHTML, so you don't get any of the advantages of the X, you just end up having to jump through more hoops and run with messy code to achieve the same outcome.
There is no big difference, html5 doctype (<!doctype html>) works correctly in all browsers and corresponds to transitional mode in old browsers. If you wonder should you use new semantic tags from html5 than I can say that there is a simple trick to make them works fine in all browsers.

Question on syntax of doctype. And also in need of some suggestions

<!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.
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.
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.
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.).
I do not think this syntax is easily understandable. You might get bests results with HTML5:
<!doctype html>

Is the HTML5 DOCTYPE the last one we will see?

The rather terse HTML5 doctype, <!DOCTYPE HTML>, seems to indicate that this the last HTML doctype we will see. Is this really true?
From what I understand the primary function of the various doctypes was to turn on the numerous quirks rendering modes of modern browsers. Surely there is nothing stopping this from happening again? i.e. people writing web=-pages against a 'broken' browser implementation, resulting in future browsers needing to employ doctype sniffing?
The idea of the new html standard is that it should be forward compatible.
If new standards arrive (html 6?) they should render normally on html 5 renderers, just not have all the new (future) features.
Read more about it here: http://www.alistapart.com/articles/semanticsinhtml5
(somewhere half way the page)
Another reason for the short doctype is that html5 has no DTD.
This question is probably quite subjective (no, I'm not voting for close). I think the W3C guys are quite optimistic (idealistic) about browser implementation of their standards, and so in that view we shouldn't need more doctypes. Any future HTML versions (in 2030ish?) will just add to the current one to allow for new technologies (because after all, it's perfect!) and so browsers will just need to implement the new features.
How it actually happens, I think we'll just have to wait and see. I predict that in some way, they will regret the terseness of <!doctype html>, although for what reasons I can't be sure.
I think that the "doctype html" will be enough.
http://blog.whatwg.org/html-is-the-new-html5
No more HTML4, HTML5 or HTML6... just HTML. They are moving from versioned to unversioned development model. Just a standard that is continuously evolving. So from now on, we should not ask whether my browser supports HTML5 or HTML6, but which are the features supported by my current browser.
Regarding to follow the standards, I think that the developer will be no more the only one to worry about this. Actually there is no browser with a market share big enough to impose its owns, (and even internet explorer its taking very seriously to implement the standards now)

If I use HTML 5's doctype, what will happen?

I have recently been learning about doctypes, and was I wondering what the differences between <!DOCTYPE html> and some of the others were.
I know <!DOCTYPE html> is the HTML5 doctype and it is experimental, but I was wondering what would happen if I used it instead of the other doctypes?
Thanks in advance!!!!
Basically what will happen is that you'll get your page rendered in a "standards mode".
The only reason why you probably shouldn't use the new DOCTYPE is if you want to use XHTML 1.0 markup and conform to XHTML 1.0.
The downside to using HTML5 now is that the spec can change. This makes it important for you to keep up with the spec as it actively changes.
With that being said, I've already started using the new syntax in my pages. Also it guarantees that your page will last for a very, very, long time.
So go ahead, use it (and learn to love how simple it is).
The HTML5 doctype isn’t experimental. Ian Hickson tested a bunch of browsers, and found that <!DOCTYPE html> worked the same in them as the HTML 4 and XHTML 1 doctypes (i.e. it triggered standards mode).
However, if you use it, then validators will (by default) validate your page as if it’s HTML5, which may not be what you want if you’re actually writing HTML 4. (For example, some elements are getting dropped in HTML5. Using them would show up as an error if you validated your page as HTML5.)
Lucas nailed the most important aspect. Let me explain this in a slightly different way:
In the browser the doctype serves exactly one purpose, to set the rendering mode: Quirks, almost standards and full standards mode. This used to be simple until MSIE 8 introduced a second switch, "compatibility mode" = MSIE7 bugs and limitations are preserved on purpose.
An HTML5 doctype will (usually) override that setting, and is thus somewhat more powerful than XHTML 1.x or HTML 4.01 doctypes. (MSIE may override it sometimes, though.)
The definitive guide to doctype switching and layout mode is at: http://hsivonen.iki.fi/doctype/
The second thing that will happen is that you get your pages validated according to the HTML5 rules. Some elements and attributes that were allowed in HTML 4 are gone and a bunch of new ones have come.
Edit: Removing example. Mixing what used to be known as inline and block elements is now OK. (In the original proposal it was not.)
The semantics and syntax for HTML5 is mostly like the one in HTML 4, so most well written HTML 4 sites will continue to validate. The main difference is that you mat start to use the new stuff and still be valid.
There's nothing illegal about
<div>
<p>foo</p>
<span>bar</span>
</div>
(The terms 'block level' and 'inline' elements are obsolete in HTML5.)