PDA

Click to See Complete Forum and Search --> : xhtml vs html



Frets
11-21-2006, 09:47 AM
How do you define the differences between html and xhtml?

What does html4 offer that still makes it appealing to designers?

catbert303
11-21-2006, 10:35 AM
In the web at large there is very little difference. XHTML is essentially HTML 4 rewritten so that it follows XML rules. So if you want a line break you need <br /> instead of <br>.

Since it uses XML rules it means in theory if you're using XHTML you should be able to do things like use namespaces to mix different markup languages in the same document (e.g. XHTML and MathML) however since effectively all XHTML content out there is served up using the text/html MIME type the browser will treat it all as HTML regardless of what DOCTYPE you chose or whether you correctly closed all your elements.

If you use the application/xhtml+xml MIME type, then some browsers (things that aren't Internet Explorer) will treat you document as XML, providing the benefits XHTML is supposed to give you. It also means they are required to spit out an error message should they encounter a parsing error. Of course whether this is a good thing or not is open to debate. It does help you enforce well-formed content across a site. Although if you provided a site to a client that broke if they accidently included an & symbol in some text without converting it to &amp; they might have reason to be a little unhappy.

Having said that the X obviously makes XHTML sound so much cooler ;)

Other than that I think there may be a few subtle differences in what is allowed, for example I seem to remember (maybe?) that in HTML 4.01 strict a fieldset must contain a legend element, whereas it is not required in XHTML 1 strict.

I think in general the most important thing is not whether you use XHTML or HTML, but whether you're using a strict doctype with good semantic markup. A clean well-formed DOM makes applying CSS and scripting to a document a far more pleasant task :)

Frets
11-21-2006, 11:45 AM
If you use the application/xhtml+xml MIME type, then some browsers (things that aren't Internet Explorer) will treat you document as XML, providing the benefits XHTML is supposed to give you.

Does that then mean that css can't be user or that xslt can be used in leiu of css?

catbert303
11-21-2006, 12:38 PM
CSS can be used to style any document whether it's HTML (text/html) or XHTML (application/xhtml+xml) though there may be a couple of small differences - for example the body element shouldn't magically expand to fill the height of the viewport in XHTML.

I don't know about using XSL-FO, but you could use XSLT to transform your document and then CSS to style the resulting transformation. In IE I think you can always link to an xsl stylesheet using,

<?xml-stylesheet type="text/xsl" href="your-stylesheet.xsl"?>

in mozilla I think you have to be viewing the document using the XML parser for this to work.

Disclaimer - in case you didn't notice I'm so not an expert on XSLT ;)

JPnyc
11-21-2006, 02:14 PM
It could be, but I recommend still using CSS. Much easier to deal with.

catbert303
11-21-2006, 05:23 PM
I guess XSLT would be used more commonly on the server side?

JPnyc
11-21-2006, 05:28 PM
If you have a dynamic page that's fully XML then yes. XSLT has a rudimentary loop system. But even then you don't HAVE to use it. You could still style it all with CSS.

Frets
11-22-2006, 04:00 AM
Well that's a releif,

I have a love/hate with xml I use it when I have to but for the most part I've always preferred MySql

cancerinform
11-22-2006, 08:39 PM
In fact you can create a Flash XML parser for XHTML pages but not for HTML, because it is not strict. I made such a parser and can get whole XHTML websites like the one from Adobe. You can then create simple XHTML pages even with table tags, which you can display in Flash formatting with CSS.

Frets
11-22-2006, 09:30 PM
In fact you can create a Flash XML parser for XHTML


This I didn't know. Is it limited to AS3

I can already parse quite a bit of xml in swf and apply css.
I just prefer straght MySql>php>loadvar

While xhtml in swf would be an enhanced method I think I would just use xhmtl rather then add the steps to display in swf.

cancerinform
11-23-2006, 12:22 AM
You can easily do it in AS2. I cannot publish the parser, because it is for a book, but here is the example:

http://flashscript.biz/book/chapter6/decodeallhtm_final.html