The difference between line-height1.5 and line-height:150%

Source: Internet
Author: User

First, the difference

The difference is reflected in the child element inheritance, as follows:

    • The parent element setting line-height:1.5 is directly inherited to the child element, and the child element calculates its own line-height according to its own font-size.
    • The parent element setting line-height:150% is the calculation of the Line-height value, and then the calculated value to the child element inheritance, child element inheritance to get is the final value. When the child element is set font-size it has no effect on its line-height.
Ii. Examples

such as the parent element setting property: Font-size:14px;line-height:1.5,child set font-size:26px;

Then the parent element: Line-height = 14px * 1.5 = 21px, child element: Line-height = 26px * 1.5 = 39px.

Parent Element Setting Property: Font-size:14px;line-height:150%,child set font-size:26px;

Then the parent element: Line-height = 14px * 150% = 21px, child element: Line-height = Line-height = 21px of the parent element.

<!DOCTYPE HTML><HTML>    <MetaCharSet= "Utf-8"/><Head>    <title></title>    <styletype= "Text/css">. Father{width:400px;Border:1px solid Pink;Display:Inline-block;}. Son{width:350px;Border:1px solid Green;}. Father1{font-size:14px;Line-height:1.5;}. Son1{font-size:26px;}. Father2{font-size:14px;Line-height:150%;}. Son2{font-size:26px;}</style></Head><Body>    <Divclass= "Father Father1">parent element font-size:14px;line-height:1.5; calculated value is 21px<Divclass= "Son son1">The child element Font-size:26px;line-height inherits 1.5 of the parent element, and the computed value is 39px</Div>    </Div>    <Divclass= "Father Father2">parent element font-size:14px;line-height:150%; calculated value is 21px<Divclass= "Son son2">child elements font-size:26px;line-height= the line-height=21px of the parent element</Div>    </Div></Body></HTML>

The author starof, because the knowledge itself in the change, the author is also constantly learning and growth, the content of the article is not updated regularly, in order to avoid misleading readers, convenient tracing, please reprint annotated source: http://www.cnblogs.com/starof/p/4742323. HTML has a problem welcome to discuss with me, common progress.

The difference between line-height1.5 and line-height:150%

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.