pythonic pythonic - 1 year ago 51
HTML Question

Cannot reduce height of image in html

I am a newbie to web development. I wanted to reduce the size of an image, but the height of the image is not being reduced. What am I doing wrong here?

<!DOCTYPE html>
<meta charset="utf-8">
<title>My test page</title>
<img style="width: 100%; height: 30%" src="images/test.jpg" alt="test image">

Answer Source

Use height instead of max-height. max-height only specifies the maximum height an element can take and not the actual height.

Also, since you are using percentage to define height, make sure that the parent element(in your case, body) is given a height.