How to vertically-align element in HTML using CSS? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 13

How to vertically-align element in HTML using CSS?

Align an element(block-level) to vertical- center of <body> tag.

2nd Jun 2018, 11:23 PM
Jaydeep Khatri
Jaydeep Khatri - avatar
4 Answers
+ 5
For the positioning of elements I like to use Flexbox. https://philipwalton.github.io/solved-by-flexbox/demos/vertical-centering/
3rd Jun 2018, 12:27 AM
Mickel
Mickel - avatar
+ 14
Thank you Daniel Silva & Mickel Sánchez 😊😊
3rd Jun 2018, 12:35 AM
Jaydeep Khatri
Jaydeep Khatri - avatar
+ 2
The best way to do that is with the position property. https://www.w3schools.com/Css/css_positioning.asp
2nd Jun 2018, 11:56 PM
Daniel Silva
Daniel Silva - avatar
0
it depends if it's a list or a table
3rd Jun 2018, 1:10 PM
callum willcocks
callum willcocks - avatar