Hakon Lie (
Thu, 14 Aug 1997 12:13:01 +0200 (MET DST)

Date: Thu, 14 Aug 1997 12:13:01 +0200 (MET DST)
Message-Id: <>
To: Liam Quinn <>
In-Reply-To: <>
From: Hakon Lie <>
Subject: Re: JUSTIFY

Liam Quinn writes:

 > >Speaking of which, how do you align an image (and its
 > >resulting ALT text)?  Currently, I just let it float left, but I wo=
 > >really prefer a centered graphic.
 > Use { text-align: center } with the block-level element containing t=
 > image.  E.g.,
 > P.footer { text-align: center }
 > ...
 > <P CLASS=3Dfooter><IMG SRC=3Dfoo.gif ALT=3D"Some centred stuff"></P>=

Yup, the 'text-align' property centers the content of an element which
(despite its name) can also be an image.

If you want to center the element itself -- not its content -- you can
do something a la:

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

This is described in section 4.1.2 of CSS1 [1]:

  .. if both 'margin-left' and 'margin-right' are 'auto', they will be
  set to equal values. This will center the element inside its parent.

A test page can be found from [2].



H   =E5   k   o   n      W   i   u   m       L   i   e
World     W      i     d     e       Web  Consortium