Why does a jpg link take up more vertical space than just the jpg?

I have the following code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>testing</title>
<style>
html, body {
box-sizing: border-box;
background-color: black;
height: 100dvh;
margin: 0px;
}

.wrapper {
height: 100dvh;
display: flex;
flex-direction: column;
margin: auto;
max-width: 1000px;
}

.content {
display: flex;
flex: 1;
background-color:yellow;
flex-direction: column;
}

.footer {
background-color: red;
display: flex;
flex-direction: row;
max-height: 40px;
align-items: center;
margin: 0px;
padding: 0px;
}
</style>
</head>

<body>

<div class = "wrapper">

<div class = "content">
content
</div>

<div class="footer">
<img src="images/email40x40.jpg" height="40" alt="eMail joe">
</div>

</div>

</body>

</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>testing</title>
<style>
html, body {
box-sizing: border-box;
background-color: black;
height: 100dvh;
margin: 0px;
}

.wrapper {
height: 100dvh;
display: flex;
flex-direction: column;
margin: auto;
max-width: 1000px;
}

.content {
display: flex;
flex: 1;
background-color:yellow;
flex-direction: column;
}

.footer {
background-color: red;
display: flex;
flex-direction: row;
max-height: 40px;
align-items: center;
margin: 0px;
padding: 0px;
}
</style>
</head>

<body>

<div class = "wrapper">

<div class = "content">
content
</div>

<div class="footer">
<img src="images/email40x40.jpg" height="40" alt="eMail joe">
</div>

</div>

</body>

</html>
It works as I would expect with no scrollbar. If I make the jpg in the footer a link like the following:
<div class="footer">
<a href="mailto:[email protected]" title="eMail joe">
<img src="images/email40x40.jpg" height="40" alt="eMail joe"></a>
</div>
<div class="footer">
<a href="mailto:[email protected]" title="eMail joe">
<img src="images/email40x40.jpg" height="40" alt="eMail joe"></a>
</div>
I suddenly get a scrollbar. Why is that? How do I keep it from happening if I want to keep the same footer height. You can use any 40 jpg to see this behavior. Thanks, Alan
5 Replies
suethepooh
suethepooh•3mo ago
images default to inline display. this leaves room for a decender. you could change vertical align to bottom, or change display to something other than inline.
Alan
Alan•3mo ago
Hi Sue: Can you give me an example of what I should change it to? Thanks, Alan
DEEP KOTHARI 🚀
img{ max-width:100%; display:block; }
Alan
Alan•3mo ago
Thank you!
DEEP KOTHARI 🚀
put this in stylesheet so it will apply on all images
Want results from more Discord servers?
Add your server