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.
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.