If we want to align just texts in the center then we could easily use text-align property. But sometime we just want to align the whole text block in the center and it doesn’t work out that simply.
The trick to align the block of texts in center horizontally is to set the margin property correctly and by correctly, I mean set it as ‘auto‘.
Horizontal alignment of a text block
It works the same way for an image block too. Be careful though, it won’t work without the ‘display:block‘ property.
Horizontal alignment of an image block
This is actually CSS2 way of aligning the text block vertically. In CSS3, we can just use grid or text or even just a bit more advanced properties that are not available in CSS2.
We need to add an outer container to the paragraph tag. Set the display as a table cell and then just use vertical-align property.
Vertical alignment of a text block
We can align an image block vertically the exact same way as we did for text above.
Vertical alignment of an image block
align align-items block display horizontally images text vertically