backslash in html elements, what's up with that?

I have seen here every so often the use of a backslash at the end og a html element in it's tag such as:<br />
<br />
<br /><br />
<img blah blah /><br />
<br />
<br />
does this have to do with xhtml? or is it specifically for compatability with macintosh computers as i've heard once or twice?<br />
<br />
any clearification on this and why anyone should pay any sort of attention to it would be appreciated...<!--content-->It has everything to do with XHTML. In XHTML, it is required for every element to have an ending "/" as opposed to HTML which doesn't require it for a lot of things.<!--content-->so if i am writing dhtml ( js, css, and html ) and im not working on anything xml nor xhtml based then macs and unix/linux wont care about those end tag things?<!--content-->Correct...unless for whatever reason you use an XHTML doc type, but if you're not using XML then there's no reason to really.<!--content-->xhtml uses them, they're used to close tags that aren't normally closed. like img and br tags.<!--content-->Nothing more to add, they pretty much said everything, except that this: '/' is a forwardslash and this: '\\' is a backslash<br />
XML uses the forwardslash for closing tags.<!--content-->Originally posted by everythingand2 <br />
it is required for every element to have an ending "/" as opposed to HTML which doesn't require it for a lot of things. <br />
uhhh NO. it is required for tags that do not have a closing tag.<br />
<br />
Originally posted by ucm <br />
<br />
so if i am writing dhtml ( js, css, and html ) and im not working on anything xml nor xhtml based then macs and unix/linux wont care about those end tag things?<br />
the OS doesn't have anything to do with it. every browser out now supports them.<!--content-->cool, so just to clearify after reading everyone's posts...<br />
<br />
if im not using nor concerned with xml or xhtml then i don't 'have' to bother with the />'s<br />
<br />
however, if i decide to use a doctype that specifys xml/xhtml or is i plan to code myself and/or add code from my associates with xml or xhtml Then it's nessisary to use them, but only in those cases...<br />
<br />
the following example should be fine as is:<br />
<br />
<html><br />
<head><br />
<title>this is a page</title><br />
<script><br />
//javascripts go here including js scripts that will<br />
//modify various elements and their style objects at<br />
//run time<br />
</script><br />
<style><br />
body { margins:'0px';padding:'0px'; }<br />
</style><br />
</head><br />
<body bgcolor="0000FF" text="F6F6F6"><br />
This is some of my content, I include a lot of things like:<br><br><br><br />
text<br><br><br />
and<br><br><br />
Images like:<img src=http://www.htmlforums.com/archive/index.php/"blah.gif" align="middle">among others...<br />
</body><br />
</html><br />
<br />
<br />
btw, for dhtml like this, what would the best doctype be and why? *obviously, in new at doctypes*<!--content-->anything that you want. most common is the 4.01 transitional. that should be used if you don't use anything else. actually that is all there is if you don't use xml/xhtml. you can also do html4.01 strict.<br />
<br />
so if you don't use xml/xhtml then you have to use html4.01 either transitional/strict.<!--content-->thanx, scoutt... what's the code for the 4.01 transitional doctype?<!--content--><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><br />
<br />
and you need this<br />
<br />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><!--content-->For reference a useful list of doctypes can be found here:<br />
doctypes @ w3.org (<!-- m --><a class="postlink" href="http://www.w3.org/QA/2002/04/valid-dtd-list.html">http://www.w3.org/QA/2002/04/valid-dtd-list.html</a><!-- m -->)<br />
<br />
Something that will potentially save you time in the future - write all your tags in lowercase, that way if/when you decide to go for XHTML compliance your life will be a lot easier :cool:<!--content-->thanx, scoutt i'll be using that from now on in my pages -- maybe now the w3c validator will be able to validate my stuff :D <br />
<br />
<br />
and lan, thanx for the resource and i'll note the lowercase code thingy too :)<!--content-->
 
Back
Top