A Flash Developer Resource Site

Results 1 to 11 of 11

Thread: xhtml vs html

  1. #1
    Flashkit historian Frets's Avatar
    Join Date
    Oct 2000
    Location
    flashkit
    Posts
    8,797

    xhtml vs html

    How do you define the differences between html and xhtml?

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

  2. #2
    Senior Member catbert303's Avatar
    Join Date
    Aug 2001
    Location
    uk
    Posts
    11,222
    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

  3. #3
    Flashkit historian Frets's Avatar
    Join Date
    Oct 2000
    Location
    flashkit
    Posts
    8,797
    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?

  4. #4
    Senior Member catbert303's Avatar
    Join Date
    Aug 2001
    Location
    uk
    Posts
    11,222
    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

  5. #5
    Senior Member
    Join Date
    Jan 2005
    Posts
    1,582
    It could be, but I recommend still using CSS. Much easier to deal with.

  6. #6
    Senior Member catbert303's Avatar
    Join Date
    Aug 2001
    Location
    uk
    Posts
    11,222
    I guess XSLT would be used more commonly on the server side?

  7. #7
    Senior Member
    Join Date
    Jan 2005
    Posts
    1,582
    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.

  8. #8
    Flashkit historian Frets's Avatar
    Join Date
    Oct 2000
    Location
    flashkit
    Posts
    8,797
    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

  9. #9
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    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.
    - The right of the People to create Flash movies shall not be infringed. -

  10. #10
    Flashkit historian Frets's Avatar
    Join Date
    Oct 2000
    Location
    flashkit
    Posts
    8,797
    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.

  11. #11
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    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...htm_final.html
    - The right of the People to create Flash movies shall not be infringed. -

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center