W3C home > Mailing lists > Public > www-style@w3.org > April 1998

Re: align=center

From: Chris Lilley <chris@w3.org>
Date: Fri, 24 Apr 1998 22:51:46 +0200
Message-ID: <3540FB62.49F9B13D@w3.org>
To: Frank Boumphrey <bckman@ix.netcom.com>
CC: "'Style Sheet mailing list'" <www-style@w3.org>
Frank Boumphrey wrote:
> 
> There seems to be no way in CSS to align an object in the center of the
> page, such as the align=center attribute in HTML.
> 
>  Position properties aligns the left edge of an image, text-align will align
> a table in IE4 but not an image (I don't think though that this is what the
> specification intended, I think text align is only ment to refer to text).

The image is an inline element. It needs to be inline inside some block
element.
One of the well-known problems of using <p> as a paragraph separator,
which some folks still try to do, is that you end up with text which
looks like a paragraph but the stylesheet is unable to select it:

<!doctype html system "http://www.w3.org/TR/REC-html40/strict.dtd">
<html><head><title>test</title>
<style type="text/css">P { color: red }</style></head>
<body lang=>
This text is not inside a paragraph. It will probably not be red
<p>
This text <em>is</em> inside a paragraph, and will be red
<!-- closing p tag omitted, which is valid HTML -->
</body></html>

> Am I missing something? Is this an oversight? or is this intended?

The only thing that you are missing is to put your inline images inside
a container, such as P.

P.figure {text-align: center }

<P class="figure"><IMG src="url" alt="stuff"></P>

--
Chris
Received on Friday, 24 April 1998 17:00:36 GMT

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