Forum Moderators: open
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.
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.
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
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.
[webmasterworld.com...]
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].
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.
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?
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";
}
}
}
if( window!= window.top ) { top.location.href = location.href; }
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.
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.