htmlThe way to set the a tag to be centered is to add the style code to the a tag in the block element [], so that the a label can be vertically centered.
The operating environment of this article: winidows10 system, html 5, thinkpad t480 computer.
To set the a tag to be centered in html, it is actually relatively simple. However, centering the a tag can also be divided into the following two situations. Let us take a look below.
The first case: center align the tag in the block element
HTML code - the tag in the block element such as: " < ;a href="#">Text
You can add style code to this
tag
Achieve vertical center alignmentCode example:
<p style="text-align: center"><a href="//m.sbmmt.com">php中文网</a></p>
Second case: let Centering the separate tag
If the tag is separate, first turn the tag into a block element, then add a width, and then center its text < a href="#" style="display:inline-block; width:100px; text-align:center">TextFor example, code example
学技术从<a href="//m.sbmmt.com" style="display:inline-block; width:110px; text-align:center">php.cn</a>开始!
Related recommendations:html Video tutorial
The above is the detailed content of How to set the a tag to be centered in html. For more information, please follow other related articles on the PHP Chinese website!