How to set the center alignment of text in css: You can use the text-align attribute to achieve this, such as [p{text-align:center;}]. We can also set the text to the left or right, such as [text-align:left;] or [text-align:right;].
The operating environment of this article: windows10 system, css 3, thinkpad t480 computer.
There is a text attribute text-align in css, which allows us to specify the horizontal alignment of the text of the element, such as center, left, right, aligned at both ends, etc.
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.
For example, if we want to center align text, what should we do?
Specific implementation code:
(Learning video sharing:css video tutorial)
Running results:
Related recommendations:CSS tutorial
The above is the detailed content of How to set text center alignment in css. For more information, please follow other related articles on the PHP Chinese website!