W3C home > Mailing lists > Public > www-style@w3.org > May 2002

Re: May elements with display:inline contain children with display:block?

From: Rijk van Geijtenbeek <rijk@iname.com>
Date: Fri, 31 May 2002 17:02:18 +0200
Message-ID: <1722914197.20020531170218@iname.com>
To: www-style@w3.org

On Friday, May 31, 2002 Bert wrote:
> Steven Pemberton writes:

>> I read and reread the relevant parts of
>> http://www.w3.org/TR/REC-CSS2/visuren.html to try and answer this question,
>> and couldn't find from the text any reason why not. May elements with
>> display:inline contain children with display:block?

> Yes, absolutely. I do this occasionally to get a displayed, centered
> image:

>     img {display: block; margin: auto}
>     <p>Some text <img...> more text

To me this looks like a block-level element nested in a block-level
element. This produces linebreaks before and after the IMG, and the
IMG is centered (in MSIE only in Standards mode).

But what should happen with the background property of an inline
element when it has a block-level child? Should this background also
be applied to the block-level child?

See this example
http://rijk.op.het.net/test/inline-in-block.html

<p style="border: thin solid; margin-top: 2em;">bla <em
style="background: yellow;">bla <img style="border: thin solid;
display: block; margin: auto;" src="foo" alt="bar" width="100"
height="100"> bla</em> bla.</p>

Mozilla and Opera leave the background transparent for the IMG, while
MSIE colors it.



> In HTML it is rare to have blocks inside inlines, but CSS was designed
> to allow paragraphs interrupted by displayed material, such as quotes.
> It would probably be a good idea to support that in XHTML:

>     <p>Some text before the quotation
>       <blockquote>"A famous quote"</blockquote>
>       and the text continues.</p>

Isn't that what we have the 'Q' element for?


> Or mathematical formulas:

>     <p>Some text leading to a grand formula,
>      <math display=block>...</math>
>      after which the text continues.

Isn't that what we have the 'inline-block' display value for?




Greetings,
 Rijk                            mailto:rijk@iname.com

Mot du Jour:
One way to stop a run away horse is to bet on him.
Received on Friday, 31 May 2002 11:03:01 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:54:14 GMT