×

CSS Line Height

CSS Line Height: This property in CSS can be used to describe the line box’s minimal height inside the element. It sets-up the distinction among two lines in our content.

It depicts the amount of space below and above the inline elements. It also allows us to set-up the line height, which is independent of various font sizes.

Values of Line-height

Following are a few values properties which can be applied in Line Height attribute:

normal: Normal value is used as a default value. It portrays the line-height normally.

number: It depicts a number which will be multiplied with a font size, which is currently in use, to set-up line-height.

length: Length value is applied to set-up line-height with pt, cm, px, etc.

%: It can be specified by the use of the current font’s percent for setting line-height.

initial: It is used to sets-up this attribute to the default value.

inherit: It acquires this attribute from the parent element.

Example:

<!DOCTYPE html>
<html>
<head>
<style>
h4.small {
line-height: 150%;
}
h4.big {
line-height: 200%;
}
</style>
</head>
<body>
<h4>This is a heading with a specific line-height.<br>
This is a heading with a specific line-height.<br>
The default value of line height property is 110% to 120% in most of the browsers.
</h4>
<h4 class="small">
This is a heading written with a small line-height.<br>
This is a heading written with a small line-height.<br>
This is a heading written with a small line-height.<br>
This is a heading written with a small line-height.<br></h4>
<h4 class="big">
This is a heading written with a big line-height.<br>
This is a heading written with a big line-height.<br>
This is a heading written with a big line-height.<br>
This is a heading written with a big line-height.<br></h4>
</body>
</html>

Output:

CSS Line Height

Example:

In the following example, line height is set-up with a number along with different <div> tags:

<!DOCTYPE html>
<html>
<head>
<style>
div.x {
line-height: 0.5;
}
div.y {
line-height: 1.5;
}
div.z {
line-height: 2.5;
}
</style>
</head>
<body>
<h1>Line Height</h1>
<p>Here, we are setting the line height with a number.
This number will be multiplied with the current font-size.</p>
<h2>Line-Height: 0.5</h2>
<div class="x">This is a paragraph with the recommended line-height.<br>
It is set to 0.5.</div>
<h2>Line-Height: 1.5</h2>
<div class="y">This is a paragraph with the recommended line-height.<br>
It is set to 1.5.</div>
<h2>Line-Height: 2.5</h2>
<div class="z">This is a paragraph with the recommended line-height.<br>
It is set to 2.5.</div>
</body>
</html>

Output:

CSS Line Height

Related Topics

CSS Form

You can create attractive HTML form by using CSS. Style input Fields The Input Field width properties are used to determine the width of the input field. Let us see an example of CSS style...

2 minutes read.

Radial-gradient() CSS function

Radial-gradient() CSS function It defines a CSS in-built function, which produces a smooth transition among multiple colors. It is used to set any radial-gradient that is same as a background-image. This...

4 minutes read.

Css Text Orientation

Introduction: The text-orientation property of CSS is used to specify the orientation of the text characters in the line of content. This property applies only with the vertical writing-mode and not...

4 minutes read.

Is CSS a programming language?

 A programming language is a set of grammatical rules and a vocabulary for commanding a machine to accomplish specified tasks. High-level languages like BASIC, C, C++, COBOL, Java, FORTRAN, Ada...

4 minutes read.

How to change background color in CSS

How to change background color in CSS? The background-color property in CSS would be used to specify the color of an element's background. As the element's background, it uses solid colors. The...

3 minutes read.

CSS Comments

CSS Comments: Generally, comments in CSS are used to describe our code. Further, it will provide support to many users who are concerned with the code. Somewhat, these are ignored...

2 minutes read.

CSS Filter

CSS Filter CSS filter is used to apply visual effects on the images, text, and other factors of the webpage. This filter property in CSS allows us to admit the effects like...

7 minutes read.

CSS Counters

CSS Counters: The CSS counter property is similar to the variables. CSS counters are controlled via CSS, and its values are incremented via rules of CSS to record how much...

4 minutes read.

CSS Gradient

CSS Gradient: The CSS gradient property is applied to show the smooth transition inside two specified colors or more than two specified colors. Need of CSS Gradient The following are a few...

4 minutes read.

What is a CSS File?

What is a CSS File and How to use it in Html? CSS: - CSS stands for Cascading Style Sheet. CSS is a file of style sheets that describe the presentation of...

4 minutes read.

CSS Math Functions

The CSS math functions permit numerical articulations. These CSS math functions can particularly be utilized in maybe unforeseen ways, for example, inside angles and shading the functions and in the...

3 minutes read.

CSS Visibility

Visibility in CSS: This visibility property in CSS is employed to describe whether the components are visible or not. Note: An invisible component also grabs the space over the page. If...

2 minutes read.

CSS Pseudo-elements

Pseudo-elements The pseudo-classes in CSS can be represented as any keyword which is connected to the selector that represents any selected element’s unique state. On the other hand, pseudo-elements can be...

6 minutes read.

CSS Letter-spacing

CSS Letter-spacing: Letter-spacing attribute is applied to manage the space among all letters within the block or element of the text. This property sets the behavior of the spacing between...

2 minutes read.

CSS Descendant Selector

Descendant Selector The Descendant selector in CSS is used to match the descendant components of a particular component. The term descendant depicts nested in whatever place, inside a DOM tree. This...

2 minutes read.

CSS Display

CSS Display: The CSS Display property is one of an essential property among all other properties of CSS. The display property specifies how the HTML elements should be displayed on...

4 minutes read.

CSS Overflow

CSS Overflow: The Overflow property in CSS is used to manage the content if it overflows from its container of the block level. We have seen that all the elements...

3 minutes read.

CSS Text-align

Text-align The text-align property of CSS sets the table-cell box’s horizontal alignment or any block element. The text-align property is the same as the CSS property vertical-align but towards any horizontal...

1 minute read.

CSS Outline

CSS Outline: This CSS property is quite similar to the border property of CSS. It eases us to design an additional border around the element to obtain visual attention. The...

4 minutes read.

How to include CSS

How to include CSS CSS is included in HTML pages for formatting the documents based on the information inside a style sheet. We can add CSS in HTML documents in the following three ways: Inline...

5 minutes read.