How to center a tag in css

王林
Release: 2020-11-20 09:30:51
Original
8035 people have browsed it

How to center the a tag in css: This can be achieved by setting the [text-align:center] attribute to the parent element of the a tag. The text-align attribute specifies the horizontal alignment of the element's text.

How to center a tag in css

Attribute introduction:

The text-align attribute specifies the horizontal alignment of the element's text.

(Learning video sharing: css video tutorial)

Attribute value:

  • left Arrange the text to the left. Default: determined by the browser.

  • #right Arrange the text to the right.

  • #center Arrange the text to the center.

  • #justify Achieve the effect of aligning text on both ends.

  • #inherit Specifies that the value of the text-align attribute should be inherited from the parent element.

Example:

Add the text-align: center attribute to the parent element of the a tag.

.app{
    height: 100px;
    border: 1px solid #000;
    text-align: center;
}
Copy after login

Related recommendations: CSS tutorial

The above is the detailed content of How to center a tag in css. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template