How to move anchor text up inside anchor tag?
Adam Breslin
I'm trying to get the anchor text to move up in the anchor tag. Here's the anchor text that says "play":
I'm trying to make this anchor text that says "play" move up slightly by putting some padding at the bottom, but this doesn't seem to work when I try with p or span elements. I don't know if there is another way to get the text to move up, but I could use some help.
Here is my html code:
<!DOCTYPE html>
<html>
<head>
<title>nested anchor links in divs</title>
<link rel="stylesheet" href="styles/styling.css">
</head>
<body>
<div id="outer-container">
<div id="sidebar">
<a href="#"><img src="images/play logo.webp" alt="play" id="play" height='25px' width='25px'><span>Play</span></a>
</div>
<div id="content">
</div>
</div>
</body>
</html>
CSS code:
html {
height: 100%;
}
body {
margin: 0;
height: 100%;
}
#outer-container {
display: table;
width: 100%;
height: 100%;
}
#sidebar {
display: table-cell;
width: 15%;
height: 100%;
vertical-align: top;
background-color: rgb(68, 68, 68);
}
#content {
display: table-cell;
width: 85%;
vertical-align: top;
background-color: gray;
}
#sidebar a {
background-color: rgb(20, 15, 15);
color: white;
display: block;
padding: 10px;
text-decoration: none;
}
span {
padding-top: 10px;
}
#sidebar img {
padding-top: .5em;
padding-right: .1em;
}
Nites
Juat added display: flex; align-items: center;
to #sidebar a
.
html {
height: 100%;
}
body {
margin: 0;
height: 100%;
}
#outer-container {
display: table;
width: 100%;
height: 100%;
}
#sidebar {
display: table-cell;
width: 15%;
height: 100%;
vertical-align: top;
background-color: rgb(68, 68, 68);
}
#content {
display: table-cell;
width: 85%;
vertical-align: top;
background-color: gray;
}
#sidebar a {
background-color: rgb(20, 15, 15);
color: white;
/* display: block; */
padding: 10px;
text-decoration: none;
display: flex;
align-items: center;
}
span {
padding-top: 10px;
}
#sidebar img {
padding-top: .5em;
padding-right: .1em;
}
<body>
<div id="outer-container">
<div id="sidebar">
<a href="#">
<img
src="https://cdn2.iconfinder.com/data/icons/social-media-2285/512/1_Youtube_colored_svg-512.png"
alt="play" id="play" height='25px'
width='25px'>
<span>Play</span>
</a>
</div>
<div id="content">
</div>
</div>
</body>