"Jukka K. Korpela" in litteris
<Xns93EA59AEF5F85jkorpelacstutfi@193.229.0.31> scripsit:[color=blue]
> Let's see you examples:
>
>
david.madore@ens.fr (David Madore) wrote:[color=green]
>> <div style="clear: both"><!-- EMPTY --></div>[/color]
>
> You should assign clear: both to the next element. If there is no next
> element in the document, no clearing is needed.[/color]
Maybe you didn't read my example completely. I'm not using the
"clear" property to clear the next element, but to clear the border of
the surrounding <div>.
Here's an example (except that I didn't have a nice porn picture to
use, sorry): please compare
<URL:
http://www.eleves.ens.fr:8080/home/m...st/float1.html >
and
<URL:
http://www.eleves.ens.fr:8080/home/m...st/float2.html >
(the first uses an empty <div> as I suggest, and the second puts the
float property on the next element).
All browsers I have at hand display them differently, and that is also
what I understand from the CSS spec should be done. And evidently
there are cases when the first presentation is wanted, not the second:
in this case I think putting an empty <div> is a perfectly reasonable
solution, and I don't see in what way it would be harmful.
[color=blue][color=green]
>> Another case is when you want to style an element using the CSS
>> "content" property:[/color]
>
> The content property applies to :before and :after pseudo-elements only,
> so you just need to select whether you wish to have the text inserted
> before or after some text in the document.[/color]
Sometimes the content is generated and it is extremely difficult to
get at the previous or next generated element.
[color=blue][color=green]
>> One intereting hack consists of using the CSS "content"
>> property on an empty <span> element as it seems to be the only way to
>> include foreign text in an HTML document without embedding it.[/color]
>
> Would that really fall within the principle of using CSS for optional
> presentational suggestions? It's hardly a good argument in favor of
> something that it would be needed for a hack that shouldn't be used.[/color]
I would very much prefer if the fathers and normalizers of HTML had
foreseen the usefulness of a tag to include plain text (or
inline-level HTML) from a foreign source within HTML (without creating
a block-level element for embedding). But given that this tag doesn't
exist, what else can I do? I agree that it's a hack to use CSS for
that, and most often contrary to the goals and principles of CSS
(though not always: sometimes the inserted text *is* optional and of
presentational nature), but until someone suggests a better
solution...
[color=blue]
> But
> even for such a hack, you can simply assign the content property to a
> suitable pseudo-element (as you need to do anyway, but the point is that
> the pseudo-element can be derived from a real element, as opposite to an
> artificial element with empty content).[/color]
See above: if the content is generated, it is not always easy, or even
possible, to get at the previous or next element.
Or it may be simply a matter of elegance. For example, consider this:
<p>Stylesheet name (if applicable): [<span
id="insert-stylesheet-name-here"><!-- EMPTY --></span>]</p>
with a CSS rule like
#insert-stylesheet-name-here:before { content: "Foobar"; }
in the "Foobar" stylesheet, and similarly in the others. Now it is
true that I might also write this as
<p>Stylesheet name (if applicable): [<span
id="insert-stylesheet-name-here">]</span></p>
I just happen to think it is more elegant to use an empty <span> tag,
because it avoids misbalancing the braces.
(Of course, you might then point out that the <span> shouldn't be
empty, it should contain the word "none", and CSS should be used to
avoid displaying that word when a stylesheet is active. Right. We
could continue the byzantine discussion indefinitely in this line.)
[color=blue][color=green]
>> Similarly, using the Mozilla-invented XBL language it might turn out
>> to be useful to bind to empty <div> or <span> elements.[/color]
>
> A similar case indeed, except that you're referring to a browser-specific
> invention, it seems.[/color]
Yes, and so? There's nothing wrong with browser-specific inventions
if they're useful and are employed in a way that gracefully degrades
on other browsers.
[color=blue][color=green]
>> Another case is when the <div> or <span> element starts empty, but
>> receives dynamical content through the Document Object Model, e.g.,
>> via ECMAscript.[/color]
>
> This is the kind of emptyness that potentially makes sense in SGML-based
> markup, but whether it makes sense in authoring for the WWW is less clear.[/color]
I'm not sure I understand this comment.
[color=blue][color=green]
>> Of course, the DOM might be used to create the <div>
>> or <span> element itself,[/color]
>
> I think you just objected your own example. If scripting is actually used
> to change the document's structure by adding elements, why would you hide
> this with making them technically static?[/color]
It's not a matter of hiding the fact that dynamic content will be
inserted. It's just that if there is a small (and optional) amount of
it, it is much simpler to dump it in an already existent, but empty,
<span> or <div> tag, which is located using getElementById(), than to
create that tag in the first place.
[color=blue][color=green]
>> Speaking of which, of course, an empty <div> might be useful if you
>> want several anchors pointing to the same place in an HTML document.
>> It isn't very elegant, and I would advise against it in general, but
>> sometimes it seems to be the right thing to do.[/color]
>
> The need still needs to be proven.[/color]
Why is the burden of the proof on my shoulders? Suppose you proved
that the need cannot arise?
It seems that in every case I've given (except the first, where I
still see no workaround) you've told me "this isn't absolutely
necessary" and I've answered "yes, but it's convenient". I hope we
can agree on this: that empty <div> or <span> elements are not
necessary, but they are sometimes convenient. Now suppose you told me
what is *wrong* about them?
If there is some kind of dogmatic reason ("Natura abhorret vacuum"?)
for not ever using empty <div> or <span> tags, then I will refrain
from further discussion. My religion doesn't forbid empty <div> or
<span> tags: it just frowns upon their *gratuitous* use, but allows
them when they make things simpler, or more convenient, and when no
other inconvenience results (and I'd like to know what inconvenience
can be caused by an empty tag). In that case, let us just let our
religions be at peace and people can make their own mind as to what
gospel they will follow. I do not intend to flame or debate endlessly
about what is The Right Thing.
On the other hand, if you have an important practical reason for not
using empty <div> and <span> tags (such as "this-or-that browser will
break to pieces upon encountering them" or "they cause a serious
accessibility problem for people with this-or-that disability"), then
I would certainly like to hear it.
Cheers,
--
David A. Madore
(david.madore@ens.fr,
http://www.eleves.ens.fr:8080/home/madore/ )