How to set the height of an image using a pixel value with CSS

The code below shows you how to set the height of an HTML element using a pixel value with CSS.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
<title>Web Development Tutorials.com</title>

<style type="text/css">
img.normal { height: auto; }
img.big { height: 100px; }
img.small { height: 15px; }
</style>

</head>
<body>
<p>
<img class="normal" src="imagewebdevelopmenttutorials1w244h33.jpg" width="244" height="33" />
</p>
<p>
<img class="big" src="imagewebdevelopmenttutorials1w244h33.jpg" width="244" height="33" />
</p>
<p>
<img class="small" src="imagewebdevelopmenttutorials1w244h33.jpg" width="244" height="33" />
</p>
</body>
</html>

The code above creates the images below.

Use the text editor below to practice what you have learned.

Free Website Templates

Free Web Tools

Recommended Websites