Slashdot Mirror


Why You Should Use XHTML

Da_Slayer writes "The w3's HTML group has released the 6th public working draft for XHTML 2.0. XHTML 2 is a general-purpose markup language designed for representing documents for a wide range of purposes across the Web. Meaning it is to be used for document structuring which is why it does not have presentation elements. The draft is located at w3's website. Also they have a FAQ about why you should use XHTML over HTML. It goes into specifics about embedding MathML, SVG, etc... and has links to tools and resources to help convert existing html documents to xhtml. One of those resources is a document on XML events and its advantages over the onclick style of event handling."

8 of 657 comments (clear)

  1. Funny quote by slashdevslashtty · · Score: 5, Informative

    Which browsers accept the media type application/xhtml+xml? Browsers known to us include all Mozilla-based browsers, such as Mozilla, Netscape 5 and higher, Galeon and Firefox, as well as Opera, Amaya, Camino, Chimera, DocZilla, iCab, Safari, and all browsers on mobile phones that accept WAP2. In fact, any modern browser. Most accept XHTML documents as application/xml as well. See the XHTML Media-type test for details. Does Microsoft Internet Explorer accept the media type application/xhtml+xml? No.

    --


    M$ Lawyer: But `gcc /dev/random -o kernel.dll` is our trade secret!
  2. Why You Should Use XHTML 2.0 ???? by stonebeat.org · · Score: 4, Informative

    XHTML 2.0 almost forces you to seperate "content" from "presentation". Which is a good thing.

    Something better would be to use pure XML for creating content and then let the browser apply a CSS to present the content.
    See Mozilla + CSS + XML = Structured + Formatted Content for more info.

  3. Re:XHTML and XML?? by typhoonius · · Score: 5, Informative

    XML is a metalanguage; that is, it's a mark-up language for writing other mark-up languages. XHTML is one such language. It's basically plain old HTML but with XML's stricter rules. I like it because it discourages sloppy coding (sort of like preferring Java over Perl).

    Other XML languages include SVG (for vector graphics), WML (for simple web pages designed for cell phones; never really took off), and RSS (for news feeds).

  4. Re:XHTML and XML?? by Kentamanos · · Score: 5, Informative

    XML is a pretty generic set of format rules. There are LOTS of various formats that are implemented in XML (SVG, XHTML, XSLT for some popular examples).

    XHTML applies the rules of XML to HTML. For instance you can have one root node, you have to close all tags, attributes have to have single or double quotes around their values, etc.

    Writing something that parses XHTML is a LOT simpler than writing something that parses HTML. It's also easier to confirm you've written it properly (using schemas for instance, which are also written in XML :)).

  5. It's always the way. by caluml · · Score: 5, Informative
    From the FAQ:
    Which browsers accept the media type application/xhtml+xml?

    Browsers known to us include all Mozilla-based browsers, such as Mozilla, Netscape 5 and higher, Galeon and Firefox, as well as Opera, Amaya, Camino, Chimera, DocZilla, iCab, Safari, and all browsers on mobile phones that accept WAP2. In fact, any modern browser. Most accept XHTML documents as application/xml as well. See the XHTML Media-type test for details.

    Does Microsoft Internet Explorer accept the media type application/xhtml+xml?

    No. However, there is a trick that allows you to serve XHTML1.0 documents to Internet Explorer as application/xml.

    Include at the top of your document the line in bold here:

    <?xml version="1.0" encoding="iso-8859-1"?>
    <?xml-stylesheet type="text/xsl" href="copy.xsl"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transition al.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>

    where copy.xsl is a file that contains the following:

    <stylesheet version="1.0"
    xmlns="http://www.w3.org/1999/XSL/Transform">
    &am p;n bsp; <template match="/">
    <copy-of select="."/>
    </template>
    </stylesheet>

    Note that this file must be on the same site as the document referring to it.
  6. Re:on slashdot? by MP3Chuck · · Score: 5, Informative

    You weren't kidding when you said "a lot" ... damn!

    For those who didn't RTFA the parent post had, it restructures /. with XHTML and CSS. Bottom line:
    * Savings per day without caching the CSS files: ~3.15 GB bandwidth
    * Savings per day with caching the CSS files: ~14 GB bandwidth

    And the traffic figure they used was from June 2000. Do the math.

  7. Re:XHTML and XML?? by JeanPaulBob · · Score: 5, Informative
    No one seems to have explained this point sufficiently, so I'll give it a go. (The other posts give correct information--but incomplete.)

    XML looks a lot like HTML. If you look at any XML or HTML document, you'll see a bunch of tags--a word or phrase or letter surrounded by greater than/less than symbols--perhaps with text in the middle. For example, here's basic HTML:

    <p>The quick brown fox said, <i>"Lorem ipsum dolor sit amet."</i></p>

    Your web-browser sees the <p> tag and interprets everything between it and the closing </p> tag as a paragraph. The text is formatted accordingly, with line breaks before and after. Similarly, the browser knows to show everything between the <i> and </i> tags--which are nested inside the <p> tags--using italics instead of standard formatting. Other tags include <img> for images; an image tag also has attribute inside the tag to specify the image to be shown. For example:

    <img src="mypic.jpg">

    That's HTML. XML is structured in pretty much the same way. Tags are used to give meaning to text in a systematic way, attributes can be included, tags can be nested, etc. For instance, you might store information for an address book in the following tags:

    <entry>
    <name>
    <firstName>Joss</firstName>
    <lastName>Whedon</lastName>
    <title>Mr.</title>
    </name>
    <address>
    <streetNum>1324</streetNum>
    <street>Mulholland Dr.</street>
    etc.
    </address>
    </entry>
    <entry>
    info for another person
    </entry>

    Then you would write a program that parses the data and displays it onscreen or saves it to your PDA or whatever.

    The key difference between XML and HTML or XHTML is that XML tags have no inherent meaning. You can use any text you want as a tag name, with a few limitations (no spaces, for instance). There are no assigned tag names like there are in HTML, where a <p> mean paragraph, and <b> means bold, etc. In the above example, you could change "entry" to "stickyWicket" if you want. XML data is meant to be interpreted by a machine, not a person--though meaningful tag names are obviously more convienient than random junk like "xkljad".

    As the other posts say, XML has some stricter rules than HTML. For instance, in HTML, there's a tag <br> for a line break. It doesn't have a closing tag--you just put it anywhere you want a new line to start. In XML, every tag has to have a closing tag--though you can combine both the opening and closing tags using the / symbol. You can use that to make your XML more concise. For instance, the <name> tag above with nested <firstName> and <lastName> could be simplified to this:

    <name first="Joss" last="Whedon" title="Mr." />

    People have used XML to define all sorts of formats, from music notation to images. All that means is that they decided on a tag structure with meaningful tag names and nesting, and published the rule set. Then anyone can write applications to deal with that data. XHTML is just the old HTML tag with the strict XML rules. So, in XHTML, a line break is <br />.

    To sum up, XML is just a way to structure data systematically. XHTML is an XML document with particular tags intended for a web browser.
  8. CGI.pm by mishan · · Score: 4, Informative

    I don't know about you guys, but my pages are already written in XHTML 1.0 and, thanks to CGI.pm, all I need to get my pages up to the XHTML 2.0 spec is a newer version of CGI.pm which would be provided through a newer Perl distribution.

    Ah portability..