Go Back   SitePoint Forums > Forum Index > Design Your Site > Web Page Design > HTML and XHTML
Newsletter FAQ Members List Calendar Mark Forums Read

New to SitePoint Forums? Register here for free!

SitePoint Sponsor
 
Reply
 
Thread Tools Display Modes
Old Jul 21, 2003, 00:02   #1
Rizal
SitePoint Enthusiast
 
Join Date: Aug 1999
Location: Kuala Lumpur, Malaysia
Posts: 68
HTML 4.0 or XHTML 1.0?

I'm not sure whether this has been asked before, but here goes.

To ensure current and future compatibility, which one should I use, and why?
Rizal is offline   Reply With Quote
Old Jul 21, 2003, 00:33   #2
Dan Grossman
Follow Me On Twitter: @djg
gold trophysilver trophybronze trophy
SitePoint Award Recipient
 
Dan Grossman's Avatar
 
Join Date: Aug 2000
Location: Philadephia, PA
Posts: 19,728
If coded PROPERLY, both of them will be compatible for many years to come. None of the browser makers have any intention of dropping HTML4 support any time in the foreseeable future.

If you're going the XHTML route, remember that you're going to need to separate your structure from your design as completely as possible. This means full use of CSS for layout of your page and as few tables as possible. XHTML is both backwards and forwards compatible -- it'll render on current and past browsers, but you're not going to have the same presentation on 4x generation and older (to most people, this means Netscape 4.x) browsers. They'll get the content, but likely not the design. The advantage to XHTML is easier updating, and if validly written, compatibility with most current and future browsers, phones, PDAs, and accessibility such as screen readers. Writing valid XHTML will also make it much reader to reach those accessibility guidelines becoming law in many countries. Another huge advantage is in bandwidth -- the average XHTML1.0/CSS page (like SitePoint's site, specifically outside of the forums) is much lighter than an HTML4 page because all you get is the content, not the formatting. The stylesheet only has to be downloaded once. Speaking of that, don't forget you can change the entire look and feel of your site, the entire design, just by editing your stylesheets.

If you need it to look pixel perfect in older browsers without the CSS support a true XHTML/CSS page requires, go with HTML 4. Like I said above, you still need to code it properly, and browsers won't stop supporting this in the future as long as you make proper use of the DOCTYPE tag. You can figure out the drawbacks by reading the advantages of XHTML.

If you're interested in the XHTML/CSS route and want some extra help, I recommend the book "Designing with Web Standards" (much over SP's book).

Good luck
Dan Grossman is online now   Reply With Quote
Old Jul 21, 2003, 00:48   #3
quenting
SitePoint Guru
 
quenting's Avatar
 
Join Date: Dec 2002
Location: Switzerland
Posts: 745
Quote:
This means full use of CSS for layout of your page and as few tables as possible
I don't see anywhere in xhtml where it states you have to use as few tables as possible.
xhtml just means "clean code" and "xml compatible", and while the philosophy behind it is that it provides a better environment for CSS prevalence over tables it doesn't mean you have to do it. You can also style tables with CSS very easily, and in some (many ?) cases that will do a cleaner and smaller html (which are the two main arguments for CSS-P) than if using CSS.

just my 2 cents
Quentin
quenting is offline   Reply With Quote
Old Jul 21, 2003, 00:53   #4
Dan Grossman
Follow Me On Twitter: @djg
gold trophysilver trophybronze trophy
SitePoint Award Recipient
 
Dan Grossman's Avatar
 
Join Date: Aug 2000
Location: Philadephia, PA
Posts: 19,728
XHTML doesn't state anything about how you should go about using it -- you can wrap your site in a million tables and make each page a megabyte in size.

It's just the philosophy that goes along with transitioning towards XML. If you don't want to try to adopt that philosophy, stick to HTML 4? This is just my advice as well, but I see no reason to use XHTML if you're not going to make the full changeover from the old way of thinking about web page design.

Another 2 cents from me. You're getting rich, Rizal.
Dan Grossman is online now   Reply With Quote
Old Jul 21, 2003, 03:20   #5
hurricane.uk
SitePoint Addict
 
hurricane.uk's Avatar
 
Join Date: May 2003
Location: Liverpool
Posts: 361
XHTML is an extension of the HTML 4.01 standard, bringing XML functionality into it. By using xhtml over html 4.01 you will be opening your site up to a number of UAs that can't access html as well as a browser can, and also providing the capacity for your markup to interact with programming and scripting languages in a more logical way.
hurricane.uk is offline   Reply With Quote
Old Jul 22, 2003, 08:50   #6
xhtmlcoder
Robert Wellock
 
xhtmlcoder's Avatar
 
Join Date: Apr 2002
Location: A Maze of Twisty Little Passages
Posts: 1,862
eXtensible HyperText Markup Language (XHTML) is well-formed eXtensible Markup Language (XML) that has been written to mimic HTML 4.01.

Thus for future proofing the XHTML Family has the edge and potentially a wider user-agent, platform base and greater interoperability as was mentioned before.
xhtmlcoder is offline   Reply With Quote
Old Jul 23, 2003, 01:24   #7
Dan Grossman
Follow Me On Twitter: @djg
gold trophysilver trophybronze trophy
SitePoint Award Recipient
 
Dan Grossman's Avatar
 
Join Date: Aug 2000
Location: Philadephia, PA
Posts: 19,728
Woot, our thread made it into the Tech Times
Dan Grossman is online now   Reply With Quote
Old Jul 23, 2003, 01:30   #8
AlexW
Team SitePoint
 
AlexW's Avatar
 
Join Date: Apr 2000
Location: Melbourne
Posts: 1,007
I think XHTML is a good habit to get into. It takes little time to learn the differences and is more accessible for non-browser devices. Anyway it feels good

After a while I couldn't bring myself to write HTML anymore. I kinda feel dirty even seeing a <br> in my old code, let alone writing one... hehehe . Have to spin a find and replace through the code before I can touch it. And unclosed list items?!?! (involuntary shiver)
AlexW is offline   Reply With Quote
Old Jul 23, 2003, 02:31   #9
firegryphon3207
because you gotta have beer!
 
firegryphon3207's Avatar
 
Join Date: Apr 2000
Location: Roxbury/Boston
Posts: 484
Quote:
Originally Posted by AlexW
And unclosed list items?!?! (involuntary shiver)
I'm not having too much trouble making the change. I was already in the habit of closing tags to begin with. When I started learning, I closed all tags possible, it was too confusing to try and remember which ones you had to close and which ones you didn't. It does feel good because your code is nice and neat. I have however been very lazy about changing some old code.
firegryphon3207 is offline   Reply With Quote
Old Jul 23, 2003, 06:05   #10
vgarcia
☆★☆★
silver trophy
 
vgarcia's Avatar
 
Join Date: Jan 2002
Location: in transition
Posts: 21,481
Quote:
Originally Posted by AlexW
I think XHTML is a good habit to get into. It takes little time to learn the differences and is more accessible for non-browser devices. Anyway it feels good

After a while I couldn't bring myself to write HTML anymore. I kinda feel dirty even seeing a <br> in my old code, let alone writing one... hehehe . Have to spin a find and replace through the code before I can touch it. And unclosed list items?!?! (involuntary shiver)
<br /> still has valid uses however. Try creating a layout that makes extensive use of floats; you'll find that you need a <br clear="all" /> in there at least once.
vgarcia is offline   Reply With Quote
Old Jul 23, 2003, 19:11   #11
AlexW
Team SitePoint
 
AlexW's Avatar
 
Join Date: Apr 2000
Location: Melbourne
Posts: 1,007
Oh I have nothing against '<br />'. Use it all the time.. ... just the non self-closing version '<br>' makes me feel the need to wash.
AlexW is offline   Reply With Quote
Old Jul 23, 2003, 20:15   #12
vgarcia
☆★☆★
silver trophy
 
vgarcia's Avatar
 
Join Date: Jan 2002
Location: in transition
Posts: 21,481
Quote:
Originally Posted by AlexW
Oh I have nothing against '<br />'. Use it all the time.. ... just the non self-closing version '<br>' makes me feel the need to wash.
Yes it's a "dirty" tag to me, even in XHTML. I use it only when necessary .
vgarcia is offline   Reply With Quote
Old Jul 23, 2003, 20:16   #13
Dan Grossman
Follow Me On Twitter: @djg
gold trophysilver trophybronze trophy
SitePoint Award Recipient
 
Dan Grossman's Avatar
 
Join Date: Aug 2000
Location: Philadephia, PA
Posts: 19,728
What does <br clear="all" /> do?

I'm only 3/4 through "Designing with Web Standards" and haven't started "Eric Meyers on CSS" yet.
Dan Grossman is online now   Reply With Quote
Old Jul 23, 2003, 20:31   #14
AlexW
Team SitePoint
 
AlexW's Avatar
 
Join Date: Apr 2000
Location: Melbourne
Posts: 1,007
Doesn't <br style="clear:both"> work pretty much the same as "<br clear="all" />" ?

(I wouldn't normally do it inline like that)
AlexW is offline   Reply With Quote
Old Jul 23, 2003, 20:32   #15
Dan Grossman
Follow Me On Twitter: @djg
gold trophysilver trophybronze trophy
SitePoint Award Recipient
 
Dan Grossman's Avatar
 
Join Date: Aug 2000
Location: Philadephia, PA
Posts: 19,728
Don't know what either do
Dan Grossman is online now   Reply With Quote
Old Jul 23, 2003, 20:58   #16
Webnauts
Organic SEO Expert
 
Webnauts's Avatar
 
Join Date: Jun 2003
Location: European Union
Posts: 1,577
<br clear=all or left or right or none> breaks the text flow and resumes the next line after the specified margin is clear. This is often used to start the text below an aligned image (preventing text wrap). "none" is the default, causing a simple line break.
Webnauts is offline   Reply With Quote
Old Jul 24, 2003, 03:25   #17
Rizal
SitePoint Enthusiast
 
Join Date: Aug 1999
Location: Kuala Lumpur, Malaysia
Posts: 68
Quote:
Originally Posted by AlexW
I think XHTML is a good habit to get into. It takes little time to learn the differences and is more accessible for non-browser devices. Anyway it feels good [img]images/smilies/smile.gif[/img]
I'm in the middle of re-coding everything to validate to XHTML 1.0 standards. It was hard remembering closing those tags, making sure everything was properly nested but I feel much better now.

Last edited by Rizal; Jul 24, 2003 at 03:39.
Rizal is offline   Reply With Quote
Old Jul 25, 2003, 03:59   #18
DougBTX
SitePoint Wizard
 
DougBTX's Avatar
 
Join Date: Nov 2001
Location: Bath, UK
Posts: 2,532
Quote:
Originally Posted by vgarcia
<br /> still has valid uses however. Try creating a layout that makes extensive use of floats; you'll find that you need a <br clear="all" /> in there at least once.
Why bother doing a CSS layout if you are going to keep on using Transitional HTML?

Douglas
DougBTX is offline   Reply With Quote
Old Jul 25, 2003, 04:49   #19
Rizal
SitePoint Enthusiast
 
Join Date: Aug 1999
Location: Kuala Lumpur, Malaysia
Posts: 68
I'm already sold on XHTML 1.0. Now I need to compile a list of browsers (and their versions) that support (fully/partial) this standard. Any ideas?
Rizal is offline   Reply With Quote
Old Jul 25, 2003, 05:07   #20
Webnauts
Organic SEO Expert
 
Webnauts's Avatar
 
Join Date: Jun 2003
Location: European Union
Posts: 1,577
Quote:
Originally Posted by Rizal
I'm already sold on XHTML 1.0. Now I need to compile a list of browsers (and their versions) that support (fully/partial) this standard. Any ideas?
Are you looking for resources?
Webnauts is offline   Reply With Quote
Old Jul 25, 2003, 07:24   #21
DougBTX
SitePoint Wizard
 
DougBTX's Avatar
 
Join Date: Nov 2001
Location: Bath, UK
Posts: 2,532
Quote:
Originally Posted by Rizal
I'm already sold on XHTML 1.0. Now I need to compile a list of browsers (and their versions) that support (fully/partial) this standard. Any ideas?
No browser (that I know of) supports XHTML as XML, but most are quite happy to treat it as HTML 4.01 (If you follow these guides)

Douglas
DougBTX is offline   Reply With Quote
Old Jul 25, 2003, 07:58   #22
xhtmlcoder
Robert Wellock
 
xhtmlcoder's Avatar
 
Join Date: Apr 2002
Location: A Maze of Twisty Little Passages
Posts: 1,862
Well just remember within HTML 4.01 the start and end tags for the HTML, HEAD and BODY elements are optional, but specifying the Document Type Definition, the character encoding and the TITLE is a requirement.

That was one of the main reasons I never really liked HTML 4.01.
xhtmlcoder is offline   Reply With Quote
Old Jul 25, 2003, 08:08   #23
redux
gingham dress, army boots...
silver trophy
 
redux's Avatar
 
Join Date: Apr 2002
Location: Salford / Manchester / UK
Posts: 4,856
Quote:
Originally Posted by DougBTX
No browser (that I know of) supports XHTML as XML, but most are quite happy to treat it as HTML 4.01 (If you follow these guides)

Douglas
if i remember correctly, an xhtml strict document sent as application/xhtml+xml to Opera7 is treated as xml...so much so that if there is an error in its syntax, it shows a big fat error message right where the syntax error occurred (and not some quirks mode stuff)
redux is offline   Reply With Quote
Old Jul 25, 2003, 13:14   #24
beetle
Web-coding NINJA!
silver trophy
 
beetle's Avatar
 
Join Date: Jul 2002
Location: Dallas, TX
Posts: 2,910
Quote:
Originally Posted by DougBTX
No browser (that I know of) supports XHTML as XML, but most are quite happy to treat it as HTML 4.01
Mozilla likes XML content just fine

<meta http-equiv="Content-Type" content="text/xml; charset=UTF-8" />
beetle is offline   Reply With Quote
Old Jul 25, 2003, 13:31   #25
DougBTX
SitePoint Wizard
 
DougBTX's Avatar
 
Join Date: Nov 2001
Location: Bath, UK
Posts: 2,532
Quote:
Originally Posted by redux
if i remember correctly, an xhtml strict document sent as application/xhtml+xml to Opera7 is treated as xml...so much so that if there is an error in its syntax, it shows a big fat error message right where the syntax error occurred (and not some quirks mode stuff)
I stand corrected

IE6, Moz and Opera all throw nice big errors with invalid XML sent as XML, very cool. (That means that... I can use XHTML 2... today?)

There is hope yet

Douglas

Edit:

In each case, I sent this as application/xml along with a style sheet:

Code:
<?xml-stylesheet href="xml.css" type="text/css"?>
<mytag>
<my>hi</my>
<my>hii</my>
<my>hi</my>
</mytaggggggg>
With a correct end tag, all render the same

I wonder what IE5/IE5.5 do with it...

Douglas

Edit:

Works 100% in IE5.5 by the looks of it atleast when loaded off your harddrive...

DougBTX is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread | Next Thread »

Thread Tools
Display Modes

 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Sponsored Links
 
Forum Jump


All times are GMT -7. The time now is 01:44.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Copyright 1998-2009, SitePoint Pty Ltd. All Rights Reserved