How to set text center by CSS
This article mainly introduces the CSS how to set the text center of the relevant knowledge, the content is detailed and easy to understand, the operation is simple and fast, has a certain reference value, I believe that everyone after reading this CSS how to set the text center article will have a harvest, let's take a look.
Text-align attribute
The commonly used property of CSS setting text center display is text-align, whose attribute values are left, right, center, and justify, respectively. However, justity has been used less, because most browsing is not supported.
If we set the text-align:center property directly, we can clearly see that the text is centered only horizontally, not vertically.
If you want the text to be centered in the div vertical orientation, you can set the line-height property directly and set the property value to the height of the div.
The source code is as follows:
CSS setting text center display-(yisu.com) div {height: 100px; width: 300px; text-align: center; background-color: red; line-height: 100px } this text will be centered to show the content of this article on "how to set the text center in CSS". Thank you for reading! I believe you all have a certain understanding of "how to set the text center in CSS". If you want to learn more, you are welcome to follow the industry information channel.