Jump to content

Xhtml in older browsers


htmlnewbie23

Recommended Posts

Please forgive me if this question is too simplistic, but I am newbie in this area.I read that xhtml is the new standard because it is cleaner and better than html. If a webpage is written in strict xhtml will older browsers be able to show it correctly? If not, because older browsers may have been written before the existence of xhtml, what is the work around so that the code can be correctly read by both old and recent browsers?Can search engines read xhtml content?Finally, is there an easy way to convert an html coded file into xhtml? Other than rewriting it?Thanks

Link to comment
Share on other sites

Which old browsers would you be talking about? Majority of people would be on the modern browsers that do support it. And those not using them, they are only restricting themselves you could say.

Link to comment
Share on other sites

Which old browsers would you be talking about? Majority of people would be on the modern browsers that do support it. And those not using them, they are only restricting themselves you could say.
Allow me to rephrase the question. As of which generation of browsers, did browser start to recognize xhtml? Or better still, what percentage of browsers in use by the public today recognize xhtml? It is possible to recognize the browser a visitor to a webpage is using, so that percentage of browsers used should be known by someone.
Link to comment
Share on other sites

XHTML 1.0 Strict code served as HTML (*.html extension and/or the MIME type "text/html") is viewable in all browsers that have HTML support (meaning "all desktop browsers and all modern mobile ones"). If served as XHTML (*.xhtml extension and/or the MIME type "application/xhtml+xml"), it's only viewable in browsers that follow some of the new rules. This includes the latest versions of Firefox and Opera, as well as many others (including all modern mobile browsers), but excludes all IE version up until and including IE7. IE will show a download box instead of rendering the file if served "as is".

Can search engines read xhtml content?
Absolutely.
Finally, is there an easy way to convert an html coded file into xhtml?
If you've written HTML 4.01 Strict compatable code before that, convertion is usually easily doable by simple search&replace in any text editor. For example find "<br>" and replace it with "<br />". Replace the DTD. And convert the tags to lower case (modern HTML editors have this option built in).Another way is HTML Tidy but unless you're willing to "study it", you'll probably want an editor that implements it. One such editor, made by Elevator_Hazard is AHTML pad. There are of course many others, some of which are viewable from the HTML Tidy website.
Link to comment
Share on other sites

XHTML 1.0 Strict code served as HTML (*.html extension and/or the MIME type "text/html") is viewable in all browsers that have HTML support (meaning "all desktop browsers and all modern mobile ones"). If served as XHTML (*.xhtml extension and/or the MIME type "application/xhtml+xml"), it's only viewable in browsers that follow some of the new rules. This includes the latest versions of Firefox and Opera, as well as many others (including all modern mobile browsers), but excludes all IE version up until and including IE7. IE will show a download box instead of rendering the file if served "as is".Absolutely.If you've written HTML 4.01 Strict compatable code before that, convertion is usually easily doable by simple search&replace in any text editor. For example find "<br>" and replace it with "<br />". Replace the DTD. And convert the tags to lower case (modern HTML editors have this option built in).Another way is HTML Tidy but unless you're willing to "study it", you'll probably want an editor that implements it. One such editor, made by Elevator_Hazard is AHTML pad. There are of course many others, some of which are viewable from the HTML Tidy website.
Thank you that explains things. I did not realize the difference for browsers was whether the extension was htm/html or xhtml. (I told you I was a newbie). If I did things like replace my "<br>" with "<br />, etc., BUT kept the extension as html, would that cause a problem with non-xhtml browsers or with getting it verified as html by W3?Thanks.
Link to comment
Share on other sites

Thank you that explains things. I did not realize the difference for browsers was whether the extension was htm/html or xhtml. (I told you I was a newbie). If I did things like replace my "<br>" with "<br />, etc., BUT kept the extension as html, would that cause a problem with non-xhtml browsers or with getting it verified as html by W3?Thanks.
As I said, XHTML code in HTML file won't cause problems in non XHTML aware browsers. This includes IE. All browsers will render XHTML as if it is HTML. Since the differences aren't that many, you shouldn't have many problems with that.And for validation- HTML file that has XHTML code will validate as XHTML but not as HTML.It's a weird mix really. You need to have firefox and see it all for yourself to see the big(er) picture.
Link to comment
Share on other sites

Firefox is the browser I've used for years. I only use IE for XP updates.
Well then. Good.
  1. Save XHTML file and try viewing it in Firefox. You can. Try it in IE. You won't be able to.
  2. Try to rename the file to HTML - viewable in both browsers.
  3. Try validating the file (by uploading it to the W3C validator) - it will validate as XHTML, even though it's saved as HTML file.
  4. Try to rename the file back to XHTML and validate it again - it will (still) validate as XHTML.

And for the fun part. Seeing XHTML differences in action.Try to add in the head:

<style type="text/css">body {background-color:red;}</style>

save the file as XHTML and view it in Firefox. You should NOT see a red background color on the body. Try to save it as HTML and try again in both browsers. There should be a red background.At least I know that happens when XSLT transformations produce XHTML code. I'm not sure if pure XHTML files are affected.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...