+ 2

Align a text vertically to the center? HTML

How can I align a text vertically to the center?

10th May 2017, 7:21 PM
Adam
Adam - avatar
6 Answers
+ 7
"vertical-align:middle;" works only with <td> ( and "display:table-cell;" styled element, if in a valid <table> structure )... Old workaround for vertical text centering on a unique line, is to set the line height of the container with its height... Modern way to vertical align is to use the FlexBox model: https://code.sololearn.com/W8RqtEN6Tv8q/?ref=app Accessory, @Agung Ramadhan Putra is twice bad: "align=center" is an html attribute deprecated in Html5, in addition to horizontal centering and not vertical :P
11th May 2017, 1:43 AM
visph
visph - avatar
+ 6
vertical-align: middle; or position: absolute; transform: translate(0, -50%); top: 50%; I prefer using the last one.
10th May 2017, 7:27 PM
The Coding Sloth
The Coding Sloth - avatar
+ 1
thank you so much
10th May 2017, 7:29 PM
Adam
Adam - avatar
0
adam can you help me
10th May 2017, 8:34 PM
Ibrahim Benyounes
Ibrahim Benyounes - avatar
0
if I can then I'll try
10th May 2017, 8:35 PM
Adam
Adam - avatar
- 2
align = center
10th May 2017, 9:02 PM
Agung Ramadhan Putra
Agung Ramadhan Putra - avatar