Sunday, 20 September 2015

CSS Line Height

CSS Line Height

The CSS line height property is used to define the minimal height of line boxes within the element. It sets the differences between two lines of your content.
It defines the amount of space above and below inline elements. It allows you to set the height of a line of independently from the font size.

CSS line-height values

There are some property values which are used with CSS line-height property.
valuedescription
normalThis is a default value. it specifies a normal line height.
numberIt specifies a number that is multiplied with the current font size to set the line height.
lengthIt is used to set the line height in px, pt,cm,etc.
%It specifies the line height in percent of the current font.
initialIt sets this property to its default value.
inheritIt inherits this property from its parent element.

CSS line-height example

<!DOCTYPE html>  
<html>  
<head>  
<style>  
h3.small {  
    line-height: 70%;  
}  
h3.big {  
    line-height: 200%;  
}  
</style>  
</head>  
<body>  
<h3>  
This is a heading with a standard line-height.<br>  
This is a heading with a standard line-height.<br>  
The default line height in most browsers is about 110% to 120%.<br>  
</h3>  
<h3 class="small">  
This is a heading with a smaller line-height.<br>  
This is a heading with a smaller line-height.<br>  
This is a heading with a smaller line-height.<br>  
This is a heading with a smaller line-height.<br>  
</h3>  
<h3 class="big">  
This is a heading with a bigger line-height.<br>  
This is a heading with a bigger line-height.<br>  
This is a heading with a bigger line-height.<br>  
This is a heading with a bigger line-height.<br>  

</h3>  
</body>  
</html> 
Output


No comments:

Post a Comment