1/* To center text, you need to use text-align. */
2
3.centerText {
4 text-align: center; /* This puts the text into the center of the
5 screen. */
6}
7
8/* There are also other things that you can use in text-align:
9left, right, and justify. Left and right make the test align to the
10right or left of the screen, while justify makes the text align both
11sides by spreading out spaces between some words and squishing others. */
1/* Using flex to center anything*/
2.parent{
3 display: flex;
4 justify-content: center; /* Centering Horizantly */
5 align-items: center; /* Centering Vertically */
6 /* Every element inside this div will be centered*/
7}
8/* Using Line Height*/
9.main-div{
10 width: 50%;
11 height: 40px;
12}
13.main-div p{
14 line-height: 40px; /* Same as parent height*/
15 /* p will be centered vertically inside its parent div*/
16}
17/* CSS Property */
18p{
19 text-align: center;
20}
1/* Character-based alignment in a table column */
2
3text-align: center;
4
5/* The inline contents are centered within the line box. */