Using text-align CSS Property
CSS text-align property describes the alignment of the inline content (eg. text) contained in the element.
text-align does not define the alignment of block element itself.
Below are the possible values of text-align css property:
text-align: left; // Inline contents are aligned to the left
text-align: right; // Inline contents are aligned to the right
text-align: center; // Inline contents are centered withing the box
text-align: justify; // Inline content is aligned to left
// Below values are experimental, Most commonly used values are above four only.
text-align: start; // same as left if direction is left-to-right, and right if its right-to-left
text-align: end; // same as right if direction is left-to-right, and left if its right-to-left
text-align: match-parent;
text-align: inherit;
div { text-align: center; border: 1px solid #ccc; }
<div>Hello there, it is centered paragraph</div>
And to center the block element itself, one should use margin property (auto in left and right)
div { margin: 5px auto; }