Jump to content

Centering for Firefox?


Renegade605

Recommended Posts

Hi all, in my website I use numerous divs and a few tables, none of which are centered as they should be in Firefox. (They do work in IE)The best/biggest example of this is the entire content div (the on with the green bars on the sides). They are centered in IE because of the CSS code that follows.

<html><head><style type="text/css">body, div.center { text-align: center; }</style></head><body><div> <!-- This div should be centered --><p>text</p><div class="center"><table> <!-- This should also be centered --> </table></div></div></body></html>

That makes the divs/tables centered in IE, but not FF.How can I center them in FF as well?

Link to comment
Share on other sites

Sure, it works in IE, but what you're using is an IE workaround, not the preferred CSS method. Text-align centers content, ideally text content. To really make the workaround work, your declaration should be for BOTH the body and html elements, thus:

/* The IE workaround: */body, html {   text-align: center;}/* To make elements center on their own, adjust the margin: */div.center {   margin: 0 auto;}

The second works in all standards-compliant browsers.

Link to comment
Share on other sites

Text-align should be used to center text. Use automatic margins to center children.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...