Flexbox solution is the way to go in/from 2015. justify-content: center is used for the parent element to align the content to the center of it.
HTML
CSS
.container {
display: flex;
justify-content: center;
}
.center {
width: 800px;
}
Output
.container {
display: flex;
justify-content: center;
}
.center {
width: 400px;
padding: 10px;
background: #5F85DB;
color: #fff;
font-weight: bold;
font-family: Tahoma;
}
Centered div with left aligned text.