Re: JUSTIFY

Hakon Lie (howcome@w3.org)
Thu, 14 Aug 1997 12:13:01 +0200 (MET DST)


Date: Thu, 14 Aug 1997 12:13:01 +0200 (MET DST)
Message-Id: <199708141013.MAA11672@stovner.a.sol.no>
To: Liam Quinn <liam@htmlhelp.com>
Cc: www-html@w3.org
In-Reply-To: <3.0.2.32.19970813082410.008b6680@undergrad.math.uwaterloo.ca>
 <Pine.HPP.3.93.970812220552.5634A-100000@falcon.jmu.edu>
From: Hakon Lie <howcome@w3.org>
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=
uld
 > >really prefer a centered graphic.
 >=20
 > Use { text-align: center } with the block-level element containing t=
he=20
 > image.  E.g.,
 >=20
 > 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].

[1] http://www.w3.org/TR/REC-CSS1#horizontal-formatting
[2] http://www.w3.org/Style/CSS/Test/edge

-h&kon

H   =E5   k   o   n      W   i   u   m       L   i   e
howcome@w3.org      http://www.w3.org/people/howcome
World     W      i     d     e       Web  Consortium