Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I centre an image horizontally?

Status
Not open for further replies.

HelloMike

MIS
Feb 14, 2003
210
GB
Simple question, but the answer eludes me at the moment.
How do I centre (center) an image horizontally inside a <div> or a <span>?

TIA,
Mike.
 
Images are, just like text, links, input boxes and spans inline elements, thus to center them, you need to do the same as with these elements:
Code:
<body>
<div [b]style="text-align: center;"[/b]>
 <img src="MyImage.jpg" alt="My Image" width="250" height="150" />
</div>
</body>
Hope this helps.
 
Thanks Vragabond. That comes as confirmation - I figured it out shortly after posting & tried to post back but tek-tips was giving server jrun errors, so I forgot about it and had lunch instead :)

Mike.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top