The method of setting text Center alignment by html
The knowledge of this article "html sets text center alignment method" is not understood by most people, so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "html setting text center alignment method" article.
Html sets the text center alignment by adding the text-align attribute to the paragraph text and setting the property value to center, for example, [H2 {text-align:center}]. The text-align attribute specifies the horizontal alignment of the element text.
This article operating environment: windows10 system, html 5, thinkpad T480 computer.
To center the text, you can simply use the text-align property. Maybe some of you who have just come into contact with programming don't know much about the text-algin attribute and don't understand its usefulness. I'll give you a brief introduction to the attribute below.
The text-align attribute specifies the horizontal alignment of the element text.
Common attribute values are as follows:
Left arranges the text to the left. Default value: determined by the browser.
Right arranges the text to the right.
Center arranges the text in the middle.
Justify achieves the effect of aligning text at both ends.
Inherit states that the value of the text-align attribute should be inherited from the parent element.
Code demonstration:
(php.cn) H2 {text-align:center} h3 {text-align:left} h4 {text-align:right} This is heading 1This is heading 2This is heading 3
The running result is shown as follows:
The above is about the content of this article on "html setting text center alignment method". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more related knowledge, please pay attention to the industry information channel.