To make the content in a div vertically and horizontally center
text-align:center;
property will set the content horizontally center of a div.
vertical-align:middle; property will set the content vertically center of a div. but to make the content positioned exactly to fit in the center line-height:400px; set the line height to the half of the height and width.
HTML:
Learning Chameleon
css:
.container{
width:400px;
height:400px;
background-color:green;
text-align:center;
vertical-align:middle;
line-height:400px;
}
CodePen Ref: Code pen source code