/    Sign up×
Community /Pin to ProfileBookmark

Mozilla and CSS again

Hi,

I am using xhtml and css to create a new website.

I have managed to center an image using CSS (position: absolute; left: 50%; margin-left: -310?. The image is 620px wide so this centers the image OK. However, when I try to center a table the same way (in Mozilla) it does not work.

It works in Opera and IE. Is there any other way to get Mozilla to center a table using css??? (while remaining xhtml valid)

Thanks in advance,
Tim Ballard.

to post a comment
CSS

1 Comments(s)

Copy linkTweet thisAlerts:
@StefanNov 24.2002 — To center things horizontally in CSS the proper method is to use a fixed width + margin:0 auto;

That will corretly center it in Mozilla as well as Opera. However IE is buggy and will need some kind of workaround.

An easy way is to eg nest your table inside a div with text-align:center

It should have absolutely no effect on the table positioning according to spec, but in buggy IE it does (which in our case is fortunate since it alows us to fix the original bug).

BTW, to center you image with CSS, don't use that intricate positiong stuff.

text-align:center on the parent works just fine in all browsers.
×

Success!

Help @Tim158 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.24,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...