PDA

View Full Version : Combining xhtml and html on a website



georgie_b
07-30-2008, 11:50 AM
Hi guys,

I'm beginning to think that I might be having the wool pulled over my eyes so to speak by an agency and wondered if someone who knows more than me could confirm...

Would you combine html and xhtml on the same microsite? I'm sure you can, but wouldn't it make more sense to go for either one or the other?

:)

rangana
07-30-2008, 11:58 AM
The main question is how are you going to serve your pages? Will it be html or XHTML? You cannot serve both of them together at the same time. You need to choose from the two and from the selection, use a proper DTD (http://alistapart.com/articles/doctype).

If you mean to combine by the markups, ensure that if you are planning to serve your page as xHTML, you need to close all the tags (self-close is necessary) and use lowercase at all times. You should also note that name is deprecated in XHTML.

There's no sense on combining the two really. Maybe you mean to observe proper closing of the tags (which is a mandatory in XHTML) on your HTML pages. Otherwise, I should say that you cannot really serve two masters at the same time.

Hope that makes sense.

Medyman
07-30-2008, 03:00 PM
Hi guys,

I'm beginning to think that I might be having the wool pulled over my eyes so to speak by an agency and wondered if someone who knows more than me could confirm...

Would you combine html and xhtml on the same microsite? I'm sure you can, but wouldn't it make more sense to go for either one or the other?

:)

You can combine HTML and XHTML in the same project in the sense that one page would be HTML and another XHTML. As rangaga states, you can't combine them both on the same page.

Most people's definition of XHTML is HTML with self closing tags (though this isn't the true distinction between the two markup languages). In most cases, it's fairly simple to convert from one to the other. For example, a find-and-replace on "/>" to ">" should convert a XHTML page to HTML.

Twey
07-30-2008, 03:30 PM
This is a common misconception. There is a lot more involved in converting to XHTML than most people think, the biggest of which in most cases is probably that you have to drop IE support entirely, since IE currently has no support for XHTML.

Some links:
http://www.webdevout.net/articles/beware-of-xhtml
http://www.hixie.ch/advocacy/xhtml

jscheuer1
07-31-2008, 05:56 PM
XHTML served as text/html is fine for just playing around and will work as well as HTML in most cases, but it is a bad habit to get into. Many developers think that they are doing something cool or advanced by developing in XHTML, when all they are really doing is just serving it as HTML, broken HTML at that, which browsers must error correct to parse. Another common misconception is that XHTML is required for the use of any xml. However, any xml (like for RSS, etc.) that will work on an XHTML page that is being served as HTML will work just as well on an HTML page (though it would likely not be technically valid on either). For any serious project meant to be cross browser, one should stick to HTML 4.01 strict.

In short, yes. Whoever has suggested this is either messing with you, or doesn't really know what they are talking about. The only two possible exceptions I can think of being if part of the site is being done with some sort of CMS that doesn't lend itself to using HTML. These are poorly designed in regards to this issue, but they may be feature rich enough to be worth using, though there is probably a better equivalent that doesn't have the phony XHTML locked into it. Or if you are going to truly serve the XHTML as an application only for those browsers that support it.