Centring Text and Embedded Elements in HTML5 and CSS3

Text Centring

In order to centre text, we use the text-align CSS property with the value 'centre'.

Element Centring

In order to centre elements within elements (i.e nested elements), we need to apply two properties to the contained element:

The block display forces a line-break both before and after the element is rendered.

The margin setting of auto causes an equal distribution of space to both the left and right side of the horizontal margin.