I made box and I set line-height, the text is automatically vertically center. Is there a way or any kind of trick to set the text on the bottom of the box?
div {
width: 100px;
height: 100px;
background: #eee;
color: #333;
text-align: center;
line-height: 100px;
vertical-align: text-bottom;
}
<div>FoxRox</div>
2020 Update
You can use CSS grid, flexbox or the original method with
line-height
:Setting the
height
of thediv
and theline-height
of the text to the same value,100px
in your case, is a method of vertically centering the text within thediv
. That's the problem.The solution is to change
line-height
to twice the height minus the size of the text and remove uselessvertical-align
.