Forum Moderators: open

Message Too Old, No Replies

mixing xhtml with html 4

Is it a good idea to use xhtml code in an html 4 template?

         

mcwebedit

6:25 am on Aug 17, 2005 (gmt 0)

10+ Year Member



I am preparing documents for a couple of clients who have website templates that use html 4 (I have to use their templates). I've been told that xhtml is valid within html 4 (and with an html4 dtd), and that it would be better for forward compatibility to use xhtml. Is it okay to do that? And is it a good idea?

For example with <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd"> as the doctype if I include <p><img src="bg_nav.jpg" alt="background" /></p> in the code, W3C validator and ARealValidator both say it's valid (though Dreamweaver flags it as an error)

Hester

8:34 am on Aug 17, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



XHTML is meant to be backwards compatibility, so yes I'd say it's OK. (Though if the whole document was XHTML it should have an XHTML doctype.)

kaled

8:53 am on Aug 17, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I don't use xhtml so I'm certainly no expert in this area but, for instance <br/> is not valid html.

There have been threads along the lines of "why doesn't this work" and the answer has been mixed html and xhtml.

Kaled.

Hester

8:29 pm on Aug 17, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



<br/> isn't usable, but <br /> is. The space ensures backwards compatibility.

Don_Hoagie

1:28 am on Aug 18, 2005 (gmt 0)

10+ Year Member



Also XHTML i believe needs to be all lowercase, so don't get sloppy with things like <BR />... my guess is that if you use a DTD of HTML4, you'll be ok. But if you start mixing versions and you have an XHTML DTD, I suppose some issues could arise.