How to Center a text inside anchor tag in HTML
In this tutorial, we are going to learn about how to center a text inside a anchor <a>
tag in HTML with the help of examples.
Consider, we have the following anchor element in our HTML:
<a href="https://google.com" class="link">Google</h1>
To center a text inside a anchor tag, add the text-align:center
to the anchor
CSS class.
“text-align: center” centers the text horizontally.
Here is an example:
<a href="https://google.com" class="link">Google</a>
CSS:
.link{
text-align: center;
}
or we can add the inline styles to anchor element using the style
attribute in HTML.
<a href="https://google.com" style="text-align: center;">
Google
</a>