Forum Moderators: open

Message Too Old, No Replies

HTML or XHTML?

Which to code in?

         

sosidge

8:20 am on Mar 29, 2004 (gmt 0)

10+ Year Member



I know this has doubtlessly been asked many times before, but a search has left me none the wiser.

Which language should I be using today to code webpages?

My site at present is a bit of a mish-mash - homepage is "dirty" HTML I suppose - it has no DOCTYPE announcement.

Online shop is osCommerce - which seems to use HTML 4 where applicable.

Discussion board is YaBBSE - which uses XHTML 1.

I'm now coding from scratch for a couple of pages, one is a modification of the homepage (can't afford the webdesigner's fee...), two is a new "under construction" page for a future project, which will be another forum, probably running Simple Machines (replacement of YaBBSE).

What should I use? I have limited experience of HTML/XHTML - but XHTML looks "wrong" to me compared to all the other HTML coding I have done (custom ebay pages).

Can HTML now be considered future-proof? Is there that much more functionality/compatibility to come from XHTML that I should start coding in this instead?

My HTML book (Elizabeth Castro's Visual Quick Start guide) seems obsessed with XHTML - is she right to be?

Thanks for any help in advance.

mep00

10:22 am on Mar 29, 2004 (gmt 0)

10+ Year Member



First of all, it's important to note that each page stands on its own; there is no such thing as a "site wide" DOCTYPE. You may already know that, but it's been asked before and I thought it was worth repeating.

A thread which should answer your question is "Why XHTML 1.1/CSS? [webmasterworld.com]"

To briefly sumerize, while XHTML was designed to be backwards compatable, HTML 4 will not be (at least in theory) forwards compatable. There are a number of deprecated elements forwhich there is no gaurentee of future browser support.

As far as "looking 'wrong'" goes, in most respects XHTML is a subset of HTML. If you don't use some of the newer tags, the only differance is handling of empty tags; something which older browsers will ignore anyway.

One aspect of XHTML which is important today and will likely become much more imprortant in the coming years: XHTML, because of its stricter rules, is more machine readable. Why that's important it a whole seperate discussion in and of itself.

To answer your last question, she is absolutly correct to be pushing XHTML.

sosidge

11:15 am on Mar 29, 2004 (gmt 0)

10+ Year Member



Second question... Strict or Transitional?

mipapage

11:18 am on Mar 29, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



That depends on how far you want to go. One of the most major concerns for most people is that this:

target="_blank"

is illegal in anchors when using XHTML Strict.

PatomaS

11:22 am on Mar 29, 2004 (gmt 0)

10+ Year Member



Hello

Well, this is an interesing question...

If you use transitional XHTML, your life will be easier, but if you try with the strict one, you'll see that is not as hard as it looks in the beginning.

Of course, there is a lot of things you use to do in html that you can't in xhtml, specially in strict mode, but i think is not so mucho what you lose once you start using in the right way the css pages and JavaScript. In dee i think that your pages don't lose any thing.

With strict xhtml, your code will be shorter and it is reflected in the load speed of the page, and if you use a well designed css, your page will be faster.

So jut try strict for a while and see what can and can not do.

Bye

asquithea

7:20 pm on Mar 29, 2004 (gmt 0)

10+ Year Member



It really depends whether you care how well your pages are put together, and whether you are planning to use CSS.

Let's suppose for a moment that either or both is desirable or important to you. In my opinion, the most important thing is to go "strict", whether that be in HTML 4.01 or XHTML 1.0 or 1.1. By validating your code at the W3C [validator.w3.org] or HTML Help [htmlhelp.com] sites, you will quickly develop a real understanding of HTML, rather than the froth you might know at the moment.

Do you know, for example, why it is wrong to put a list inside a paragraph?

In-depth HTML knowledge will stand you in good stead for using CSS 1 and 2. Too many pages are broken in some browsers because the author simply hacked a page together without understanding what (s)he was doing.

Although there's not much difference between HTML and XHTML, personally I'd go with XHTML for cleaner syntax and better data interoperability. It's certainly no harder.

WeirdoPL

10:59 pm on Mar 29, 2004 (gmt 0)

10+ Year Member



Also visit this thread for a similar discussion:

[webmasterworld.com...]

sosidge

5:52 am on Mar 30, 2004 (gmt 0)

10+ Year Member



Reading that thread would suggest that the most "universally" understood language in the current browser world is HTML 4.01 - with XHTML having issues on IE6 or Opera.

So XHTML is the one to learn about, HTML 4.01 the one to code in today.

True/False?

Rincewind

6:04 am on Mar 30, 2004 (gmt 0)

10+ Year Member



XHTML is my weapon of choice. All browsers can cope with it. There is no added elements in xhtml 1.0 compaird to html 4.01. Just a stricter rule book as to how you use each element. It's the CSS support which goes hand in hand with the xhtml can be patchy. But the same CSS is needed for HTML 4.01 design.

koocw

9:18 am on Mar 30, 2004 (gmt 0)

10+ Year Member



Basically XHTML stands for Extensible Hypertext Markup language, so it is more forward-compatible than HTML. I'm planning to use XHTML 1.0 Strict.

If you have problems transiting from HTML to XHTML, try Better Living Through XHTML [alistapart.com] by Jeffrey Zeldman, at A List Apart [alistapart.com].

sderenzi

3:30 pm on Apr 1, 2004 (gmt 0)



You're looking for an answer that is a definitive one. I'll give it to you! HTML is better to use than XHTML. There is not any contest because more browsers support HTML and by using XHTML you'll limit the number of users capable of visiting your site. Consider whether you'd like your site to be available to everyone or only the select few with newer computers or browser software. The same is true of Flash to a degree, but because it is a plugin even Internet Explorer v3.0 can display it!

RammsteinNicCage

7:30 pm on Apr 1, 2004 (gmt 0)

10+ Year Member



sderenzi, what browsers don't support XHTML? Even Netscape 4.x doesn't seem to have any trouble with it....

Jennifer

encyclo

8:25 pm on Apr 1, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



by using XHTML you'll limit the number of users capable of visiting your site

Even Netscape 0.9 can read XHTML. It can't understand half of it, but that's not a problem because browsers are designed to ignore any markup which they do not understand.

Personally, I prefer HTML 4.01, but there is no definitive answer to this question. It's just a tool, not a way of life, and the end user won't tell the difference between HTML and XHTML is normal circumstances (nor will he care). You've just got to pick the one you feel more comfortable with, and work to get all your pages to validate. The fact that your pages validate is more important that the standard to which they validate to.

Mohamed_E

9:52 pm on Apr 1, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



encyclo makes a statement where I would rather ask a question:

The fact that your pages validate is more important that the standard to which they validate to.

Which is "better" (whatever that word may mean): to validate completely to 4.01 Transitional, using every deprecated construct that standard allows, or to almost validate to 4.01 Strict, flunking because of, say, target=_blank?

twist

12:22 am on Apr 2, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I decided to make all my pages xhtml 1.1. It was a incredible learning experiance and I couldn't be happier with the results. All the hard work was worth it. I even converted my phpbb 2.0.6 over to xhtml 1.1. My code is very clean and easy to read. If you do web development professionally I think it looks more professional to use xhtml. With programs like frontpage and all the other wysiwyg editors out there and people buying those html for dummies books a lot of people think they know how to make websites. I like it when I tell someone I make websites and they reply, "Oh yeah, I've made websites before, I made a great one using yahoo webpagebuilder, so what do you do for a living though?" I think it helps seperate you from the crowd and shows that you are more serious about your webpages, but thats just my opinion. As for the little speed bumps you run into during the coversion process there are always workarounds.

For example, I replace target="_blank" with rel="external" by using the javascript below. If for whatever reason the user has javascript disabled then the browser simply ignores the tag and opens the window in the same page.


function NewPage() {
if(!document.getElementsByTagName ) { return; }
var anchors = document.getElementsByTagName( "a" );
for( var loop = 0; loop < anchors.length; loop++ ) {
var anchor = anchors[ loop ];
if( anchor.getAttribute( "href" ) && anchor.getAttribute( "rel" ) == "external" ) {
anchor.target = "_blank";
}
}
}

To replace target="_top" and to keep my pages from being framed by another website I added the javascript below. Once again, if for whatever reason the visitor has javascript disabled then the worst that would happen would be that person being able to view my page framed.

if( window!= window.top ) { top.location.href = location.href; }

If you choose to use flash embed tags are any other non-usable tags, there is always the option of putting it inside a javascript document.write statement, which the parser doesn't read. It's a shady way of doing things that I don't personally use but it will allow you to add things that you may find necessary but still want validation. There is also options by adding things to the DTD which can make it valid and usable.

Anyway, these are just a few of the things I've picked up since switching over to xhtml 1.1. So, like I said, it can be a real learning experience.

encyclo

12:29 am on Apr 2, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Which is "better" (whatever that word may mean): to validate completely to 4.01 Transitional, using every deprecated construct that standard allows, or to almost validate to 4.01 Strict, flunking because of, say, target=_blank?

OK, I'll start by adding a couple of nuances to my previous comment. Validation matters, but not all validation errors are equal. Also, validation matters, but accessibility matters just as much.

A valid layout with nested tables, non-semantic markup (no h1, h2, p tags, just <br> and <font> for example) is not what you call ideal - but validity ensures that parsing errors are cut to a minimum, and the layout behaviour is predictable (ie. any bugs are in the browser, not in the markup).

A semantically-rich document in HTML 4.01 Strict, which does not validate because of a target="_blank" has numerous advantages, and the validation error is of little consequence because it is not a critical error (such as improperly nested tags, which break the DOM) rather an unrecognised (by the spec, not by the browser) attribute. A strictly-conforming parser (if that were ever to exist) would simply ignore the unknown attribute.

If you specify a site-wide doctype in an include, then use target="_blank" on one page, breaking the validation in that one case, then I find the compromise acceptable because the additional work required (creating a specific header for one page just to avoid the error) is not worth it. However, if you are using attributes such as target="_blank" site-wide, even if your other markup does not contain depreciated elements, then I still feel you should declare a Transitional doctype.