I have noticed jQuery (or is it Firefox) will turn some of my <span class="presentational"></span> into <span class="presentational" />
Now my question is, is this okay to write my markup like this? Will any browsers choke on it?
Personally, I think it looks cleaner to do <span class="presentational" />
if it's going to be empty.
Yes. It is. It'll cause problems in certain cases for old browsers.
In this case, the old browser might not understand that
<script>
tag has ended.Generally it's not a problem to use shorthand for empty elements, but there are some exceptions where it can cause problems.
<script>
is an important one that needs to be closed with</script>
to avoid issues.Another is
<meta>
which works much better with spiders written as<meta></meta>
instead of<meta />
Not exactly the question, but related, in terms of formatting, versions of IE have problems with just empty elements such as
<div></div>
or<div />
. In this case,<div> </div>
is required to maintain the formatting.