SitePoint Sponsor

User Tag List

Results 1 to 7 of 7

Hybrid View

  1. #1
    SitePoint Addict artemis's Avatar
    Join Date
    Sep 2003
    Location
    London
    Posts
    295
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Brain fart with break tag

    Had a brain fart this morning and accidentally wrote </br> instead of <br /> on an XHTML page. Funny thing was that whilst Firefox correctly ignored it, IE assumed it was a line break tag. Just thought I would post it as a slightly odd bug or quirk.

  2. #2
    Word Painter silver trophy Shyflower's Avatar
    Join Date
    Oct 2003
    Location
    Winona, MN USA
    Posts
    10,053
    Mentioned
    142 Post(s)
    Tagged
    2 Thread(s)
    Oddly enough, IE is more forgiving for errors that FireFox. I guess it comes from their "intuitive" interface. However, I would much rather write code the correct way so I am very grateful that FireFox doesn't put up with code shennanigans!
    Linda Jenkinson
    "Say what you mean. Mean what you say. But don't say it mean." ~Unknown

  3. #3
    Caveat surfer Buddy Bradley's Avatar
    Join Date
    May 2003
    Location
    Cambridge, UK
    Posts
    2,366
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm not 100% sure, but my guess would be that you can actually write break tags like this in XHTML:
    Code:
    <br></br>
    The self-closing version is a shorthand. The IE parser just assumed that you forgot to type the opening tag and added it in for you.

  4. #4
    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)
    Yes you can write <br></br> though obviously it is not best practice.

    Also Appendix C.2. Empty Elements has an example.

  5. #5
    bronze trophy
    Join Date
    Dec 2004
    Location
    Sweden
    Posts
    2,670
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Treating </br> as if it were <br> is a quirk that IE4 copied from NN4 I believe. Firefox has this quirk still in quirks mode. Same for stray </p>s (which are treated as <p></p>).

    This has nothing to do with XHTML btw. This is a tag soup phenomenon that only lives in tag soup environments (text/html).
    Simon Pieters

  6. #6
    SitePoint Wizard bronze trophy DaveWoods's Avatar
    Join Date
    Dec 2004
    Location
    Derbyshire - UK
    Posts
    2,651
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Given the fact that in theory <br /> could be written like <br></br>

    Would that mean that if you were using a div for decoration on a page and it was empty that you could write it like <div class="corner" />

  7. #7
    bronze trophy
    Join Date
    Dec 2004
    Location
    Sweden
    Posts
    2,670
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you serve as XML yes, text/html no. If you serve XHTML as text/html you must (according to RFC2854 which is referenced in section 5.1 in the XHTML 1.0 spec) follow appendix C, which means <br></br> and <div/> are disallowed.

    text/html is always treated as HTML by UAs. </br> is invalid HTML (though HTML4 doesn't define error handling for it).
    Simon Pieters


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
  •