Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 7 of 7
  1. #1
    Member
    Join Date
    May 2008
    Posts
    65
    Member #
    16874
    When does a tag need the closing tag <> </>
    and when does it not? < >

    My brain is fried from reading and being on the computer all day.

    Thanks for your help

  2.  

  3. #2
    Senior Member imagn's Avatar
    Join Date
    Jul 2007
    Location
    Los Angeles
    Posts
    156
    Member #
    15594
    There are only a few tags that don't need it and those would best be described as ones where content doesn't exist within them.
    For example:
    Line Breaks - <br />
    Horizontal Rules - <hr />
    In XHTML the traling "/>" acts as the closing tag.

  4. #3
    Member
    Join Date
    May 2008
    Posts
    65
    Member #
    16874
    Thanks imagn - That was a great way to describe it. Makes more sense to me now.

  5. #4
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    Tags like those are called "self-closing" tags. Any tag that can't contain other content (for example, an image, line break, horizontal rule, meta tag, etc.) must be self-closing.

    In XML (and therefore XHTML), <foo></foo> and <foo /> are identical as far as the parser is concerned, but in reality, there are browser problems where you have to use one or the other. For example, you can't do <script type="text/javascript" src="foo.js" /> because most browsers don't properly detect the script tag as being closed.
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!

  6. #5
    Senior Member Hitch - CP's Avatar
    Join Date
    Jun 2009
    Location
    London
    Posts
    120
    Member #
    19164
    Normal WYSIWYG programs like Dreamweaver do this for you, although many people don't like to use these programs as they can add-in unnecessary code along with other problems ...still got my vote though.
    Ali Hitch

    Portfolio & Tutorial Site
    www.alihitch.com

  7. #6
    Junior Member
    Join Date
    Jun 2009
    Posts
    8
    Member #
    19197
    Quote Originally Posted by imagn
    There are only a few tags that don't need it and those would best be described as ones where content doesn't exist within them.
    For example:
    Line Breaks - <br />
    Horizontal Rules - <hr />
    In XHTML the traling "/>" acts as the closing tag.
    This is right, the XHTML closing tag also applies to the image tag, we usually use <img src=""></img> right, but it's more easier now because instead of that we just close it after declaring the src="" or anything that follows after). <img src="" />

  8. #7
    Junior Member
    Join Date
    Jul 2009
    Posts
    14
    Member #
    19332
    Actually most of the html tags has ending tag. But there are some tags dont have end tag. For example break tag, hr tag dont have tag mostly these are the two which will use very useful in most of the coding.


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 01:28 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com