HTML or XHTML?, that is my question. |
HTML or XHTML?, that is my question. |
James |
Jul 20 2008, 12:36 AM
Post
#1
|
Advanced Member Group: Members Posts: 103 Joined: 29-September 06 From: Western Australia Member No.: 269 |
I am no expert on doctype definitions so when building Web pages I usually paste this into the top of my document:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> and stick to the HTML 4.01 specification rules. When validating my HTML I note that, assuming I have made no silly mistakes, the WDG Validator reports no errors, but the w3c validator, while reporting no major errors, it does issue some warnings, and complains about missing information. I note that some notable sites, where you would expect good programming, have something like this: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> QUESTION #1 Is it time to switch to XHTML? ... or ... would that find us writing code which might not work on older browsers? QUESTION #2 What exactly do "transitional.dtd" and "strict.dtd" mean? I have always assumed that 'transitional' will allow some features of the previous version to be coded in the old way, without throwing up an error on validation, whereas I assumed the 'strict' meant you had to stick strictly to the new specification or your document would fail validation. Am I correct, or way off the mark? Many thanks, James |
Darin McGrew |
Jul 20 2008, 01:17 AM
Post
#2
|
WDG Member Group: Root Admin Posts: 8,365 Joined: 4-August 06 From: Mountain View, CA Member No.: 3 |
QUOTE Is it time to switch to XHTML? ... or ... would that find us writing code which might not work on older browsers? If you receive a specific benefit from using XHTML, then go ahead and switch. If you can't name a specific benefit you would receive from using XHTML, then it's better to stick with regular HTML. (A lot of the benefits touted for XHTML can be obtained simply by writing HTML carefully.)We use XHTML on our forum because the best forum software we found used XHTML, and we didn't think there was enough benefit in converting it back to plain HTML. Everywhere else, we use HTML. My personal authoring tools automatically enforce some of the things that XHTML requires, even though I'm writing HTML. QUOTE What exactly do "transitional.dtd" and "strict.dtd" mean? For the most part, Transitional allows presentational markup that is deprecated in favor of CSS, while Strict does not allow that deprecated presentational markup. There are a couple other differences though.Strict does not allow frame-related markup, even though frames are not explicitly deprecated. And Strict imposes certain limitations on what elements can contain (or be contained by) what other elements. For example, loose text is allowed inside body in Transitional, but in Strict, body can contain only block-level elements. All inline (text-level) content must be contained within a block-level element. |
James |
Jul 20 2008, 01:46 AM
Post
#3
|
Advanced Member Group: Members Posts: 103 Joined: 29-September 06 From: Western Australia Member No.: 269 |
Thanks Darin, for all that information which is much appreciated. I will stick to HTML for now.
QUOTE And Strict imposes certain limitations on what elements can contain (or be contained by) what other elements. Would I be right in saying then that everything coded under Strict would run under Transitional? ... but not all Transitional code would run under Strict? You did not express a preference for one or the other. I like to learn things the right way, so, for me, it seems Strict might be best, as I might get into some bad habits in the more accommodating Transitional mode. Apart from having to be spot on with one's code, is there any downside to using Strict? Many thanks, James |
pandy |
Jul 20 2008, 02:03 AM
Post
#4
|
🌟Computer says no🌟 Group: WDG Moderators Posts: 20,733 Joined: 9-August 06 Member No.: 6 |
QUOTE Would I be right in saying then that everything coded under Strict would run under Transitional? ... but not all Transitional code would run under Strict? Yes and no. Everything would run always. Browsers don't care what you call it, you see. Even the most crooked XHTML runs fine as long as you don't actually serve it as XHTML, which hardly anyone does. If they did, most XHTML pages out there wouldn't even display. A soothing thought, that. But you asked about Strict and Transitional. What validates as Strict will also validate as Transitional while the opposite mostly isn't true. Transitional is Strict with additions, you could say. It contains all of Strict + all the presentational stuff Strict is (almost) free from. |
Darin McGrew |
Jul 20 2008, 02:20 AM
Post
#5
|
WDG Member Group: Root Admin Posts: 8,365 Joined: 4-August 06 From: Mountain View, CA Member No.: 3 |
For my personal site, I use a custom DTD that is basically 4.01 Strict with one modification to allow <base target="_top">.
|
James |
Jul 20 2008, 02:30 AM
Post
#6
|
Advanced Member Group: Members Posts: 103 Joined: 29-September 06 From: Western Australia Member No.: 269 |
Thanks to both of you, Darin and Pandy, for that - I will stick with 4.01 Strict
Cheers, James |
Frederiek |
Jul 20 2008, 05:39 AM
Post
#7
|
Programming Fanatic Group: Members Posts: 5,146 Joined: 23-August 06 From: Europe Member No.: 9 |
QUOTE When validating my HTML I note that, assuming I have made no silly mistakes, the WDG Validator reports no errors, but the w3c validator, while reporting no major errors, it does issue some warnings, and complains about missing information. With a simple HTML Strict file (taken from http://htmlhelp.com/reference/html40/structure.html#doc), both validators returned no errors or warnings. Have you sorted out your validation tests, or can you post the URL of a page that produced the difference? |
Peter Evans |
Jul 21 2008, 10:16 AM
Post
#8
|
Advanced Member Group: Members Posts: 109 Joined: 24-August 06 Member No.: 13 |
A further difference between strict and transitional is that invoking the latter (or more broadly failing to invoke the former) puts various browsers into "quirks mode". This is something like "lamebrain mode"; the browser "thinks" (if that's the right word) "This page was probably written by some simple soul who actually thinks that old versions of Internet Explorer got CSS right, so I shall pretend to be an old version of Internet Explorer (though with not quite so many bugs)".
QUOTE And Strict imposes certain limitations on what elements can contain (or be contained by) what other elements. For example, loose text is allowed inside body in Transitional, but in Strict, body can contain only block-level elements. All inline (text-level) content must be contained within a block-level element. Yup! You may have guessed it: The incompetent who just wants to boast that he can use "Strict" and get the result to validate puts the entire page within a single, meaningless DIV: <body> <div><!-- No class, ID, or style necessary! --> All kinds of crap go here. </div> </body> |
pandy |
Jul 21 2008, 11:31 AM
Post
#9
|
🌟Computer says no🌟 Group: WDG Moderators Posts: 20,733 Joined: 9-August 06 Member No.: 6 |
Not if all kinds of crap include deprecated stuff.
|
Frederiek |
Jul 21 2008, 11:47 AM
Post
#10
|
Programming Fanatic Group: Members Posts: 5,146 Joined: 23-August 06 From: Europe Member No.: 9 |
Yes, there are, in both the WDG and W3C validation tools/services. |
Christian J |
Jul 21 2008, 03:47 PM
Post
#11
|
. Group: WDG Moderators Posts: 9,661 Joined: 10-August 06 Member No.: 7 |
Even the most crooked XHTML runs fine as long as you don't actually serve it as XHTML, which hardly anyone does. If they did, most XHTML pages out there wouldn't even display. A soothing thought, that. Just to clarify, "serve" in this context is about the Content-Type header sent by the server along with the HTML file: http://www.w3.org/TR/xhtml-media-types/ QUOTE What validates as Strict will also validate as Transitional while the opposite mostly isn't true. When you say "mostly", which exceptions are there? |
pandy |
Jul 21 2008, 04:07 PM
Post
#12
|
🌟Computer says no🌟 Group: WDG Moderators Posts: 20,733 Joined: 9-August 06 Member No.: 6 |
|
Christian J |
Jul 21 2008, 04:10 PM
Post
#13
|
. Group: WDG Moderators Posts: 9,661 Joined: 10-August 06 Member No.: 7 |
A further difference between strict and transitional is that invoking the latter (or more broadly failing to invoke the former) puts various browsers into "quirks mode". Not necessarily, a Strict DTD like CODE <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> may put some browsers into quirks mode (IE6 always goes into quirks mode if there's anything before the DTD, including the XML prologue in the example above), while a Transitional DTD like CODE <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> or CODE <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> puts most browsers into "standards mode". See also http://hsivonen.iki.fi/doctype/ IMO one shouldn't equal Strict/Transitional with "standards/quirks mode", since the former are HTML specs from the W3C and the latter are unrelated rendering modes invented by various browser vendors (rendering modes that --to add insult to injury-- mostly affects CSS rather than HTML rendering). QUOTE This is something like "lamebrain mode"; the browser "thinks" (if that's the right word) "This page was probably written by some simple soul who actually thinks that old versions of Internet Explorer got CSS right, so I shall pretend to be an old version of Internet Explorer (though with not quite so many bugs)". I recall Mozilla/Firefox/Gecko tries to emulate some of Netscape4's bugs too. In any case every browser vendor has different "quirks modes". QUOTE QUOTE And Strict imposes certain limitations on what elements can contain (or be contained by) what other elements. For example, loose text is allowed inside body in Transitional, but in Strict, body can contain only block-level elements. All inline (text-level) content must be contained within a block-level element. Yup! You may have guessed it: The incompetent who just wants to boast that he can use "Strict" and get the result to validate puts the entire page within a single, meaningless DIV: <body> <div><!-- No class, ID, or style necessary! --> All kinds of crap go here. </div> </body> Actually at least FORM may not contain inline elements like INPUT in Strict HTML. Invalid: CODE <body> <div> <form action=""> <input type="hidden" name="foo" value="bar"> </form> </div> </body> Valid: CODE <body> <form action=""> <div><input type="hidden" name="foo" value="bar"></div> </form> </body> |
Christian J |
Jul 21 2008, 04:13 PM
Post
#14
|
. Group: WDG Moderators Posts: 9,661 Joined: 10-August 06 Member No.: 7 |
|
pandy |
Jul 21 2008, 04:21 PM
Post
#15
|
🌟Computer says no🌟 Group: WDG Moderators Posts: 20,733 Joined: 9-August 06 Member No.: 6 |
Thickness, thy name is Christian J.
|
Lo-Fi Version | Time is now: 28th April 2024 - 05:03 AM |