why block on img making the image fit the div vertically

17 Views Asked by At

In the following image i have posted the problem i am facing. bellow the images i have also added html code(style is inserted in head element) .

when we are not setting image to block there is a gap in bottom

when we are setting image to block it fills the div vertically

can anyone explain why setting image element to block makes it fill the div veritcally ?

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div{
            width : 300px ; 
            border: 5px solid black;
            background-color: aqua;
        }
        img{
            width: 100%;
            display: block;
        }
    </style>
</head>
<body>
    <div>
<img src="https://upload.wikimedia.org/wikipedia/en/1/1e/IchigoKurosakiBleach.jpg" alt="">
    </div>
</body>
</html>
0

There are 0 best solutions below