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

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

From: Bert Bos <bert@w3.org>
Date: Fri, 31 May 2002 15:35:43 +0200
Message-ID: <15607.31791.677239.449351@jfouffa.inria.fr>
To: "Steven Pemberton" <steven.pemberton@cwi.nl>
Cc: <www-style@w3.org>

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

    img {display: block; margin: auto}

    <p>Some text <img...> more text

There are implicit anonymous blocks before and after the real block,
around any inline elements that are siblings of the block. (It doesn't
matter whether that anonymous block actually exists, in the DOM or
elsewhere, since CSS doesn't allow you to set any properties on 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>

Or mathematical formulas:

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

> Or to put it another way, if in HTML <html> and <body> were display:inline,
> what would break?

Nothing would break, but some properties on html or body (such as
padding, border, line-height) would obviously have different effects.

  Bert Bos                                ( W 3 C ) http://www.w3.org/
  http://www.w3.org/people/bos/                              W3C/INRIA
  bert@w3.org                             2004 Rt des Lucioles / BP 93
  +33 (0)4 92 38 76 92            06902 Sophia Antipolis Cedex, France
Received on Friday, 31 May 2002 09:36:27 UTC

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:27:02 UTC