Technically, tables are perfectly valid in any "flavor" of HTML and XHTML. The thing about not using tables for layout is a recommended best practice, but strictly speaking (no pun intended) it is legal.
However, if you want an image to just be sort of floating in the middle of your page without a table, you can put it in a <div> like so:
<div id="myImage"><img src="images/foo.jpg" alt="Foo" width="300" height="150" /></div>
And then add some CSS:
#myImage {
width: 300px;
margin: 0 auto;
}
What that does is tell the browser to make the div the same width as the image, and then set the top and bottom margins to 0 and the left and right margins to "auto". The top and bottom margins are actually irrelevant in this case and can be set to anything; it's setting the left and right to auto that does that trick. If that seems a bit weird and somewhat counter-intuitive, it's because it is, but it works. Oh, and you do need to set the width to something - most likely the width of the image, but if you have a different value that's fine (so long as it is greater than or equal to the width of the image). If you do not specify the width of the div, then it will default to 100%, which will nullify the centering.
Rob Huddleston
Adobe Community Expert - Dreamweaver
Adobe Certified Developer and Instructor
Sierra Adobe/Multimedia User Group Manager
Now blogging at www.robhuddleston.com
----- Original Message ----
From: paulthesinger < astles%40btinternet.com">astles
btinternet.com>
To: HTML-Haven%40yahoogroups.com">HTML-Haven
yahoogroups.com
Sent: Thursday, July 10, 2008 11:57:47 AM
Subject: [HTML-Haven] centering images in html strict
i want to add an image in the middle of a page. i have done it as a table but it isn't html strict
how can i do this?
thanks in advance
paul
[Non-text portions of this message have been removed]
.