I am trying to get my <div> and my <button> to occupy the same space vertically. They each have a height:20px style but as you can see there is space below my <div> tag and space above my <button> tag. What should I do so that both my <div> and <button> tag take up the SAME 20px?
body, h1, h2, h3, h4, h5, h6, div, p, button { padding: 0px; margin: 0px; border: 0px; } .box { border: 1px solid red; } .boxes { display: inline-block; border: 1px solid black; height: 20px; width: 20px; } #next { display: inline-block; margin-top: auto; margin-bottom: auto; height: 20px; } <div class="box" id="box0"> <p class="boxes" id="boxes0"> </p> <button id="next" onclick="switcher()">Guess</button> </div> My jsfiddle is https://jsfiddle.net/pb4759jh68/37bfhxdr/4/
vertical-alignis your friend withinline-blockelements... (also,0pxis redundant -0is unitless, so just writepadding: 0;)