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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Centre text against image 1

Status
Not open for further replies.

jimmyshoes

Programmer
Jun 1, 2008
132
GB
Is the following the correct way to center text on an image
Code:
<p style="border:1px solid #ffffff">Text<img src="1.jpg" style="vertical-align:middle"/></p>

I have been experimenting with this. the surrounding <p> takes on the height of the image and the text aligns to the image depending on the vertical-align

What seems slightly odd to me is that the TEXT seems to respond to the styling on the IMAGE. I would have expected to have had to apply a style to the text itself to get this behaviour
 
That's not quite right. The image is adjusted to align with the text. Since the image is inside the paragraph, the border is simply adjusting to include it.

Greg
People demand freedom of speech as a compensation for the freedom of thought which they seldom use. Kierkegaard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top