Deep understanding of the line height properties of css (illustrated)

Source: Internet
Author: User

What is line spacing.

In ancient times we used printing presses to come out text. Every word that is printed is in a separate block.

Line spacing, that is, the legendary control of two lines of text vertical distance. In CSS, Line-height is used to control the vertical distance between rows and rows.

However, the line spacing and half line spacing depends on the line-height in the CSS. So, how to use Line-height?

Default state, the browser uses 1.0-1.2 line-height, which is an initial value. You can define the Line-height property to override the initial value: p{line-height:140%}

There are 5 ways you can define line-height.

1.line-height can be defined as: body{line-height:normal;}

2.line-height can be defined as: Body{line-height:inherit;}

3.line-height can use a percentage of the value body{line-height:120%;}

4.line-height can be defined as a length value (px,em, etc.) body{line-height:25px;}

5.line-height can also be defined as pure numbers, body{line-height:1.2}

Abbreviation Line-height

The 5 types of line-height can be abbreviated in the font attribute. The value of the line-height follows the Font-size value and is separated by a slash, such as:<font-size>/<line-height>

Example: Body{font:100%/normal Arial;, body{font:100%/120% Arial;, body{font:100%/1.2 Arial; , body{font:100%/25px Arial;

Calculate Line-height

Some CSS attributes are inheritable (inherited) and are passed down from a cascade of elements. This is done to facilitate developers and no longer reset values for descendant elements.

It's a bit complicated for line-height inheritance.

1, percentage

2. Length

3 Value: Normal

4 Pure digits

(But the actual application in the Chinese font or in the English font mix, as well as Ie678,xp Win7, row high rules and different, tearful)

Related Article

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.