0
I want my text to be centered horizontally and vertically on the element <div>
. For this, I am using the properties text-align
and vertical-align
for this element.
The problem is that the property vertical-align: middle;
is not centering the text vertically. Below is my code:
#myDiv {
border: 2px solid #0f0;
height: 100px;
text-align: center;
vertical-align: middle;
width: 300px;
}
<div id="myDiv">Este daqui é o meu texto</div>
vertical-align: middle;
works only when the display for table-Cell (or inline, in some cases).– Valdeir Psr
One observation is that table-Cell makes the element behave as an <td element>.
– João Monteiro