Need some clarifications on xhtml

Discussion in 'HTML' started by Thierry Lam, Sep 28, 2006.

  1. Thierry Lam

    Thierry Lam Guest

    I've decided to switch to xhtml and I've added the following at the top
    of my page:

    <!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">


    However, my page is still working and I can't see any warnings whenever
    I use old html tags like <br> instead of <br/>. What other things
    should I add to validate xhtml tags?
     
    Thierry Lam, Sep 28, 2006
    #1
    1. Advertising

  2. Thierry Lam

    jojo Guest

    Thierry Lam wrote:

    > I've decided to switch to xhtml and I've added the following at the top
    > of my page:


    Why?

    >
    > <!DOCTYPE html
    > PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    >


    Where do you expect the warnings to appear? Definetly not in the
    browser... (except you use some firefox extension or something similar)

    >
    > However, my page is still working and I can't see any warnings whenever
    > I use old html tags like <br> instead of <br/>. What other things
    > should I add to validate xhtml tags?
    >


    A XHTML document should look like this:

    <?xml version="1.0" ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <!-- page head -->
    </head>
    <body>
    <!-- page body -->
    </body>
    </html>
     
    jojo, Sep 28, 2006
    #2
    1. Advertising

  3. Thierry Lam

    cwdjrxyz Guest

    Thierry Lam wrote:
    > I've decided to switch to xhtml and I've added the following at the top
    > of my page:
    >
    > <!DOCTYPE html
    > PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    >
    >
    > However, my page is still working and I can't see any warnings whenever
    > I use old html tags like <br> instead of <br/>. What other things
    > should I add to validate xhtml tags?


    Go to http://validator.w3.org/ to validate a page as any of several
    forms of html/xhtml including the one you mention. The break tag you
    mention usually is written with a space included in it as <br />. I
    believe this was done to avoid problems with some browsers. In general
    all tags have to be closed in xhtml. When tags such as br and img that
    have no close tag in html are used they most be closed as was done for
    br above such as <img blah />. Closing p is optional in html. In xhtml
    a paragraph must always use a closing tag </p> in addition to the
    opening tag <p>. Unless you set up your server to serve true xhtml
    using an extension such as xhtml and associating a mime type with it
    such as xhtml+xml, the page will just be served as text/html despite
    your xhtml tags and Doctype. Note the page will still validate as xhtml
    if there are no errors. The validator just checks the code for what you
    ask. However if you use the advanced interface to validate, there will
    be additional information showing you how the page is served. Recent
    Firefox, Netscape, Opera, and a few other browsers can handle xhtml
    served correctly as such. However IE6 will not, and you can not view
    the page. You have to provide IE6 and a few older browsers with an html
    4.01 strict page using some server side code or whatever to allow
    viewing of the page by them. Unless you do all of this, there is no
    point in writing the page in xhtml if IE6 and some older browsers are
    intended to be viewed with it. Unfortunately it appears that not even
    IE7 will handle true xhtml. It is quite possible to serve even xhtml
    1.1 correctly. However, to do so, you have your work cut out for you
    and much to learn, likely including some server side languages.

    When a page is properly served as xhtml is viewed with a browser that
    can handle it, the browser becomes as strict as a mother superior in a
    1800s convent. Tiny code errors that would cause little or no harm on
    an html page often cause the browser to give you an error message
    rather than a view of the page. Unless one writes very good html 4.01
    strict, don't even think of writing xhtml and serving it properly as
    such.
     
    cwdjrxyz, Sep 28, 2006
    #3
  4. Scripsit jojo:

    > Thierry Lam wrote:
    >
    >> I've decided to switch to xhtml and I've added the following at the
    >> top of my page:

    >
    > Why?


    I guess the usual explanation is that people have no idea of XHTML or its
    practical usefulness or uselessness, but someone told them it's the "newest
    recommendation".

    > Where do you expect the warnings to appear? Definetly not in the
    > browser...


    Actually, a browser _could_ have a validating XML parser. That was really
    more or less part of the idea. Of course, that would not mean warnings but
    error messages.

    > A XHTML document should look like this:
    >
    > <?xml version="1.0" ?>


    Well, in theory it could start with the <?xml ...> declaration, but in
    practice, that throws IE to "quirks mode", making it simulate some errors of
    IE 5. How modern...

    --
    Jukka K. Korpela ("Yucca")
    http://www.cs.tut.fi/~jkorpela/
     
    Jukka K. Korpela, Sep 28, 2006
    #4
  5. Jukka K. Korpela wrote:

    >> <?xml version="1.0" ?>


    > Well, in theory it could start with the <?xml ...> declaration


    .... although it might be forbidden in XHTML documents served as text/html
    (its hard to say for sure, the spec is rather fuzzy regarding the subject
    and I prefer to avoid it altogether by using HTML 4.01 on the client side
    for webpages except where XHTML provides an actual practical benefit).

    --
    David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
    Home is where the ~/.bashrc is
     
    David Dorward, Sep 28, 2006
    #5
  6. Thierry Lam

    jojo Guest

    Jukka K. Korpela wrote:

    >>> I've decided to switch to xhtml and I've added the following at the
    >>> top of my page:

    >>
    >> Why?

    >
    > I guess the usual explanation is that people have no idea of XHTML or
    > its practical usefulness or uselessness, but someone told them it's the
    > "newest recommendation".


    Yeah, I suppose that's the reason. But unfortunately the "newest" is not
    always the best recommendation (Not that the idea behind XHTML is bad,
    it's just the poor support in "modern" browsers which is...)

    >> Where do you expect the warnings to appear? Definetly not in the
    >> browser...

    >
    > Actually, a browser _could_ have a validating XML parser. That was
    > really more or less part of the idea. Of course, that would not mean
    > warnings but error messages.


    Right, it could have one. But most browsers have none or do only use it
    on properly served XHTML documents (Which means the MIME-type is set to
    application/xhtml+xml and not text/html). And I guess the MIME type is
    not set properly...

    >> A XHTML document should look like this:
    >>
    >> <?xml version="1.0" ?>

    >
    > Well, in theory it could start with the <?xml ...> declaration, but in
    > practice, that throws IE to "quirks mode", making it simulate some
    > errors of IE 5. How modern...
    >

    Oh, yes, I remember... the quirks mode is enabled if there is no Doctype
    (with URL, the ones without enable quirks mode ASFAIK) specified in the
    *first* line of a html document...

    But there maybe is another problem with the xml declaration: if php is
    available on the server and short-tags are enabled the <? is recognized
    as beginning of a php-statement...
     
    jojo, Sep 28, 2006
    #6
  7. Thierry Lam

    Toby Inkster Guest

    jojo wrote:

    > But there maybe is another problem with the xml declaration: if php is
    > available on the server and short-tags are enabled the <? is recognized
    > as beginning of a php-statement...


    The solution of course is:

    <?= '<?xml version="1.0" ?>'."\n" ?>

    --
    Toby A Inkster BSc (Hons) ARCS
    Contact Me ~ http://tobyinkster.co.uk/contact
     
    Toby Inkster, Sep 29, 2006
    #7
  8. Thierry Lam

    Andy Dingley Guest

    jojo wrote:

    > A XHTML document should look like this:
    >
    > <?xml version="1.0" ?>
    > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">


    What's an "XHTML document" ? If you mean a local XML document, then
    why not use XHTML 1.1 ? If you mean a web-published document then for
    certain you need to lose that XML declaration:
    <?xml version="1.0" ?>
    as it breaks far too many web user agents.

    > <html xmlns="http://www.w3.org/1999/xhtml">


    If you're going to pontificate, make sure you're infallible.

    Where are the lang and xml:lang attributes ?
     
    Andy Dingley, Sep 29, 2006
    #8
  9. Scripsit Andy Dingley:

    > If you're going to pontificate, make sure you're infallible.
    >
    > Where are the lang and xml:lang attributes ?


    Are _you_ trying to pontificate that the lang and xml:lang attributes are
    required? Surely not by the syntax, or by any HTML specifications.

    Language markup might good practice, but it has fairly little practical
    value. Programs don't use the language information expressed that way very
    much, partly because the information is so often plain wrong.

    --
    Jukka K. Korpela ("Yucca")
    http://www.cs.tut.fi/~jkorpela/
     
    Jukka K. Korpela, Sep 29, 2006
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Nicola Farina
    Replies:
    2
    Views:
    650
    Patrick.O.Ige
    Jan 22, 2006
  2. Phil Bouchard

    Re: smart pointer clarifications

    Phil Bouchard, Aug 21, 2008, in forum: C++
    Replies:
    3
    Views:
    290
    Phil Bouchard
    Aug 23, 2008
  3. peteshinners

    Clarifications on compiling for Windows

    peteshinners, Jan 8, 2010, in forum: Python
    Replies:
    3
    Views:
    279
    Martin v. Loewis
    Jan 9, 2010
  4. Panagiotis Atmatzidis

    Few clarifications on recursion

    Panagiotis Atmatzidis, Jan 3, 2010, in forum: Ruby
    Replies:
    9
    Views:
    143
    Bob Hutchison
    Jan 3, 2010
  5. Jeremy J Starcher

    Same Origin Policy -- clarifications?

    Jeremy J Starcher, Apr 28, 2008, in forum: Javascript
    Replies:
    2
    Views:
    121
    Jeremy J Starcher
    Apr 30, 2008
Loading...

Share This Page