A common task for CSS is to center text or images.

In this example, we are using the display: flex; property, justify-content: center; property, and align-items: center; property. Covering popular subjects like HTML, CSS, JavaScript, Python, Example 2: We have one image that has some space around it, so by default the non-block element will come next to the img tag and not on the next line. Toggle navigation Centering a block of text or an image. As a best practice, we highly recommend using the