CSS Question

Erik Price eprice at ptc.com
Wed Jun 11 16:38:45 EDT 2003


Cole Tuininga wrote:

> As I understand, the "correct" way to do it now would be with style
> sheets.  However, I can't seem to figure out the attribute to use.  The
> closest I could find was "text-align", but that seems to only work on
> text (which does make sense).
> 
> 
> I've been using www.w3schools.com (a very handy reference) to pick up
> xhtml and css, but I couldn't find anything about this in there. 
> Anybody have any hints, pointers, etc?

The CSS2 spec lets you get really detailed about exactly where you want 
stuff to go -- but most browsers don't have full support for it yet. 
But it sounds like you've discovered "float" does the job.

If you ever want to "center-align" an image, one recommended way is to 
set its margin-left and margin-right properties to "auto".  This is a 
clip from the CSS on my personal site (which has a centered image):


div.glamour img {
     border-color: #FFF;
     border-width: thin;
}

div.glamour p {
     width: 35em;
     text-align: center;
     margin-left: auto;
     margin-right: auto;
}


I'm centering the entire div whose class is "glamour" but you can 
equally apply this to an img tag.



Erik




More information about the gnhlug-discuss mailing list