PDA

View Full Version : [HTML Guide] HTML or XHTML



Iszak
09-11-2008, 11:07 AM
HTML or XHTML
Many people favour XHTML over HTML because they believe that it is the future and to a degree they are correct, but there are some drawbacks they must understand before they go rushing off into coding XHTML. Some of these include content type, null end tags, internet explorer incompatibility, and other problems. I’m aware this is a lengthy read but anyone who wants to be knowledge in developing websites it is worth it.


Beliefs of XHTML
Many people believe that XHTML is superior to HTML, in which it does have some beneficial features, but people often push forwards beliefs that XHTML does things that HTML doesn’t, and the following are incorrect. XHTML does not;

• XHTML does not allow a greater separation of content and presentation than HTML.
• XHTML does not have more elements and attributes than HTML.
• XHTML doesn’t give any extra CSS features than HTML.
• XHTML isn’t as equip for the future than HTML, as XHTML 2.0 won’t be backwards compatible where as HTML 5 will.
• XHTML does not have good browser support.
• XHTML source isn’t essentially cleaner than HTML source


Content Type
Everything has a content type, GIF has "image/gif", PNG has "image/png", CSS has "text/css", Javascript has "text/javascript" etc. So does HTML and XHTML but they’re not the same much like images content types. HTML has the content type "text/html" where as XHTML has the content type "application/xhtml+xml" but there’s more to it than simply the content type.

XHTML Being Sent as HTML
Majority of web servers sends your page as text/html by default, even ".php" extension files are sent as "text/html", so if you have a page that has XHTML mark-up and is ".php" extension unless you’ve specified a header it will be sent to the user’s browser has "text/html". What will this mean? Well this means that your XHTML will be interrupted as HTML! Now what effects will this have? Well firstly this will result in the browser rendering your XHTML as ‘broken HTML’ such that if you used "<br />" it will simply presume that the trailing slash "/" is an error, and corrects it to be "<br>". This will mean that the XHTML mark-up as broken HTML, which will practically eliminate any beneficial XHTML features.

XHTML Being Sent as XHTML
So you understand that your XHTML is being sent as HTML so you want to correct this, you can do it via a number of ways, one of which is not the meta tag. You can either change the server configuration to send it as "application/xhtml+xml" or you can use a server-side language to send the headers for example in PHP if you put at the top of the page
header("Content-type: application/xhtml+xml"); this will change the content type. But you’ve got to understand by doing this will you have an adverse effect on Internet Explorer! Typical, I know. Internet Explorer up to this date still does not support the XHTML content type, and so when you send it as "application/xhtml+xml" it will simply ask how to open your page.


Null End Tags
If you didn’t already know in XHTML everything must be closed, such example is "<br>" will become "<br />", which will close it. Null End Tags is a feature in HTML which you can use "/" to close a element such example is "<p/Paragraph/" which is 100% valid in HTML 4.01 Transitional, although it is not the best practice. The first slash signifies the closing of the opening paragraph tag, the second slash is the closing paragraph tag. So if you use "<br />" in XHTML and its rendered as HTML in a browser that supports null end tags, it will render it as "<br /" with "<" as text, this is because the forward slash closed the "br".


Compatibility Guidelines
XHTML 1.0 had the idea to allow people to send their documents as "text/html" by following guidelines, and this is why it’s seen as valid when sent as "text/html". The whole idea of this was to allow people and browsers to change from HTML to XHTML more easily, but many people believe this was a mistake. They believe it as a mistake because many sites that are developed under this compatibility guideline would break if they were treated as XML (as that’s the whole point of XHTML to be an XML alternative to HTML). So by believing that by following the HTML compatibility guidelines and validating your document will ensure it to compatible for both HTML and XHTML are mistake. Because if you use a single self-closing tag like "<br />" that automatically creates incompatibilities between the two specifications.


Other problems
XHTML is often supported in many browsers, one being Firefox, but the performance of XHTML based websites (with the XHTML content type) in versions of Firefox 2.0 and below is considerably worse than HTML. This is because Firefox 2.0 and below renders XHTML once the entire page has been loaded, and it’s checked that the mark-up is well formed, unlike HTML. HTML uses what is called incremental rendering, which means that it will start rendering the page as soon as it gets it. Besides that you also have the fact that Internet Explorer does not support the "application/xhtml+xml" content type as already stated which eliminates over half of your viewers.


Conclusion
XHTML is a great thing and has many promising features, although it currently isn’t supported enough in the correct form and to make a browser render it as HTML is against everything XHTML is. Presuming you want to make your website available to the greatest number of viewers, you can only chose to use XHTML incorrectly. So if you have no real use for the XHTML benefits like SVG and MathML then you should use HTML 4.01 Strict as it’s what most browsers and search engines are used to and there is nothing wrong with using it, It is in fact a World Wide Web Consortium recommendation. But in the end it’s up to you. Well you’ve reached the end of this lengthy post; forgive me for any spelling mistakes and I hope this has broaden your knowledge on what to chose.

Selections.
09-11-2008, 11:09 AM
Great tutorial Iszak hopefully it will help people!

Agnostic Bear
09-11-2008, 12:38 PM
I'm sorry I prefer full PHP with no tables.

Iszak
09-11-2008, 12:41 PM
Never using tables isn't exactly the smartest thing to do, you're meant to use tables when appropriate - for tabular data. Not to mention this guide doesn't even mention tables once so I don't know where you got that from.

UniqueHabbo
09-11-2008, 12:42 PM
So the point of that is..
Use HTML, not XHTML

Merged by Meti (Forum Moderator): Due to forum lag

Trinity
09-11-2008, 12:43 PM
Never using tables isn't exactly the smartest thing to do, you're meant to use tables when appropriate - for tabular data. Not to mention this guide doesn't even mention tables once so I don't know where you got that from.

I believe he was referencing a comment that Darren made a while ago.
Just nod along ;)

Source
09-11-2008, 12:45 PM
What do you expect from "know-it-all" new kids to the block trinity... honestly.

Everyone on this forum uses HTML anyway, so this is completly useless as the correct specs for XHTML will be released in years to come as new browsers slowly update and improve on XHTML rendering capabilities.

Decode
09-11-2008, 12:52 PM
This is a good guide :) +rep If I can.

I'm sorry I prefer full PHP with no tables.
Was this meant to be a dig at DarrenToogood? :P

Awfy
09-11-2008, 12:59 PM
Okay here's the problem! You've written the guide in such as way that only people who already know the facts will understand it. Simplify it for god sake :|

Source
09-11-2008, 01:02 PM
Valid point greg, no offense to the developers on this forum but an "idiots how-to" version would be good for the newer people to the scene.

Iszak
09-11-2008, 01:04 PM
So the point of that is.. Use HTML, not XHTML
Well this is entirely up to the individual and their purposes as the conclusion is trying to state. But I personally suggest HTML 4.01 Strict as said in the conclusion browsers and search engines are better in rendering this.



What do you expect from "know-it-all" new kids to the block trinity... honestly.

Everyone on this forum uses HTML anyway, so this is completly useless as the correct specs for XHTML will be released in years to come as new browsers slowly update and improve on XHTML rendering capabilities.
I've seen people use XHTML on this forum over HTML, and as for your statement about XHTML specifications it is wrong. XHTML 1.0 specifications have been outlined and aren't set to change they were in outlined in 2000 and became a W3C recommended in the same year, so browsers have had many years to be compliant to it with Internet Explorer 7 being released in 2006 it had 6 years to become compliant.


Also


I’m aware this is a lengthy read but anyone who wants to be knowledge in developing websites it is worth it.

It's not intended to be an idiots guide to developing websites or what to chose. Idiots don't really care if their site works in most browsers the only care about theirs. Not to mention they usually develop in tables, this guide is for people who are serious about web development not an idiot. But good point none the less.

Source
09-11-2008, 01:08 PM
I worded my response badly, I meant we need to wait for browsers to fully move out that have bad support (ie when people stop using older browsers such as IE6 etc.. and move onto the newer better alternatives.)

But still... generally people still use HTML this just seems like another "hypertext"ish thread to gain some ego within the community.

Iszak
09-11-2008, 01:11 PM
Ah okay, you're right there but that could take many years unfortunently and with Internet Explorer 8 still lacking support of XHTML it doesn't look like it's going to have full support anytime soon unless everyone switches to a browser that supports it, although Internet Explorer is still in beta so it could be subject to change.



But still... generally people still use HTML this just seems like another "hypertext"ish thread to gain some ego within the community.

Not so much ego but more so respect but you were pretty much dead on. But it is also designed to inform people who are using XHTML.

Source
09-11-2008, 01:15 PM
Its just the way you are putting things across makes you seem overly big headed and wants to out-do everyone, if you tone things down and remember what sort of forum you are on then people will respect you alot more. They want the help... without the lecture, even though its tempting to sit them down and say "Blah blah you idiot this is why....".

And lets face it, loads of people are still on IE6 even though IE7 is out... I doubt people would move over to IE8 even if it did have amazing support for XHTML and was at last fully standards complient.

Iszak
09-11-2008, 01:24 PM
Well I didn't intend for it to be like that, I guess it's how you interupt it. Regardless of this if people want to learn why it's generally better to use HTML over XHTML then they'll read about it.

You are right about people not switching to Internet Explorer 8 even if it had great XHTML support, it's more the front end web developers who want browsers to be compliant because it makes our job harder if it's not as well as users switching to the latest browsers.

iUnknown
09-11-2008, 04:46 PM
Most of the users on this forum are teenagers. Your article is good but it's length will put most users off. Try and cut bits out, or make them shorter... in future.

L?KE
09-11-2008, 04:50 PM
Didn't bother reading it cos it looked boring. Make it more pleasing to the eye :P

Nevertheless, looks like you put some effort into it, so +rep.

Iszak
09-11-2008, 09:53 PM
Basic Overview to the HUGE HTML or XHTML Article
Due to a number of people saying that the article is way to long which I agree to an extent - if you really want to learn you've got to put the effort into it. Anyhow this is pretty much the main reason why you should use HTML over XHTML although on the original it states it's up to you - which it is.


Content type
Everything has a content type, GIF images have “image/gif”, Javascript is “text/javascript” and CSS is “text/css”, so why should HTML and XHTML be any different? Well they’re not, HTML has text/html and XHTML is “application/xhtml+xml”

XHTML sent as HTML
Well if you’ve got an XHTML website it’s likely to be sent as HTML this is due to the server configuration, and by default “.php” files are also sent as text/html. So this means your XHTML will be rendered as broken HTML because the browser will simply see “<br />” as an error and correct it to “<br>”

XHTML sent as XHTML
So your site is being sent as the proper content type, application/xhtml+xml but this will cause Internet Explorer (all versions) to give you a dialogue so either way you either choose a) lose XHTML features by having it rendered as HTML or b) make all internet users unable to view your website


Conclusion
There are various other reasons why you should not use XHTML at the present time, but as stated the main reason is the content type, Internet Explorer doesn’t support it, lots of people use Internet Explorer. Why use XHTML if it’s being rendered as HTML and you lose all the features of XHTML, there’s no point so instead use HTML 4.01 Strict which is more familiar with browsers and search engines over XHTML 1.0 or XHMTL 1.1.

Hypertext
10-11-2008, 12:33 AM
Well this is entirely up to the individual and their purposes as the conclusion is trying to state. But I personally suggest HTML 4.01 Strict as said in the conclusion browsers and search engines are better in rendering this.

I've seen people use XHTML on this forum over HTML, and as for your statement about XHTML specifications it is wrong. XHTML 1.0 specifications have been outlined and aren't set to change they were in outlined in 2000 and became a W3C recommended in the same year, so browsers have had many years to be compliant to it with Internet Explorer 7 being released in 2006 it had 6 years to become compliant.


Also

It's not intended to be an idiots guide to developing websites or what to chose. Idiots don't really care if their site works in most browsers the only care about theirs. Not to mention they usually develop in tables, this guide is for people who are serious about web development not an idiot. But good point none the less.

Since when do search engines render (X)HTML?

Also, the way you've written this, only somebody who was very advanced would understand it, yet it's giving information to someone who is less advanced, defeating the purpose of learning...

Also, how the hell did nobody mention doc types?

Iszak
10-11-2008, 12:43 AM
It was in context of parsing / rendering XHTML sorry if you got confused by this I'll be sure to use 'parse' for future reference. It wouldn't designed for people who are new to web development as already stated, more so the advance and I made a basic one for people who wanted to know as posted above. As for doctypes everyone (I'd presume) uses doctypes so there is really no need to mention it, hardly relevent on why you should use HTML over XHTML.

Hypertext
10-11-2008, 12:49 AM
It was in context of parsing / rendering XHTML sorry if you got confused by this I'll be sure to use 'parse' for future reference. It wouldn't designed for people who are new to web development as already stated, more so the advance and I made a basic one for people who wanted to know as posted above. As for doctypes everyone (I'd presume) uses doctypes so there is really no need to mention it, hardly relevent on why you should use HTML over XHTML.

You spoke of how to make a document rendered in XHTML or HTML, so why not just use doc types instead of changing server settings?

Iszak
10-11-2008, 01:40 AM
The doctype is used to tell the browser what version of mark-up to use and is critical when it comes to parsing your website. Doctype is short for DTD which means Document Type Definition, but yeah it's understandable to see where people get confused in thinking that the doctype changes the content type.

Blinger1
10-11-2008, 01:46 AM
When i saw this, i was like "ugh... huge text blocks :("

Agnostic Bear
10-11-2008, 07:33 AM
Basic Overview to the HUGE HTML or XHTML Article
Due to a number of people saying that the article is way to long which I agree to an extent - if you really want to learn you've got to put the effort into it. Anyhow this is pretty much the main reason why you should use HTML over XHTML although on the original it states it's up to you - which it is.


Content type
Everything has a content type, GIF images have “image/gif”, Javascript is “text/javascript” and CSS is “text/css”, so why should HTML and XHTML be any different? Well they’re not, HTML has text/html and XHTML is “application/xhtml+xml”

XHTML sent as HTML
Well if you’ve got an XHTML website it’s likely to be sent as HTML this is due to the server configuration, and by default “.php” files are also sent as text/html. So this means your XHTML will be rendered as broken HTML because the browser will simply see “<br />” as an error and correct it to “<br>”

XHTML sent as XHTML
So your site is being sent as the proper content type, application/xhtml+xml but this will cause Internet Explorer (all versions) to give you a dialogue so either way you either choose a) lose XHTML features by having it rendered as HTML or b) make all internet users unable to view your website


Conclusion
There are various other reasons why you should not use XHTML at the present time, but as stated the main reason is the content type, Internet Explorer doesn’t support it, lots of people use Internet Explorer. Why use XHTML if it’s being rendered as HTML and you lose all the features of XHTML, there’s no point so instead use HTML 4.01 Strict which is more familiar with browsers and search engines over XHTML 1.0 or XHMTL 1.1.

What the hell are you talking about, browsers don't render xhtml based on content type alone, they render it based on content type or the doctype.

Hypertext
10-11-2008, 01:51 PM
What the hell are you talking about, browsers don't render xhtml based on content type alone, they render it based on content type or the doctype.

That's what I said.

Iszak
11-11-2008, 03:34 PM
primarily Sorry for the late reply, the thread got pushed down as for both of yours queries.

The content type currently specifies whether to use HTML or the XML parser in a browser, that is why when you send your XHTML as text/html it's rendered as broken HTML, which is primarily what it bases it's render on. The document type is the version of HTML or XHTML it also stops the browser from triggering quirks mode - and thus puts it into standard mode. Hope that answered your question(s).

Want to hide these adverts? Register an account for free!