SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Guru DeNasio's Avatar
    Join Date
    May 2001
    Posts
    830
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    <br /> instead of <br> ?

    I often see "<.. />" in codes, like <br /> or <img src=".." />.

    But why do people use "/>" instead of ">" ?
    Ballot-Box.net - free polls for webmasters
    FormLog.com - free form processor

  2. #2
    He's No Good To Me Dead silver trophybronze trophy stymiee's Avatar
    Join Date
    Feb 2003
    Location
    Slave I
    Posts
    23,424
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)
    That's because the web is moving towards XML. In XML all tags must have a closing tag. In HTML, that's not true. So, to begin the migration, in XHTML 1.0 (the first phase of moving from HTML to XML), all tags that don't normally have a closing tag (BR, HR, IMG, etc) must end in />.

  3. #3
    SitePoint Guru DeNasio's Avatar
    Join Date
    May 2001
    Posts
    830
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, i'm from the very old school. I have some catching up to do!
    Ballot-Box.net - free polls for webmasters
    FormLog.com - free form processor

  4. #4
    SitePoint Addict JNKlein's Avatar
    Join Date
    Sep 2004
    Location
    New York, NY
    Posts
    258
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    To keep it backwards complaint with ye olde HTML, doesn't there have to be a space between <br and /> too?

  5. #5
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Some old browsers need a space before the "/>", yes.

    DeNasio, don't panic. XHTML is of no use whatsoever at this time, and will remain so for a few years at least. The reason is that Internet Explorer doesn't support XHTML.

    (Yes, it will accept the pretend-XHTML served as HTML, but then you gain absolutely nothing from "using" XHTML, because it will be interpreted as badly written HTML.)

    This is just a bandwagon right now. Lots of newbies believe that XHTML is somehow "better" than HTML. It isn't, unless you do it "right", and as I said, that can't be done right now except for very narrow (non-IE) audiences.

    Besides, there are much more to XHTML than sprinkling a few slashes here and there, using lowercase, and quoting all attribute values. It impacts CSS and JavaScript as well, and those differences are much greater than the few syntactic differences in the markup.
    Birnam wood is come to Dunsinane


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
  •