center text in the middle of a div code example
Example 1: put text in center of a div
html, body {
height: 100%;
}
.parent {
width: 100%;
height: 100%;
display: table;
text-align: center;
}
.parent > .child {
display: table-cell;
vertical-align: middle;
}
Example 2: how to set text to middle in div
.center {
margin: auto;
width: 50%;
border: 3px solid green;
padding: 10px;
}