Click to See Complete Forum and Search --> : Benefits of XHTML 1.x vs 4.01 Strict


toicontien
09-28-2003, 12:20 PM
Here's a question for the standards compliance gurus out there.

What are the real-world benefits of using XHTML vs HTML 4.01:

1. At present

2. and in the future

I know that XHTML will work on any browser. It's the accompanying CSS that chokes things up. So what else can you do with XHTML that you can't with 4.01?

For example, is it easier to include RSS feeds on a Web site if the site is coded in XHTML?

Charles
09-28-2003, 12:37 PM
1) XHTML will not work on every browser, not unless you follow the "HTML Compatibility Guidelines" given in Appendix C of the XHTML 1.0 Specification.

2) The CSS doesn't choke anything up. By properly using HTML 4.01 Strict and CSS you end up with a page that works on all browsers.

3) XHTML 1.0 is simply an XML version of HTML 4.01.

4) XHTML 1.1 is simply XHTML 1.0 Strict.

5) XHTML 2.0 isn't out yet.

6) XHTML documents are simply more accessible to non human users. I frequently use XHTML 1.1 documents, add a few things to the DTD and then process them with an XSLT processor to generate an HTML 4.01 version of some document and use XSL-FO to generate a PDF version.

toicontien
09-28-2003, 12:51 PM
By CSS choking things up, I should have wrote that browser support for CSS chokes things up.

I'll have to look into XSLT and XSL-FO more on w3.org. One follow up question: since MS IE came out a couple years ago, which I assume was before XHTML 1.1 was finalized, does IE go into quirks mode because it doesn't recognize the 1.1 doctype? I personally have never done any experimenting in this matter. Same question for NS 6 and 7, and Mozilla 1.0.

Khalid Ali
09-28-2003, 12:52 PM
Originally posted by toicontien
......For example, is it easier to include RSS feeds on a Web site if the site is coded in XHTML?

As of today I don't see anything in XHTML that will do that,you have to keep in mind that html/XHTML itself does not do any processing,hence limiting its ability to directly figure out that you are loading a RSS file.
You will always have to use some kind of processing utility to process the RSS(XML) feed to create a humanly readable data to put on your HTML pages.

I am planning to write an applet for my site ( link below) to display news from InfoWorld and Yahoo! news RSS feeds,Check back their in couple of weeks to see that its accomplshed(provided my wife allows me to spend some time on this project..:D )

MotherNatrsSon
09-28-2003, 03:07 PM
2) The CSS doesn't choke anything up. By properly using HTML 4.01 Strict and CSS you end up with a page that works on all browsers.

That is not necessarily true. I can make a page using CSS 1 only, that looks great and works in Netscape 7/Mozilla and it will not work cross browser without applying "hacks".

If you really want a site to be compatible with 3x or 4x browsers the best you can do is to use a 4.01 transitional doctype and use depricated tags that are allowed only in that doctype.

I would be interested in seeing a site with one stylesheet, no browser sniffer or redirection to alternate pages that works in all browsers, that is not extremely simple layout. Like maybe one div......LOL

For my business site, I still have people using 3x browsers to visit and I cannot afford to have them get a "text-only" version of the site because somebodies standards are saying HTML is out.

Until there is a mass exodus away from IE 6, 5.5, 5.0 imho there is no need to use CSS unless you want to write multiple style sheets, use a javascript browser sniffer and redirect by browser and OS versions. It really is not practical.

My personal site is coded to xhtml 1.0 strict and has a CSS 2 menu on it that only work in Netscape and Mozilla because I do not have javascript "powering" the menu for the rest of the browsers that cannot handle the CSS 2 selectors.

You need to know more "hacks" than actual CSS to get a page cross browser cross platform using CSS without javascript or serverside intervention.

MNS

toicontien
09-28-2003, 08:22 PM
MotherNatrsSon,

I designed my college's newspaper's web site using XHTML 1 Transitional with a CSS layout. It works on all browsers, though I've had to hide the layout from older browsers with the @import "" method. That really isn't a "hack."

http://www.cm-life.com/

Also, see:

http://www.cm-life.com/pages/newdesign/ (note: there are some issues with IE5/Mac that I haven't had the time to look into).

Visit both sites with older browsers. I'm confident your won't have any problems with 4.x and newer browsers. I don't have access to 3.x browsers to test the design on, so any info on how those browsers react would be appreciated.

But the only thing that might cause display problems is the CSS. And since 3.0 browsers hardly support CSS1, they shouldn't have a problem at all with either design. It just won't look pretty that's all.

BUT

If a good portion of a web site's visitors use 3.x and 4.x browsers, there's nothing wrong with cartering to your customers and using tables and deprecated tags. After all, they are the customers and you are getting paid to produce a product that they want.

Fang
09-29-2003, 01:07 AM
toicontien wrote
... does IE go into quirks mode because it doesn't recognize the 1.1 doctype?

No, it goes into quirks mode if you include the xml decaration:
<?xml version="1.0" standalone="yes"?>
Use a valid DTD (http://www.w3.org/QA/2002/04/valid-dtd-list.html) (except HTML 3.2 and 2) to keep IE in standards mode.

pyro
09-29-2003, 07:22 AM
And you can get around it by specifying a Content-type instead:

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

That will allow you to use a XHTML DTD and not throw IE into quirks mode.

Fang
09-29-2003, 07:40 AM
But ... the charset should be utf-8 (http://www.w3.org/TR/xhtml1/#C_1) not iso-8859-1

pyro
09-29-2003, 08:09 AM
Yes, it looks like you are correct. My bad...

toicontien
09-30-2003, 09:47 PM
What I get from the posts above is that there is no real-world benefit from coding in XHTML compared to HTML 4.01 Strict.

Is that safe to say?

pyro
09-30-2003, 10:56 PM
From what I can tell, I wouldn't say there are any major benefits (over HTML 4.01 Strict). I personally like it, because it take out some of the slop in HTML, such as some tags needing to be closed, while other didn't, and having unquoted attributes, etc... It's much more balanced. Even when using HTML 4.01, I use a lot of XHTML techniques/requirements. One possible real world benefit would be forward compatability, though I don't see HTML 4.01 disappearing for quite some time.

MotherNatrsSon
10-01-2003, 01:58 AM
Originally posted by toicontien
MotherNatrsSon,

I designed my college's newspaper's web site using XHTML 1 Transitional with a CSS layout. It works on all browsers, though I've had to hide the layout from older browsers with the @import "" method. That really isn't a "hack."

http://www.cm-life.com/


Yoou have multiple style sheets and a javascript to direct peopleto the right stylesheet as well. I wonder what it looks like to people with javascript off? Can't and won't use javascript browser detection on my business site because you can't use it as a crutch, because not all people use javascript.

MNS

Charles
10-01-2003, 05:04 AM
1) If all you are doing in the "real world" is publishing a web site then HTML 4.01 Strict is just fine, though spiders and other non-human users are going to find it easier to understand XHTML.

2) You don't need JavaScript and browser sniffing or any hacks to make a page work with a CSS layout. You only need the @import rule to hide a few things from CSS1 browsers. You can also, if you want to get fancy, easily use a server side script to serve browser specific style sheets.

Robert Wellock
10-01-2003, 09:29 AM
Additional benefits of module based XHTML 1.1 are when both Opera 7.20 and Mozilla 1.x actually understand how to accept it with the relevant MIME type "application/xhtml+xml" which reduces rendering times obviously once again Micro$oft drags its heels...

I have over 190 XHTML Basic 1.0 documents online severed as 'application/xhtml+xml' to conforming user-agents I just haven't published them in the public domain yet.

toicontien
10-01-2003, 10:43 AM
Again, MotherNatrsSon...

Turn Javascript off in Netscape or Mozilla and visit http://www.cm-life.com. You'll see that even the main menu rollover affects still work and the site still renders. Here's why:

1. Javascript is ONLY used to dynamically write the banner and tile ads in. This is part of our agreement with our web hosting provider.

2. CSS 1.0 style sheets are fed through the link tag.

3. CSS 2.0 style sheets (and any additional CSS 1.0 formatting for newer browsers) is fed through the @import method in the style tags:


<style type="text/css">
<!--
@import "url_to_style_sheet";
-->
</style>


The above is CSS, not Javscript.

4. Yes I do use multiple style sheets, but no server or client side sniffer feeds the proper style sheet to what ever browser is viewing the site.

CSS can be written so that you don't need to feed different style sheets to different browsers using user agent sniffers of any sort.

You may be interested in the articles below:

http://www.alistapart.com/stories/journey/
http://www.alistapart.com/stories/flexiblelayouts/
http://www.alistapart.com/stories/taminglists/
http://www.alistapart.com/stories/goingtoprint/
http://www.alistapart.com/stories/doctype/
http://www.alistapart.com/stories/betterliving/
http://www.alistapart.com/stories/alternate/
http://www.alistapart.com/stories/practicalcss/

PunkSktBrdr01
10-02-2003, 05:16 PM
I know this isn't totally on topic, but how do you use XHTML with PHP. PHP is reading the <?xml as opening a PHP code block.

pyro
10-02-2003, 05:22 PM
Yes, you'll want to use something like this:

<?PHP
echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n";
?>

PunkSktBrdr01
10-02-2003, 05:27 PM
Is the <?xml really necessary? Also, is this correct for an XHTML page:

<meta http-equiv="content-type" content="text/html; charset=UTF-8" />

Thanks.

pyro
10-02-2003, 05:35 PM
No, the <?xml is not necessary, as long as you specify a Content-type, and as long as you use UTF-8 or UTF-16 (as Fang pointed out above) for your encoding. http://www.w3.org/TR/xhtml1/#C_1

PunkSktBrdr01
10-02-2003, 05:45 PM
Okay, thanks.

Charles
10-03-2003, 06:13 AM
Originally posted by pyro
No, the <?xml is not necessary, as long as you specify a Content-type, and as long as you use UTF-8 or UTF-16 (as Fang pointed out above) for your encoding. http://www.w3.org/TR/xhtml1/#C_1 Pleas note that iso 8859-1 is a subset of utf-8 and that ASCII is a subset of 8859-1.

pyro
10-03-2003, 07:07 AM
So are you saying that if the <?xml prolog is not used, you may still use ISO-8859-1 as your Content-type?

Charles
10-03-2003, 07:13 AM
Originally posted by pyro
So are you saying that if the <?xml prolog is not used, you may still use ISO-8859-1 as your Content-type? I don't se why not. But if you are worried you can use ISO-8859-1 and call it utf-8.

pyro
10-03-2003, 07:29 AM
No, not worried, just curious if it was valid code. I used the ISO-8859-1 charset on my site with XHTML 1.1 and no <?xml prolog and thought it was valid until Fang said it was not. I then looked on the W3C's site, and found where they said you must use UTF-8 or UTF-16. But, if ISO-8859-1 is a subset of UTF-8, it would seem plausable that one could use it.

Khalid Ali
10-03-2003, 07:55 AM
The biggest possible benefit of using XHTML is a bit futuristic. since means to access the internet are being evolved fast,there was need for a uniform markup that can be integrated with any web accessing technology. Which means the ultimate goal for XHTML is to be accessed by any user agent from any type of web accessing technology.

Robert Wellock
11-05-2003, 01:00 PM
No the W3C does not say you have to use UTF-8 though that is the default for XML.

For example: http://www.xhtmlcoder.com/beck/ is served as an application of XML; use the W3C Validator, Opera 7.2x or Mozilla if you want see the pages in that directory to be served as an application of XML rather than text/html which is the case with most of XHTML on the web.

It's only a beta site so I haven't fixed the XML CSS link issue yet.

nkaisare
11-07-2003, 06:28 PM
Toi,
If your site is already HTML 4.01 Strict, its not a big task to go to XHTML 1.0. What is the advantage of keeping it 4.01 Strict? Unless of course you used CAPS tags or attributes. Replacing empty <tag> with <tag /> and closing unclosed elements is not a big job for personal and small business sites. Advantage is conforming to stricter standards leaves you in a good stead for future.

Pyro,
Since your site is in English, you don't really need to change from iso-8859-1 to utf-8. Its a recommended practice to use the latter because the former is a subset of the latter. But I refuse to do that simply because I am too lazy to edit my template options.

MTS,
Accessible in any browser does not mean "looks the same in all browsers". A table-based site usually is inaccessible to PDAs (unless due care has been taken to make it PDA-accessible). Check out my site:
http://www.prism.gatech.edu/~gte207x/
I have<link rel="stylesheet" href="styles/basic.css"
type="text/css" media="all" />
<link rel="stylesheet" href="styles/print.css"
type="text/css" media="print" />
<link rel="stylesheet" href="styles/zunflowerlike.css"
type="text/css" media="screen" />
Hence you should see the "nice" layout in a v5+ browser but the contents will be accessible to NS4 and older browsers too.

Fang
11-08-2003, 02:31 AM
nkaisare said:
Since your site is in English, you don't really need to change from iso-8859-1 to utf-8. Its a recommended practice to use the latter because the former is a subset of the latter. But I refuse to do that simply because I am too lazy to edit my template options.
The point was if no XML declaration is used then you should use utf-8 (http://www.w3.org/TR/xhtml1/#C_1).
Are you also too lazy to write valid xhtml pages?

pyro
11-09-2003, 06:07 PM
Originally posted by Fang
nkaisare said:

The point was if no XML declaration is used then you should use utf-8 (http://www.w3.org/TR/xhtml1/#C_1).While that might have been the original point, it seems to me the discussion has turned to whether or not it is valid to use ISO-8859-1, as it is (apparently - didn't check) a subset of UTF-8.

spufi
11-09-2003, 06:36 PM
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />

I use the XHTML 1.1 DTD and that as my <meta> tag and I don't use the <?xml?> one and it validates as XHTML 1.1 using W3C's validator.

Robert Wellock
11-11-2003, 10:33 AM
Yes, it will do but you aren't serving it as an application of XML you are just validating against well-formed XHTML served as text/html not XHTML as an application of XML or served as Valid XML - well-formed and valid differ the W3C Validator just checks for well-formed XHTML.

And XHTML itself is just is well-formed XML.


Well-formed documents are well-formed because they do not have to be created in a structured environment, against a pre-defined set of structural rules, but merely have to comply with XML well-formedness constraints.

The primary difference between valid and well-formed XML is their relationship to a document type definition. Well-formed XML is designed for use without a DTD, whereas valid XML explicitly requires it.

spufi
11-14-2003, 12:00 PM
Ok, so after some searching around, I came across http://www.goer.org/Markup/TheXPhiles/ which has their little test to see just how true a site's XHTML is. Now, I understand IE chokes on the <?xml version="1.0"?> part. How far back in terms of versions are browsers like Mozilla/Netscape and Opera with it? Secondly, I saw at least one site that went and defined their CSS by defining it in XML versus using the standard <link> tag. I then went and tried this and for some reason this isn't working for me. Here's the PHP code I'm using to generate the top of my page so far.

<?PHP
echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n";
echo "<?xml-stylesheet type=\"text/css\" href=\"styles4.css\"?>\n";
?>

PunkSktBrdr01
11-14-2003, 02:52 PM
I'm probably wrong, but I think that the xml stylesheet is for XSL, and is meant format actual XML instead of XHTML.

spufi
11-14-2003, 10:18 PM
You can use CSS with XML. XSL/XSLT is much more powerful and is used more often with XML, but CSS still works. The idea that Robert brought up was that most times XHTML pages are basically well formed HTML and not really on the XML side of things. I was just trying to see what it took to accomplish this task.

Robert Wellock
11-17-2003, 10:25 AM
The X-Philes "The XHTML 100" is little misleading; it is perfectly valid to serve as 'text/html' though it would make you think you were evil if you did.

What problems in particular are you having with the PI and stylesheet links and the PHP; Opera 7.2x and Mozilla 1.x should be fine with application/xhtml+xml

XHTML File:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="blue.css" type="text/css"?>
<!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" xml:lang="en" >
<head>
<title>Blue</title>
</head>
<body>
<p>Hello World</p>
</body>
</html>

CSS file:
p{background-color: blue; color-white;}

I assume you have set the headers to "application/xhtml+xml" and have remembered the style sheet PI must follow the prologue and there has to be no whitespace. Try using PHP includes rather than just echo it is cleaner.

The cheap way for an offline static page would be to save it as *.xht and load it in Mozilla, or Opera 7.2x.

toicontien
12-07-2003, 11:40 PM
Is there any way to pop IE into standards mode and still include the <? xml ?> declaration?
The code below is what I'm using and IE is in quirks mode. You can tell because the margin left and right set to auto does not center the DIV.

<?xml version="1.0" encoding="UTF-8"?>
<!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" xml:lang="en" >
<head>
<title>|</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css" media="all">
<!--
#test {
width: 400px;
height: 400px;
margin: 0px auto 0px auto;
background-color: green;
}
-->
</style>
</head>
<body>
<div id="test">&amp;nbsp;</div>
</body>
</html>

Already validated it at W3C's vaildator.

pyro
12-08-2003, 07:11 AM
I don't belive so. Fortunately, you can have a perfectly standards compliant XHTML document without the XML prolog, if you specify your character encoding with a Content-Type meta tag (as you have).

Robert Wellock
12-08-2003, 11:09 AM
Valid XHTML Embed 1.0 Rocks!
:D

Status: online and operational pushing the <embed /> element to the limit within XHTML 1.0.
Feel the fluxing power of eXtensibility gone wild.
-//XHTMLCODER//DTD XHTML 1.0 Embed//EN

;)

toicontien
12-09-2003, 08:20 PM
Could you still serve up an XHTML page as application/xml-xhtml to a browser without the <?xml ?> prolog?

pyro
12-09-2003, 10:08 PM
Yep, I just used PHP to set the Content-Type header. Take a look at http://www.ryanbrill.com/archives/00005.php to see what I did.

Robert Wellock
12-10-2003, 02:09 PM
Though legal, you are not supposed to omit the declaration because when the markup becomes an application of XML you SHOULD follow the rules of XML 1.0 because it has to be interpreted by an XML Processor.

Assuming you serve it as an application of XML as I have done with "XHTML 1.0 Embed" then XML it is, and not fancy looking backwards-compatible XHTML...