Get the App
SLTechnology News&Howtos  ›  Development  › 

How to realize the text-centered Code in html

Shulou Source: shulou.com Published: 2022-06-01 10:33:39 10月03日 Update

This article will explain in detail how to realize the text center code in html. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

Text horizontal center

one

two

three

four

five

six

seven

eight

nine

ten

eleven

twelve

thirteen

fourteen

fifteen

sixteen

seventeen

eighteen

nineteen

Horizontal center

.box {

Width: 300px

Height: 200px

Background: palegoldenrod

Text-align:center

}

Centered horizontally-- text

Effect picture:

Description: text-align

Text-align is a basic attribute that affects how lines of text in an element are aligned to each other. The values left, right, and center cause the text in the element to be left-aligned, right-aligned, and centered, respectively. To center the text, use center directly.

This property centers some inline objects (or similar elements), such as text and img tags.

Text is vertically centered

one

two

three

four

five

six

seven

eight

nine

ten

eleven

twelve

thirteen

fourteen

fifteen

sixteen

seventeen

eighteen

Vertical center

.box {

Width: 300px

Height: 300px

Background: paleturquoise

Line-height:300px

}

Centered vertically-- text

Effect picture:

The line-height property sets the distance between rows (row height). Negative values are not allowed.

This property affects the layout of the row box. When applied to a block-level element, it defines the minimum distance rather than the maximum distance between baselines in that element.

This is the end of this article on "how to realize the text center code in html". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it out for more people to see.

Tags: Elements text attributes text horizontal articles code effects renderings more influence good practical maximum minimum between content objects layout articles Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Microsoft macOS Linux Docker