W3C home > Mailing lists > Public > www-style@w3.org > December 2003

Re: Is it possible to wrap an inline element in a div block?

From: Boris Zbarsky <bzbarsky@MIT.EDU>
Date: Tue, 30 Dec 2003 00:49:52 -0500
Message-ID: <3FF11200.7090404@mit.edu>
To: Robert Nicholson <robert@elastica.com>
Cc: www-style@w3.org

Robert Nicholson wrote:

> If you wanted to center an image for instance. Could you wrap it in a 
> div block and then set the margins on that div block to auto providing 
> you could some how set the width of the block to match the image?

img { display: block; margin-left: auto; margin-right: auto; }

Like that?  No wrapping; the image _is_ a block.  There is nothing that 
says an image is an inline element; it can be given any display type.

Please don't confuse "inline" in the HTML spec (which is just a 
convenient shorthand used by the DTD for a list of element names) with 
"inline" in CSS (which has to do with how the content is rendered).

Received on Tuesday, 30 December 2003 00:58:00 UTC

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