How to change height of heading using CSS?

Answer

To change height of heading using CSS, you can set the height style property for the heading 2 elements with the values like 200px, 60%, 5in, etc.

CSS Code

The following is the typical CSS code to change height of heading in HTML page using tag name h2.

Using height in pixels

h2 {
   height: 200px;
}

Using height in percentage of parent width

h2 {
   height: 60%;
}

Using height in inches

h2 {
   height: 5in;
}

Examples

We shall go through some working examples on how to change height of heading using CSS. In the following examples, you may change the value of height and Run the code to visually observe the changes made to the Heading 2 elements.

Example 1

This is an example on how to change height of heading using height in pixels .

You may edit the following code, and click on Run button.

Example 2

This is an example on how to change height of heading using height in percentage of parent width.

You may edit the following code, and click on Run button.

Example 3

This is an example on how to change height of heading using height in inches.

You may edit the following code, and click on Run button.