By default, an image in line with text is bottom-aligned with the bottom of the line, and top-aligned with the bottom of the previous line, which changes the text spacing:
I'd like to instead center the image on its line of text (e.g. using vertical-align:middle
), but without distorting the spacing:
How can this be done in a way which is compliant with most browsers?
As a minimal example, consider this markup:
<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8">
<title>Example</title>
</head>
<body>
<p>Some text</p>
<p>Some text <img src="http://upload.wikimedia.org/wikipedia/commons/thumb/3/38/Rect_Geometry.png/220px-Rect_Geometry.png" style="vertical-align:middle"> with an image </p>
</body>
</html>