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

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 UTC