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.
 

Similar threads

Merk
  • Merk
  • Word
Replies
0
Views
255
Merk
Merk
dEaF TO LiGhT
  • dEaF TO LiGhT
  • Word
Replies
2
Views
426
macropod
macropod
M
Replies
4
Views
170
Mike Mueller
M
M
  • Michael Virostko
  • Word
Replies
1
Views
473
macropod
macropod
K
Replies
5
Views
269
kavor
K
S
Replies
3
Views
252
Ronx
R
M
  • Michelleassistsyou
  • Word
Replies
5
Views
646
abe999
A
L
Replies
5
Views
140
Murray
M
Top