Home  >  Article  >  Web Front-end  >  How to set the first line indentation to 2 characters in css

How to set the first line indentation to 2 characters in css

藏色散人
藏色散人Original
2021-04-23 09:16:1525411browse

How to set the indentation of the first line to 2 characters in css: 1. Set the indentation of the first line to 2 characters through "h2{text-indent:24px;}"; 2. Through "h2{padding-left:" 24px;}" method to set the first line indentation to 2 characters.

How to set the first line indentation to 2 characters in css

The operating environment of this article: Windows7 system, HTML5&&CSS3 version, Dell G3 computer.

An example of the indentation of the first line is as follows (according to the size of the font on your page, for example, if the font on the page is 12px, indenting 2 characters is 24px):

Method 1: h2{text -indent:24px;}

Method 2: h2{padding-left:24px;}

It is recommended to use the standard first line indentation attribute text-indent,

text-indent attribute:

The text-indent attribute specifies the indentation of the first line of text in the text block.

Note: Negative values ​​are allowed. If a negative value is used, the first line will be indented to the left.

Attribute value:

length defines fixed indentation. Default value: 0.

% Defines the indent based on a percentage of the parent element's width.

inherit specifies that the value of the text-indent attribute should be inherited from the parent element.

【Recommended learning: css video tutorial

The above is the detailed content of How to set the first line indentation to 2 characters in css. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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