SitePoint Sponsor

User Tag List

Results 1 to 16 of 16
  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2004
    Location
    Los Angeles, California
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Why XHTML? What is the point?

    Hello
    May someone please help me out, explaining basically what XHTML is opposing to HTML?

    What is the point of XHTML?

    Is XHTML [considered] better than HTML? I heard it is, if yes, why?

    From what I hear, it's best to use XHTML Strict 1.1 when coding websites, having them validated by the validator at w3c.org . Is this true? If yes, why?

    I ALSO heard it was the way to go if I want my site fully cross browser compatible. Is this true?

    Basically, I'm asking all this because I'm having a rather large project currently being coded for me utilizing PHP, MySQL, and of course (X)HTML.

    Due to me hearing that it is best to use XHTML Strict 1.1, I requested that the coder use this technology and he was curious as to why I want it in XHTML Strict 1.1. I'm not really sure as to what to tell him, other than I heard it's better, which is why I'm creating this post, so I can really figure this stuff out.

    Any help is GREATLY appreciated!

    ~Thanks In Advance!

  2. #2
    bronze trophy
    Join Date
    Dec 2004
    Location
    Sweden
    Posts
    2,670
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could perhaps read through this http://www.w3.org/TR/xhtml1/ and this http://www.w3.org/MarkUp/2004/xhtml-faq

    Let's look at the alternatives (we agree that a Strict document is the way to go, right?):
    • HTML 4.01 Strict
    • HTML-compatible XHTML 1.0 Strict
    • "Real" XHTML
    Most browsers covers HTML4, so that is safe to use.

    HTML-compatible XHTML 1.0 (served as text/html) is basicly the same thing as HTML4 as far as the browser is conserned, though it has to correct some syntax errors (<br /> is not correct HTML4 and will be mapped to <br> by the browser). It's also "safe" to use (well, browsers won't choke).

    "Real" XHTML is when you serve it with an XML MIME type. The correct MIME type for XHTML is "application/xhtml+xml", and only HTML compatible XHTML 1.0 may be served as text/html. IE has no support for XHTML so it's probably not safe to use.

    The benefits outlined about XHTML (correct usage of CSS etc) are often in fact the benefits of a Strict document (which applies to HTML4 aswell). However, the actual benefits of using XHTML only apply to "real" XHTML. The benefits are that you can use other namespaces than XHTML in the same document, such as MathML, SVG, SMIL, etc. You can also use XML tools such as XSLT to convert you XHTML documents to whatever you like (HTML4, perhaps ).

    You could of aswell use X(HT)ML server side and serve it as (X)HTML to the user agent.

    Oh, and this article http://www.xml.com/pub/a/2003/03/19/dive-into-xml.html and this note http://www.w3.org/TR/xhtml-media-types/ <ins>might be interesting to read </ins>
    Simon Pieters

  3. #3
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Doll Resort
    Hello
    May someone please help me out, explaining basically what XHTML is opposing to HTML?
    XHTML is "HTML as an application of XML". That means it is XML with a document type definition (DTD) that includes the standard elements of HTML.

    At first glance, XHTML looks very much like HTML (which is the whole point). All tags and attributes must be written in lowercase letters (HTML is case-insensitive), and all attribute values must be quoted (HTML allows unquoted values as long as they only contain letters and digits). Also, attribute minimisation is not allowed, so you'll have to write things like readonly="readonly".

    There are quite a few large differences that are not that apparent, though. If you want to start tinkering with XHTML you need to learn about all of those or you'll end up with egg on your face. Some examples:
    • You can't omit tags like <head> ... </head> or <body> ... </body>.
    • You can't "hide" script code or CSS rules in <!-- SGML comments -->.
    • The element type selectors in CSS become case sensitive.
    • You can't use JavaScript functions like document.write().
    • DOM functions need to be namespace-aware, e.g. createElementNS().
    • XHTML needs to be served with the right media type, usually "application/xhtml+xml", to be treated as XHTML. If served as "text/html" it must be treated as HTML.


    If served and treated as HTML, you gain absolutely nothing by using XHTML. In fact you'll rely on browser bugs and error handling, because you are really serving invalid HTML. You cannot use CDATA sections and you cannot include elements from other XML namespaces (e.g. MathML or SVG).

    Note that Internet Explorer, the most common browser at this time, does not support XHTML at all. This makes proper XHTML virtually useless, except for very narrow audiences where you'll know that every visitor is using Mozilla, Firefox or Opera.

    Also note that you need access to the server configuration files, or to a server-side language or technique such as PHP, ASP or JSP, to change the media type. You cannot do it with a <meta> element.

    Quote Originally Posted by Doll Resort
    What is the point of XHTML?
    To mark up the structure and semantics of a web document, just like HTML.

    Quote Originally Posted by Doll Resort
    Is XHTML [considered] better than HTML? I heard it is, if yes, why?
    No.

    Since XHTML is XML, the standards require it to be well-formed. That means every element has to be closed. In HTML it is permissible to omit certain end tags (such as </P>), but that's not allowed in XHTML. Furthermore, you even have to close "empty" elements that do not even have an end tag in HTML, for instance <br/>.

    A document that must be well-formed is a lot easier to parse than regular HTML. On the other hand, even the slightest well-formedness error will generate a big fat error message instead of your page, so you really need to make sure you've got everything right.

    By using well-formed XML, you can use XML tools on the source code for various purposes. For instance, you can use XSLT to transform it into other formats, such as PDF.

    Quote Originally Posted by Doll Resort
    From what I hear, it's best to use XHTML Strict 1.1 when coding websites, having them validated by the validator at w3c.org . Is this true? If yes, why?
    Validation is always good, but XHTML 1.1 (there's no strict or transitional flavour of 1.1) is not very useful for a wide audience. The reason is that it's not fully backward-compatible with HTML, so you cannot serve it as "text/html" and pretend to use XHTML.

    Quote Originally Posted by Doll Resort
    I ALSO heard it was the way to go if I want my site fully cross browser compatible. Is this true?
    No! Only the latest and greatest among browsers support XHTML at all. If you use pretend-XHTML, following a number of "compatibility" guidelines, you can serve it as "text/html" and it will work in most browsers.

    Use HTML 4.01 (and avoid <tfoot>) if you want cross-browser compatibility.


    Quote Originally Posted by Doll Resort
    Due to me hearing that it is best to use XHTML Strict 1.1, I requested that the coder use this technology and he was curious as to why I want it in XHTML Strict 1.1.
    I don't blame him.

    XHTML is very hyped up right now by people who don't understand the differences between XHTML and HTML. They think it looks really cool to use lowercase tags (which you can do in HTML as well) and to write stuff like <br/>. As long as it's served as "text/html", it is HTML, and you'll gain absolutely nothing from using it. And since IE doesn't support "application/xhtml+xml", proper XHTML is not very useful in the real world yet.
    Birnam wood is come to Dunsinane

  4. #4
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by Doll Resort
    Due to me hearing that it is best to use XHTML Strict 1.1, I requested that the coder use this technology and he was curious as to why I want it in XHTML Strict 1.1.
    And you requested your coder use this before researching it yourself? It's always best to take anything you "hear" with a grain of salt.

  5. #5
    SitePoint Enthusiast
    Join Date
    Oct 2004
    Location
    Los Angeles, California
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by AutisticCuckoo
    XHTML is "HTML as an application of XML". That means it is XML with a document type definition (DTD) that includes the standard elements of HTML.

    At first glance, XHTML looks very much like HTML (which is the whole point). All tags and attributes must be written in lowercase letters (HTML is case-insensitive), and all attribute values must be quoted (HTML allows unquoted values as long as they only contain letters and digits). Also, attribute minimisation is not allowed, so you'll have to write things like readonly="readonly".

    There are quite a few large differences that are not that apparent, though. If you want to start tinkering with XHTML you need to learn about all of those or you'll end up with egg on your face. Some examples:
    • You can't omit tags like <head> ... </head> or <body> ... </body>.
    • You can't "hide" script code or CSS rules in <!-- SGML comments -->.
    • The element type selectors in CSS become case sensitive.
    • You can't use JavaScript functions like document.write().
    • DOM functions need to be namespace-aware, e.g. createElementNS().
    • XHTML needs to be served with the right media type, usually "application/xhtml+xml", to be treated as XHTML. If served as "text/html" it must be treated as HTML.


    If served and treated as HTML, you gain absolutely nothing by using XHTML. In fact you'll rely on browser bugs and error handling, because you are really serving invalid HTML. You cannot use CDATA sections and you cannot include elements from other XML namespaces (e.g. MathML or SVG).

    Note that Internet Explorer, the most common browser at this time, does not support XHTML at all. This makes proper XHTML virtually useless, except for very narrow audiences where you'll know that every visitor is using Mozilla, Firefox or Opera.

    Also note that you need access to the server configuration files, or to a server-side language or technique such as PHP, ASP or JSP, to change the media type. You cannot do it with a <meta> element.


    To mark up the structure and semantics of a web document, just like HTML.


    No.

    Since XHTML is XML, the standards require it to be well-formed. That means every element has to be closed. In HTML it is permissible to omit certain end tags (such as </P>), but that's not allowed in XHTML. Furthermore, you even have to close "empty" elements that do not even have an end tag in HTML, for instance <br/>.

    A document that must be well-formed is a lot easier to parse than regular HTML. On the other hand, even the slightest well-formedness error will generate a big fat error message instead of your page, so you really need to make sure you've got everything right.

    By using well-formed XML, you can use XML tools on the source code for various purposes. For instance, you can use XSLT to transform it into other formats, such as PDF.


    Validation is always good, but XHTML 1.1 (there's no strict or transitional flavour of 1.1) is not very useful for a wide audience. The reason is that it's not fully backward-compatible with HTML, so you cannot serve it as "text/html" and pretend to use XHTML.


    No! Only the latest and greatest among browsers support XHTML at all. If you use pretend-XHTML, following a number of "compatibility" guidelines, you can serve it as "text/html" and it will work in most browsers.

    Use HTML 4.01 (and avoid <tfoot>) if you want cross-browser compatibility.



    I don't blame him.

    XHTML is very hyped up right now by people who don't understand the differences between XHTML and HTML. They think it looks really cool to use lowercase tags (which you can do in HTML as well) and to write stuff like <br/>. As long as it's served as "text/html", it is HTML, and you'll gain absolutely nothing from using it. And since IE doesn't support "application/xhtml+xml", proper XHTML is not very useful in the real world yet.
    Wow, thanks a lot for that explanation! It really helped me understand more about the differences between the two. Basically, I have a few main questions that I still sort of need answerd?

    I want my site cross-browser compatible, and to be able to check with some type of validator that it meets current standards of the technology used; what do you suggest I tell my coder to do regarding the language for the project? What should I tell him to code it in? He has not yet started the project.

    ~Thanks In Advance!

  6. #6
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I would recommend HTML 4.01 Strict. HTML 4.01 is the latest standard that is widely supported, and a Strict doctype enforces a better separation of structure and presentation (which is good for the maintainability of the site). In order to be as "future-proof" as possible, I would recommend writing the HTML as much like XHTML as possible; lowercase tags and attributes, quoted attribute values, closing all elements that can be closed.

    Then I would recommend using CSS 2 for all layout and presentation, making sure that it degrades gracefully for old browsers.

    I would also recommend that you try to achieve level AA compliance with WCAG 1.0, but that's another issue.

    Finally, I would recommend using only external CSS and JavaScript files, in the spirit of separating structure, presentation and behaviour.
    Birnam wood is come to Dunsinane

  7. #7
    Robert Wellock silver trophybronze trophy xhtmlcoder's Avatar
    Join Date
    Apr 2002
    Location
    A Maze of Twisty Little Passages
    Posts
    6,316
    Mentioned
    60 Post(s)
    Tagged
    0 Thread(s)
    The only other puzzle being Internet Explorer does really understand HTML 4.01 either though that's life.

  8. #8
    SitePoint Wizard mcsolas's Avatar
    Join Date
    Jul 2004
    Location
    Hermosa Costa Rica
    Posts
    1,707
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have come to the conclusion the internet explorer really doesn't know much at all .. at least after getting on firefox.

    xhtml has its place, and the bottom line for me was that it makes you write your code with a few less hacks in it. I prefer transitional becuase, personally I am just not all that interested in having my browser throw a conniption fit each time I misplace 1 letter. Not that it happens often but watch out for strict, it can be a little hard on your coder, especially if he is using server side code to spit those pages out for you.

  9. #9
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by MCsolas
    xhtml has its place, and the bottom line for me was that it makes you write your code with a few less hacks in it.
    That is quite extraordinary, since XHTML 1.0 contains exactly the same things as HTML 4.01 with the corresponding DTD.

    Quote Originally Posted by MCsolas
    I prefer transitional becuase, personally I am just not all that interested in having my browser throw a conniption fit each time I misplace 1 letter.
    You don't want hacks, but you prefer Transitional?
    If you serve XHTML properly, it will crash and burn if you misplace a letter regardless of whether you use strict or transitional. If you serve it as text/html, it is HTML and your misplaced letters are handled more gently through HTML's less draconic error handling.

    Quote Originally Posted by MCsolas
    Not that it happens often but watch out for strict, it can be a little hard on your coder, especially if he is using server side code to spit those pages out for you.
    I would have thought server-side generation would make it easier to write well-formed markup than hand-coding...
    Birnam wood is come to Dunsinane

  10. #10
    SitePoint Zealot spinball's Avatar
    Join Date
    Oct 2004
    Location
    Harrison Twp., MI
    Posts
    132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This same topic is currently being discussed in 2 other threads right now. Who should you believe, the W3C who reccommends XHTML or someone on this board who is in the minority reccommending HTML? Do some research online for yourself.
    see: http://www.sitepoint.com/forums/showthread.php?t=251158
    and http://www.sitepoint.com/forums/showthread.php?t=253680

  11. #11
    Robert Wellock silver trophybronze trophy xhtmlcoder's Avatar
    Join Date
    Apr 2002
    Location
    A Maze of Twisty Little Passages
    Posts
    6,316
    Mentioned
    60 Post(s)
    Tagged
    0 Thread(s)
    He doesn't recommend HTML Per se he's saying contentment negation is a good solution though you aren't any better off using XHTML-P than HTML if the browser cannot deal with XHTML.

  12. #12
    SitePoint Enthusiast KuraFire's Avatar
    Join Date
    Nov 2001
    Location
    The Netherlands
    Posts
    64
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Doll Resort
    Hello
    May someone please help me out, explaining basically what XHTML is opposing to HTML?

    What is the point of XHTML?
    To be forwards-compatible;
    To be future-proof;
    To be extensible in many ways;
    To prepare us all for a much more flexible and powerful Internet, where applications can share data with each other, thanks to XML.

    These are aspects that HTML has lacked since forever, which is basically why XHTML was devised originally.

    Quote Originally Posted by Doll Resort
    Is XHTML [considered] better than HTML? I heard it is, if yes, why?
    Yes. It's considered better, and many people, some who have clue, some who don't have clue, will simply state that it's better, indefinitely.

    Most important to keep in mind, I feel, is that the very people who have created both HTML and XHTML are all recommending XHTML. But more important than the choice of HTML or XHTML is your consideration for using each, and the markup you end up using.

    Some people have already pointed out a lot of the differences. Personally, I much prefer XHTML myself because it's sending a signal to the world that we need to start adhering to Standards on the Internet, and for all of the years that HTML exists, it has never sent out that signal.

    On a practical and purely technical level, XHTML is only really better if you serve it as application/xhtml+xml and start combining other content in your pages, such as MathML. The coding style that XHTML demands can also be used when writing HTML, but one thing that XHTML does that HTML does not, is that if you validate your pages, XHTML will tell you if you made any mistakes that you perhaps didn't intend (such as forgetting a </p> or </li> or so), whereas HTML will not inform you of this.

    But that is still an issue of whether you actually care to write complete code, or not.

    Quote Originally Posted by Doll Resort
    From what I hear, it's best to use XHTML Strict 1.1 when coding websites, having them validated by the validator at w3c.org . Is this true? If yes, why?
    Go with XHTML 1.0 Strict, not 1.1 -- 1.1 must be served as application/xhtml+xml and that effectively means you won't allow Internet Explorer users on your site.

    However, I personally very strongly recommend that you use Strict and always validate your pages with the W3C Validator. It'll much better prepare you for the future, where applications and websites start using XML more and more to 'interact' with each other.

    Quote Originally Posted by Doll Resort
    I ALSO heard it was the way to go if I want my site fully cross browser compatible. Is this true?
    No, that'd be a lie. Cross-browser compatibility comes solely from the markup you use, but since XHTML uses roughly the same elements as HTML, you can get cross-browser compatibility with both. However, as said above, XHTML 1.1 demands that you use application/xhtml+xml and thus, you wouldn't even be compatible with Internet Explorer anymore in that case.

    Quote Originally Posted by Doll Resort
    Basically, I'm asking all this because I'm having a rather large project currently being coded for me utilizing PHP, MySQL, and of course (X)HTML.

    Due to me hearing that it is best to use XHTML Strict 1.1, I requested that the coder use this technology and he was curious as to why I want it in XHTML Strict 1.1. I'm not really sure as to what to tell him, other than I heard it's better, which is why I'm creating this post, so I can really figure this stuff out.

    Any help is GREATLY appreciated!

    ~Thanks In Advance!
    I personally recommend XHTML 1.0 Strict, and telling him to make sure not to use any document.write()-like practices which would only work under text/html.

    A lot of companies (around here, at least) have noticed that people who start working with valid XHTML 1.0 Strict coding practices become more efficient and simply better coders. That alone is worth going with XHTML 1.0 Strict, to me. However, keep in mind that the truly most important thing is that he creates clean, semantically rich markup. That link points to a post I wrote on this subject just two days ago, by the way. Give it a read

  13. #13
    SitePoint Zealot spinball's Avatar
    Join Date
    Oct 2004
    Location
    Harrison Twp., MI
    Posts
    132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by KuraFire
    Go with XHTML 1.0 Strict, not 1.1 -- 1.1 must be served as application/xhtml+xml and that effectively means you won't allow Internet Explorer users on your site.
    I have some confussion on this. I serve my site as application/xhtml+xml and have no issues viewing it on IE.

  14. #14
    SitePoint Enthusiast KuraFire's Avatar
    Join Date
    Nov 2001
    Location
    The Netherlands
    Posts
    64
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by spinball
    I have some confussion on this. I serve my site as application/xhtml+xml and have no issues viewing it on IE.
    No you're not, you're serving it as text/html.

    Your META element may specify application/xhtml+xml, but this is completely ignored as the XML content-type should be sent as a header, either by apache or PHP. Alternatively, you can use the XML prolog above the DOCTYPE declaration.

    True application/xhtml+xml doesn't work in IE.

  15. #15
    bronze trophy
    Join Date
    Dec 2004
    Location
    Sweden
    Posts
    2,670
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you serve a document as text/html it must always be treated as HTML no matter what content you put in it. It may look like XML, it may look like plain text, it doesn't matter because it is HTML (valid or not).

    You can't change the MIME type with a META element, and you can only specify the character encoding for text/html documents (which means that is useless for XHTML). If you want to change the character encoding in XHTML, you need to specify it in the Content-Type HTTP header, or use an XML declaration.
    Simon Pieters

  16. #16
    SitePoint Member
    Join Date
    Sep 2004
    Location
    Texas
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by KuraFire
    The coding style that XHTML demands can also be used when writing HTML, but one thing that XHTML does that HTML does not, is that if you validate your pages, XHTML will tell you if you made any mistakes that you perhaps didn't intend (such as forgetting a </p> or </li> or so), whereas HTML will not inform you of this.
    That depends on your choice of validator. The Page Valet 4.2 in “Fussy” SGML/HTML Parse Mode will identify an unclosed or a missing optional element. It does allow unquoted attribute values however.

    HTH,
    CK


Bookmarks

Posting Permissions

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