How to write the code to center text in html? The following article will introduce it to you. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.
The text is horizontally centered
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
|
Rendering:
Instructions : text-align
text-align is a basic attribute that affects how lines of text in an element are aligned with each other. The values left, right, and center will cause the text in the element to be left-aligned, right-aligned, and centered respectively. If you want to center the text, just use center.
This attribute sets the centering of some inline objects (or similar elements) such as text and img tags.
The text is vertically centered
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
|
Rendering:
The line-height property sets the distance between lines ( row height). Negative values are not allowed.
This property affects the layout of the line box. When applied to a block-level element, it defines the minimum distance between baselines in that element rather than the maximum distance.
Recommended tutorial: html tutorial
The above is the detailed content of How to write text centering code in html?. For more information, please follow other related articles on the PHP Chinese website!