This link has been bookmarked by 97 people . It was first bookmarked on 25 Jul 2006, by someone privately.
-
13 May 14
-
23 Apr 14
-
ext-align:center;
-
-
03 Jan 13
-
13 Jun 12
-
21 Feb 12
-
22 Dec 11
-
28 Sep 11
-
12 Apr 11
-
09 Aug 10
-
24 Apr 10
-
05 Nov 09
-
Centering: Auto-width Margins
This box is horizontally centered by setting its right and left margin widths to "auto". This is the preferred way to accomplish horizontal centering with CSS, and works very well in most browsers with CSS2 support. Unfortunately, IE5/Win does not respond to this method - a shortcoming of that browser, not the technique.
There is a simple workaround. (A pause while you fight back the nausea induced by that word.) Ready? IE5/Win incorrectly applies the CSS "text-align" attribute to block-level elements. Declaring "text-align:center" for the containing block-level element (often the BODY element) horizontally centers the box in IE5/Win. There is a side effect of this workaround: the CSS "text-align" attribute is inherited, centering inline content. It is often necessary to explicitly set the "text-align" attribute for the centered box, counteracting the effects of the IE5/Win workaround. The relevant CSS follows.
body { margin:50px 0px; padding:0px; text-align:center; } #Content { width:500px; margin:0px auto; text-align:left; padding:15px; border:1px dashed #333; background-color:#eee; }
-
-
05 Sep 09
-
23 Jul 09
-
19 Jul 09
-
12 Jan 09
-
05 Dec 08
-
03 Sep 08
-
04 Aug 08
-
17 Jul 08
-
09 Jul 08
-
21 May 08
-
13 May 08
-
08 Apr 08
-
body { margin:50px 0px; padding:0px; text-align:center; } #Content { width:500px; margin:0px auto; text-align:left; padding:15px; border:1px dashed #333; background-color:#eee; }
-
-
23 Mar 08
-
29 Feb 08
Gianluca CiralliThis box is horizontally centered by setting its right and left margin widths to "auto". This is the preferred way to accomplish horizontal centering with CSS, and works very well in most browsers with CSS2 support. Unfortunately, IE5/Win does not respond
-
06 Feb 08
-
12 Nov 07
-
04 Nov 07
-
30 Oct 07
-
13 Oct 07
-
02 Oct 07
-
08 Sep 07
-
07 Aug 07
Eric Skillingbody { margin:50px 0px; padding:0px; text-align:center; } #Content { width:500px; margin:0px auto; text-align:left; padding:15px; border:1px dashed #333; background-color:#eee; }
-
06 Aug 07
-
25 Jul 07
-
19 Jun 07
-
03 Jun 07
-
08 Feb 07
-
26 Dec 06
-
25 Oct 06
-
07 Aug 06
-
24 Jul 06
-
22 May 06
-
20 Mar 06
Fogday StudiosThis box is horizontally centered by setting its right and left margin widths to "auto". This is the preferred way to accomplish horizontal centering with CSS, and works very well in most browsers with CSS2 support. Unfortunately, IE5/Win does not respond
-
22 Feb 06
-
05 Jan 06
-
10 Nov 05
-
18 Aug 05
-
16 Apr 05
-
24 Nov 04
-
07 Jul 04
Would you like to comment?
Join Diigo for a free account, or sign in if you are already a member.