I have a div about 200px x 40px in size. Sometimes this block will contain one line of text, and in other cases it will contain two lines. In case it contains 2 lines of text, I adjusted the height of the line so that it looked balanced inside the div. However, if there is one line of text, the text is aligned at the top of the div, leaving the bottom empty.
Instead, I want one line of text to be displayed vertically in the center of the div. What is the best way to fix this? Should I put text inside a secondary element, like <p> , and then try to apply vertical-align: middle ? There seems to be a simpler, more streamlined way to achieve this. Any ideas?
source share