Vertically align text in <a> element with CSS
Vertically align text in "a" tag element with CSS
368
25-Apr-2023
Updated on 26-Apr-2023
Aryan Kumar
26-Apr-2023You can vertically align text in an "a" tag element using CSS by setting the "line-height" property to be equal to the height of the element. Here's an example:
HTML:
CSS:
In the example above, we set the "display" property of the "a" tag element to "inline-block" so that we can set its height. We then set the "height" property to be the desired height of the element and the "line-height" property to be equal to the height. Finally, we set the "vertical-align" property to "middle" to align the text vertically in the middle of the element.