- From: L. David Baron <dbaron@fas.harvard.edu>
- Date: Tue, 11 Apr 2000 12:13:11 -0400 (EDT)
- To: graf@relhum.org, www-style@w3.org
On Mon, 10 Apr 2000 23:54:57 -0400 (EDT), Konstantin Riabitsev (graf@relhum.org) wrote: > > I have a question. Consider this structure: > > <div id="parentDiv" style="text-align: center; width: 100%"> > <div id="childDiv" style="width: 50%"> > Div Contents here. > </div> > </div> > > I've read the specification, and it says that when > "text-align: center" is specified, all _inline_ content is aligned > accordingly. However, it doesn't say what happens to block > elements. Now, IE 5.5 would align "childDiv" in the middle of the > page (it's half the parentDiv, so the alignment would be > 25%-50%-25%). However, Mozilla-5 doesn't and I first noted that as a > bug, but now that I think about it, I'm not sure. It doesn't say anything about block elements in the definition of the 'text-align' property because 'text-align' has no effect on block level elements. The rules for block-level elements are defined in section 10.3.3 of CSS2 [1], which does not mention 'text-align'. In other words, the answer to your question is that the inner div should be on the left 50% of the page, but its contents should be centered within it. Using 'auto' values for both margins can center a block-level element. -David [1] http://www.w3.org/TR/REC-CSS2/visudet.html#q6 L. David Baron Sophomore, Harvard (Physics) dbaron@fas.harvard.edu Links, SatPix, CSS, etc. <URL: http://www.fas.harvard.edu/~dbaron/ > WSP CSS AC <URL: http://www.webstandards.org/css/ >
Received on Tuesday, 11 April 2000 12:13:13 UTC