On May 22, 2012, at 13:26 , Georg wrote: > On 22.05.2012 06:34, mem wrote: > >> My question is: It seems to me that, using text-align:center; should >> serve the propose of centering text and NOT img and other nested >> divs, am I wrong ? > > Yes, in that 'text-align: center' centers "inline-level" elements/content and > not "block-level" elements. Since you can alter "inline-level" elements to > become "block-level" elements, and the other way round, you have to keep > track of what level each element actually is at when you style nested > elements. > > An 'img' is for instance "inline-level" by default, and will therefore be > centered by 'text-align: center', if you haven't redefined the 'img' to > become a "block-level" element by means of a general or specific declaration > for images. > > Also, elements nested inside an element with 'text-align: center' declared on > it, will inherit that declaration unless or until you override it by another > 'text-align' declaration. So although nested "block-level" elements won't > themselves be centered, their "inline-level" content will be centered by the > inherited declaration. > > Philippe has covered the rest... :-) > > regards > Georg
Thanks a lot for those clarifications. Let's see if I get this: So, precisely speaking, even if we have a *p* and the text inside the *p* appears centered, the *p* himself doesn't. We may think that *p* (a block level element by default) is centered, where, in fact, only the text inside is. Plus: So even if we have a nested div with some text and images inside, that div (a block element by default) will NOT be centered, but it will seem to be, because their contents, mostly texts and the images (inlines by default), will be centered. Example: http://jsfiddle.net/Wz4Ck/ So, using text-align center as I did: #bottom-left-column, #bottom-middle-column, #bottom-right-column { float:left; width:33%; text-align:center; /*center inline contents and text on those boxes*/ } Is perfectly valid. We can do it, if we understand what we are centering, what we wish to center, and the nested effects that has. Is this ok ? k. regards, mem ______________________________________________________________________ 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/