What is the style of html text centering?

Patricia Arquette
Release: 2023-01-03 09:24:21
Original
18511 people have browsed it

html Text centering style: 1. Horizontal centering style is “text-align: center;”; 2. Text vertical centering style is “line-height:px value;”; 3. Text vertical centering style is “ display: flex;align-items: center;".

What is the style of html text centering?

The operating environment of this tutorial: Windows 7 system, HTML5 version, Dell G3 computer.

html text center

1. Text horizontally centered--text-align: center;

The text-align attribute specifies the horizontal alignment of text within an element.

This attribute sets the horizontal alignment of text within block-level elements by specifying the point at which the line box is aligned. The value justify is supported by allowing user agents to adjust the spacing between letters and words in line content; different user agents may get different results.

Value Description
left Allow text to the left. Default: determined by the browser.
right Arrange 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.

Example:

     

这是标题 1

这是标题 2

这是标题 3

Copy after login

Rendering:

What is the style of html text centering?

[Recommended Tutorials:CSS Video Tutorial, "html Video Tutorial"】

2, text vertically centered

1), line-height makes a single line of text vertically centered

    css 垂直居中  
css 垂直居中了--文本文字
Copy after login

Effect picture:

What is the style of html text centering?

2), CSS3 flex layout makes the text vertically centered

    css 垂直居中  
css 垂直居中--文本文字(弹性布局)
Copy after login

What is the style of html text centering?

For more programming-related knowledge, please visit:Programming Video! !

The above is the detailed content of What is the style of html text centering?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!