Vertically align text next to an image?
Vertically align text next to an image?
358
25-Apr-2023
Updated on 26-Apr-2023
Aryan Kumar
26-Apr-2023To vertically align text next to an image, you can use CSS flexbox layout. Here's an example:
HTML:
CSS:
In this example, the container is set to use flexbox layout with the display: flex; property. The align-items: center; property is then used to vertically center the items in the container.
The img element is given a margin-right property to add some space between the image and the text.
You can adjust the values of align-items and margin-right to get the desired alignment and spacing between the image and the text.