Positioning Images


J

JohnA

I am trying to use css only for formatting web pages.
Created a class for aligning images to the right called .photoright with
{float: right}
Created a class for aligning images to the left called .photoleft with
{float: left}

Now I can't figure out how to center the photo as there is no float value
for middle or center.

Any help please?

thanks
john
 
Ad

Advertisements

R

Ronx

To center an HTML element requires 3 things:

1) valid and complete !Doctype (includes URL for the .DTD file)
2) Left and right margins set to auto
3) A width for the element

Example:
<img src="image.jpg" width="230" style="margin-left:auto; margin-right:auto;" alt="description" />

The !doctype should be similar to:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
(examples are for XHTML transitional)

--
Ron Symonds
Microsoft MVP (Expression Web)
http://www.rxs-enterprises.org/fp/wf-menu.aspx


JohnA pretended :
I am trying to use css only for formatting web
pages.
Created a class for aligning images to the
right called .photoright with {float: right}
Created a class for aligning images to the left
called .photoleft with {float: left}
Now I can't figure out how to center the photo
as there is no float value for middle or
center.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Positioning graphic without absolute positioning 9
Positioning of Layers 1
iframe positioning 1
Picture Position? 1
Absolute positioning 1
absolute positioning 1
Absolute Positioning 0
Absolute positioning 1

Top