### Horizontal and vertical centering Horizontally and vertically centers a child element within a parent element. #### HTML ```html
``` #### CSS ```css .horizontal-and-vertical-centering { display: flex; justify-content: center; align-items: center; } ``` #### Demo

Centered content.

#### Explanation 1. `display: flex` enables flexbox. 2. `justify-content: center` centers the child horizontally. 3. `align-items: center` centers the child vertically. #### Browser support ⚠️ Needs prefixes for full support. * https://caniuse.com/#feat=flexbox