Hi, Try putting your headings inside some block level tag and then use margin:0 auto;. OR Go with text-align:center;
Thanks Ramesh -----Original Message----- From: css-d-boun...@lists.css-discuss.org [mailto:css-d-boun...@lists.css-discuss.org] On Behalf Of John D Sent: Thursday, February 24, 2011 10:13 AM To: t...@ramasaig.com; css-d@lists.css-discuss.org Subject: Re: [css-d] Centring headings of various lengths Have you tried something like this: <div id="wrapper"> <div class="left"><h2>Left Heading </h2> <p>This is an ordinary text</p> </div> <div class="middle"><h2>Middle Column </h2> <p>This is another ordinary text</p> </div> <div class="right"><h2>right Stuff </h2> <p>This is yet another ordinary text</p> </div> </div> and the styles to go with it: body { margin: 0; padding: 0; width: 100%; text-align: center; } #wrapper { text-align: left; margin: 0 auto; width: 960px; } .left { min-width: 30%; float:left; border: thin green solid; } .middle { min-width: 35%; float:left; border: thin green solid; } .right { width: 30%; float: left; border: thin green solid; } h2 { text-align: center; } p { text-align: left; } > I have a three-column (fixed width) layout which requires a heading in > each column. The lengths of the headings may vary. I am trying to centre > each heading using 'margin: 0 auto 0;', but can't make it work unless I > set a specific width on the heading. This leaves two of them off-centre > as some are longer than others. > > What is the best way to deal with this, please ? > > I could set an individual specific width on each heading, of course, but > that's inflexible and hard to maintain. > > My column widths are set as % of a fixed width container whose width is > declared in pixels. The pages are in an early stage of development and > not yet publicly available. ______________________________________________________________________ css-discuss [css-d@lists.css-discuss.org] http://www.css-discuss.org/mailman/listinfo/css-d List wiki/FAQ -- http://css-discuss.incutio.com/ List policies -- http://css-discuss.org/policies.html Supported by evolt.org -- http://www.evolt.org/help_support_evolt/ Please do not print this email unless it is absolutely necessary. The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments. WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email. www.wipro.com ______________________________________________________________________ css-discuss [css-d@lists.css-discuss.org] http://www.css-discuss.org/mailman/listinfo/css-d List wiki/FAQ -- http://css-discuss.incutio.com/ List policies -- http://css-discuss.org/policies.html Supported by evolt.org -- http://www.evolt.org/help_support_evolt/