Outer Court

Tech - Posts to comp.infosystems.www.*

From: "Philipp Lenssen" <phil@mrinfo.de>
Newsgroups: comp.infosystems.www.authoring.stylesheets
Subject: Re: Absolute Positioning - Class vs. ID
Date: Wed, 31 Oct 2001 10:57:01 +0100
Message-ID: <9rohr7$bc$1@swifty.westend.com>
"webboi" <webboi@msn.com> wrote in message
> I am trying to clarify why using the ID selector is preferred, in most
> cases, over the Class selector in absolute positioning. Is the ID most
> appropriate because you won't likely want to elements positioned on top of
> each other and therefore will only need to use it once? Any tips would be
> appreciated.

I mostly use classes for anything, I might not even know at the time of
defining the HTML if the element will be absolutely positioned or not, and
sometimes it might switch, or depend on the context. Or if the output is
generated by server-side scripts; imagine how much harder it would be for a
script to combine all pages together say for optimized printing when it's
<div id="content">...</div> instead of <div class="content">...</div>.
Another example, I recently outputted status information (12% done. 22%
done,. 38% done. ...) to the client while the server-side script was
calculating table contents. I used a class for every "status" element, gave
them a background-color, and overlayed them absolutely on top of each other,
so the next one would replace the old one. (I also used some kind of
blue-bar to show the progress, this was done using inline style with "width:
Xpx".) Sometimes, you also have DHTML say to toggle the display properties
of an element. In that case, I would always use an ID. And sometimes, your
stylesheets become so big and so much, that you can't figure out how to
override all the other selectors, then you might just give it an ID to make
the selector more important. And then, because multiple classes don't work
in popular browsers, you might just use an ID because the class is already

Philipp Lenssen
M+R Infosysteme