469,290 Members | 1,887 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,290 developers. It's quick & easy.

Ending Tag Format Causes Problem

Hi all,

I'm not sure if this is an HTML issue or CSS issue but it's weird.

I've been working w/XML for 5+ years and it's always been true that you
can use a shorthand notation for an empty element like this:

"<fred/>" is the same as "<fred></fred>"
Well, I'm seeing a case where this is not true. Take a look at the
following two examples, if you would:
<div class='separatorBar'></div><p>hello</p>
<hr/>
<div class='separatorBar'/><p>hello</p>
<hr/>
These should be equivalent, right? It seems they are not. Firefox
v1.0.4 renders the two differently, as do IE 6 and Opera.

Here is the 'separatorBar' definition:

<style type='text/css'>
div.separatorBar {
margin-left:-10px;
margin-right: -10px;
border:solid;
}
</style>
What have I missed here? I though the <xxx/> notation was a shorthand
for <xxx></xxx>. Is this not true> Does anyone have an explanation for
my examples above?

Thanks.

--
Tony LaPaso


Jul 21 '05 #1
6 2236
On Fri, 13 May 2005, Tony LaPaso wrote:
I'm not sure if this is an HTML issue or CSS issue but it's weird.


I don't think so. It appears you're failing to comform with Appendix
C of the XHTML/1.0 specification, that's all. Nothing "weird" about
that.
Jul 21 '05 #2
"Tony LaPaso" <tl*****@comcast.net> wrote:
I'm not sure if this is an HTML issue or CSS issue but it's weird.
It's basically an HTML issue; f'ups set accordingly.
I've been working w/XML for 5+ years and it's always been true that
you can use a shorthand notation for an empty element like this:

"<fred/>" is the same as "<fred></fred>"
It's been true all the time and it still is true that the XMLized
version of HTML, called XHTML, which is what you are really trying to
use, is not ready for Web use. At least not without the precaution of
fooling IE & Co. into seeing it as old HTML, by applying Appendix C.

(If you don't know what Appendix C means, you haven't been paying
attention when you've read c.i.w.a.h. or your XHTML primer - or you
found a very poor primer.)
<div class='separatorBar'></div><p>hello</p>
<hr/>
<div class='separatorBar'/><p>hello</p>
<hr/>

These should be equivalent, right?


They are equivalent by XML specification. The same specification tells
you should not use "self-closing" tags except for elements with EMPTY
declared content, when "interoperability" matters, and on the Web it
surely does. Ref.:
http://www.w3.org/TR/REC-xml/#sec-starttags

On the other hand, an empty div element is almost always a symptom of
bad design, and the class name virtually confirms this.

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Jul 21 '05 #3
Okay, okay...I changed <div class='separatorBar'/> to <div
class='separatorBar' /> but there's no change in behavior. This issue
about a space before the "/>" is a 1999 issue. I can't believe the
latest version of Firefox needs that space. What's more, *both* IE and
Firefox are rendering differently based on whether or not I use <.../>
vs. <...></...>. Both browsers are consistent in this respect.

As usual, I should have been more explicit. I'm using (trying to use)
XHTML 1.0 Strict. Here's the DTD I'm using: <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">

I'm not using the xml prolog so IE 6 is not in "quirks mode".

Actually, forget about IE 6 -- it's hopelessly out of date from a
standards perspective. I am concerned about the way Firefox is
rendering it. Firefox seems to generally be pretty standards compliant.

So, still I get the same behavior. Is there something special in
Appendix C I'm missing?

BTW, what is "f'ups" and "c.i.w.a.h" mean?

--
Tony LaPaso
"Jukka K. Korpela" <jk******@cs.tut.fi> wrote in message
news:Xn***************************@193.229.0.31...
"Tony LaPaso" <tl*****@comcast.net> wrote:
I'm not sure if this is an HTML issue or CSS issue but it's weird.


It's basically an HTML issue; f'ups set accordingly.
I've been working w/XML for 5+ years and it's always been true that
you can use a shorthand notation for an empty element like this:

"<fred/>" is the same as "<fred></fred>"


It's been true all the time and it still is true that the XMLized
version of HTML, called XHTML, which is what you are really trying to
use, is not ready for Web use. At least not without the precaution of
fooling IE & Co. into seeing it as old HTML, by applying Appendix C.

(If you don't know what Appendix C means, you haven't been paying
attention when you've read c.i.w.a.h. or your XHTML primer - or you
found a very poor primer.)
<div class='separatorBar'></div><p>hello</p>
<hr/>
<div class='separatorBar'/><p>hello</p>
<hr/>

These should be equivalent, right?


They are equivalent by XML specification. The same specification
tells
you should not use "self-closing" tags except for elements with EMPTY
declared content, when "interoperability" matters, and on the Web it
surely does. Ref.:
http://www.w3.org/TR/REC-xml/#sec-starttags

On the other hand, an empty div element is almost always a symptom of
bad design, and the class name virtually confirms this.

--
Yucca, http://www.cs.tut.fi/~jkorpela/

Jul 21 '05 #4
Tony LaPaso wrote:
<snip>
So, still I get the same behavior. Is there something
special in Appendix C I'm missing?

<snip>

Probably the most important aspect of Appendix C is that you send
Appendix C documents with a content type header of 'text/html' (or
possibly do content negotiation and only send text/html as the content
type for browsers that don't admit to understanding XHTML).

A browser receiving a document with a content type header asserting that
the contents are text/html will interpret that document as HTML (what
else could they do?). Appendix C relies on the content being interpreted
as tag soup HTML with syntax that is within the known error-correction
behaviour of existing browsers. Thus the browser error-corrects the
document back to HTML, and creates an HTML DOM for it.

In HTML there is no shorthand, and that penultimate slash in a tag is
interpreted as an error in the mark-up, which is just ignored (not
strictly correct, but that is what happens). Thus <div /> becomes an
opening div tag for which there is no corresponding closing div tag. The
corresponding closing div tag will probably be inferred by the browser
in a position just before the containing element is closed.

Richard.
Jul 21 '05 #5
"Tony LaPaso" <tl*****@comcast.net> writes:
Okay, okay...I changed <div class='separatorBar'/> to <div
class='separatorBar' /> but there's no change in behavior. This issue
about a space before the "/>" is a 1999 issue.
Prince had a 1999 issue I seem to recollect.
Compatibility apart, you have already been told why you shouldn't do
that in the first place...
I can't believe the
latest version of Firefox needs that space. What's more, *both* IE and
Firefox are rendering differently based on whether or not I use <.../>
vs. <...></...>. Both browsers are consistent in this respect.
....but since you are obviously advertising text/html anything that
happens is a feature.
As usual, I should have been more explicit. I'm using (trying to use)
XHTML 1.0 Strict. Here's the DTD I'm using: <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">

I'm not using the xml prolog so IE 6 is not in "quirks mode".
You just quoted (part or all of) the prolog; you could spare yourself
some quality time if you locate and read the specs right away instead of
of getting confused by helpful misinformation (webstandards.org and
such) first.
BTW, what is "f'ups" and "c.i.w.a.h" mean?


Since I'm replying to this in a 'c.i.w.a.s.', it means you need to
install a newsreader to participate on Usenet.
--
| ) PiĆ¹ Cabernet,
-( meno Internet.
| ) http://bednarz.nl/
Jul 21 '05 #6
Thank you all... I changed the content type to application/xhtml+xml
and Firefox rendered it like a charm!

I'm a little new to CSS and trying to get my site up to standards and
so some of my questions might seem a little simple. But thank you all
for responding.
--
Tony LaPaso


"Tony LaPaso" <tl*****@comcast.net> wrote in message
news:6r********************@comcast.com...
Hi all,

I'm not sure if this is an HTML issue or CSS issue but it's weird.

I've been working w/XML for 5+ years and it's always been true that
you can use a shorthand notation for an empty element like this:

"<fred/>" is the same as "<fred></fred>"
Well, I'm seeing a case where this is not true. Take a look at the
following two examples, if you would:
<div class='separatorBar'></div><p>hello</p>
<hr/>
<div class='separatorBar'/><p>hello</p>
<hr/>
These should be equivalent, right? It seems they are not. Firefox
v1.0.4 renders the two differently, as do IE 6 and Opera.

Here is the 'separatorBar' definition:

<style type='text/css'>
div.separatorBar {
margin-left:-10px;
margin-right: -10px;
border:solid;
}
</style>
What have I missed here? I though the <xxx/> notation was a shorthand
for <xxx></xxx>. Is this not true> Does anyone have an explanation
for my examples above?

Thanks.

--
Tony LaPaso

Jul 21 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Rusty Shackleford | last post: by
14 posts views Thread by Tony LaPaso | last post: by
3 posts views Thread by Just D | last post: by
5 posts views Thread by raffelm | last post: by
1 post views Thread by Manlio Perillo | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.