[thelist] Centering a table with css

aardvark roselli at earthlink.net
Thu Mar 14 13:16:00 CST 2002

> From: "Warden, Matt" <mwarden at mattwarden.com>
> >> Right now, i'm adding a margin on each side of the table. I don't
> >> want to do that if I don't have to. Here's the page:
> >>
> >> http://bhs2002.com/bhs.shtml
> >
> >oh, does that mean you don't want the margin?
> >
> >your approach is good (width-80%,right-10%,left-10%), btw...
> >nothing really wrong with it if it works...
> oh, i dunno. it looked like a hack to me when i did it.
> would having the literal percents in there work in more browsers than
> "auto"?

yes, it should... i'm operating on memory here, i haven't centered
things in a while...

however, keep in mind why 'auto' exists...

you're lucky in that your table is set to 80%, so no matter what
size the window (within reason), it will always be 80%, leaving you
a definite 20% to split up (or 10% per side)...

what if your table were, say, 595 pixels wide... you couldn't say
that it would take up 20%, 80% or whatever % in anyone's
window... 'auto' i supposed to address that by taking available
space and, when specified in opposite margins, even that space
out, which (ideally) results in centering...

so, no, not a hack, just feels like one from all the years of hack
we've done... we're all pretty used to looking for a keyword
approach (center, middle, etc.), and that doesn't exist anymore...

More information about the thelist mailing list