Align image vertically to text-top in HTML and CSS

Description

The following code shows how to align image vertically to text-top.

Example


<html>
<head>
<style rel="stylesheet" type="text/css">
p {<!-- ww w .j av a  2 s  .c o m-->
font: 12pt arial;
}

img.text-top {
vertical-align: text-top;
}
</style>
</head>

<body>
<p><img class="text-top" src="http://www.java2s.com/style/download.png"
alt="plane" width="74" height="74" />
The image is vertically aligned using the value text-top </p>
</body>
</html>

Click to view the demo

The code above generates the following result.

Align image vertically to text-top in HTML and CSS