CSS vertical-align
The vertical-align
property in CSS is used to vertically align elements. It can be applied to inline or inline-block elements within a container.
Here is an example of how the vertical-align
property works:
In this example, the text "This is vertically centered" is vertically centered within the container by using the vertical-align: middle;
property.
The vertical-align
property can also take other values such as top
, bottom
, baseline
, etc. Let's see another example:
In this example, the text "Text aligned to the top" is aligned to the top of the container using the vertical-align: top;
property.