paragraph line spacing css code example

Example 1: line spacing css

line-height: 20px; /* 4px +12px + 4px */
/* OR */
line-height: 1.7em; /* 1em = 12px in this case. 20/12 == 1.666666  */

Example 2: line-height css

/* Keyword value */
line-height: normal;

/* Unitless values: use this number multiplied
by the element's font size */
line-height: 3.5;

/* <length> values */
line-height: 3em;

/* <percentage> values */
line-height: 34%;

/* Global values */
line-height: inherit;
line-height: initial;
line-height: unset;

Example 3: css line spacing

line-height: 1.5;  /* Prefered */

line-height: 1.5em;

line-height: 150%;

line-height: 24px;

Example 4: line-height css

<div class="box green">
 <h1>Avoid unexpected results by using unitless line-height.</h1>
  length and percentage line-heights have poor inheritance behavior ...
</div>

<div class="box red">
 <h1>Avoid unexpected results by using unitless line-height.</h1>
  length and percentage line-heights have poor inheritance behavior ...
</div>

<!-- The first <h1> line-height is calculated from its own font-size   (30px × 1.1) = 33px  --> 
<!-- The second <h1> line-height results from the red div's font-size  (15px × 1.1) = 16.5px,  probably not what you want -->