Alan
Alan
KPCKevin Powell - Community
Created by Alan on 7/28/2024 in #front-end
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
6 replies