How to vertically align text to the middle inside div?

Sometimes its a headache aligning the text elements inside div to the middle. The easiest solution is to add line-height value equal to the height of the div element.

Suppose we have

unaligned text with button

This does not look good because it is not vertically aligned to the middle. So the solution is to add line and line-height to the box div.

The final corrected output likes this:
aligned text with button

About the Author

has written 38 stories on this site.

Write a Comment

Gravatars are small images that can show your personality. You can get your gravatar for free today!


Copyright © 2022 Programmer to Programmer- A website for web programming and mobile application programming tutorials.
Wordpress themes