在本教程中,我们将通过实例学习如何将HTML中的锚点<a> 标签内的文本居中。
考虑一下,我们的HTML中有以下锚点元素。
<a href="https://google.com" class="link">Google</h1>
要使锚定标签内的文本居中,可将text-align:center 添加到anchor 的CSS类中。
"text-align: center "将文本水平居中。
下面是一个例子。
<a href="https://google.com" class="link">Google</a>
CSS。
.link{
text-align: center;
}
或者我们可以使用HTML中的style 属性为锚元素添加内联样式。
<a href="https://google.com" style="text-align: center;">
Google
</a>