Div+css to indent two characters in the first line of a paragraph

Source: Internet
Author: User

Two words in front of the distance, do not use space, using CSS to achieve the first indent paragraph two characters. You should use the first line indent text-indent. text-indent can indent a unit in the first line of the container. For example, Chinese paragraphs usually have two characters in front of each paragraph.

Here we need to understand a length unit em. EM is the relative length unit. The font size relative to the text within the current object. We usually have two Chinese characters before each paragraph. In fact, the first line is indented 2em.

<style type= "Text/css" >
<!--
p{
Text-indent:2em; /*em is a relative unit, 2EM is now twice times the size of a word */
}
-
</style>
<p> the distance in front of the paragraph two words, do not use the space again. You should use the first line indent text-indent. Length Unit em. The font size relative to the text within the current object. We indented 2em in the first line. 2EM is now twice times the size of a word. </p>

--------------------------------------------------------------------------------------------------------------- --

Using CSS to achieve the first indentation of the paragraph two characters, the first line of indentation to achieve the general method is to add four small corner space.

In fact, it's more efficient to define CSS styles.

For example, define the following indentation style in style:. suojin{Text-indent:2em}

Use class= "Suojin" where you need to indent, such as defining an entire block of paragraphs with a div to indent first,

Where in the Div area, when the browser meets the P statement (that is, the beginning of a new paragraph), it executes the. Suojin defined indentation.

You can also use an inline CSS style to define it in the body, for example (change angle brackets to small angle brackets when using):


Paragraph one


Paragraph two


Paragraph three


Both methods have strengths and weaknesses that can be used to determine which method to use.

Note: The div tag does not forget the start character. Text-indent is only valid for P or div tags and does not take effect on BR tags because the br tag is a newline label and not a segmented label.

Div+css to indent two characters in the first line of a paragraph

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.