Click to See Complete Forum and Search --> : html closing forward slash


bsmbahamas
08-28-2008, 04:57 PM
hi guys i've been designing websites for years and always wondered why
<br /> and other tags have the ending ' />', is this really necesarry?

that is should i start adding it to my break and image and other tags that
don't have a special closing tag?

just curious

felgall
08-28-2008, 05:41 PM
You will not find that in HTML.

Where it is used is in XHTML where all elements must have both an opening and closing tag. Where there is no content to go between the opening and closing tags eg. <br></br> it can be abbreviated to <br/>

Where you see a space in front of the / it neans that the page is really HTML and the space tells the browser to ignore the / as it shouldn't be there. The person who wrote the page content is only pretending to use XHTML.

If you are writing HTML then it is an error to put the slash there. If you are writing XHTML then it is an error if the slash isn't there (unless you use the long form instead). Note that Internet Explorer doesn't support XHTML and so XHTML can't be used if you want peoiple to see the page in that browser (unless you only pretend to use XHTML and have it delivered as HTML with errors).

bsmbahamas
08-28-2008, 05:45 PM
great thanks