CSS Property: line-height
[this page | pdf | back links]
The CSS (CSS1) line-height property identifies the height
of lines of text.
Valid property values
(other than inherit
and initial) are:
Value
|
Description
|
length
|
Line height is a fixed
height defined by this CSS
length
|
number
|
Line height set as a
multiple of the current font size
|
%
|
Line height set as a
percentage of the current font size
|
normal
|
(default value). Line
height is normal (given the relevant font size)
|
Default Value:
|
normal
|
JavaScript syntax:
|
e.g. object.style.lineHeight="15px"
|
Inherited:
|
Yes
|
Animatable:
|
Yes
|
EXAMPLE:
HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head>
<style>
div {width: 50px; border: 1px dotted black;}
.x1 {line-height: 25px;}
</style>
</head>
<body>
Element with default property<br>
<div>abcd efgh</div><br>
Property set using in-file HTML style<br>
<div class="x1">abcd efgh</div><br>
Property set using JavaScript<br>
<div id="x2">abcd efgh</div>
<script>
document.getElementById("x2").style.lineHeight = "25px";
</script>
</body>
</html>
|
FUNCTION THAT MAY ASSIST IN TESTING WHETHER FEATURE IS SUPPORTED:
function isSupportedCSSPropertyLineHeight() {
var x = document.createElement("DIV"); x.style.lineHeight = "25px"; return (window.getComputedStyle(x, null).lineHeight == "25px");
} |
NAVIGATION LINKS
Contents | Prev | Next | CSS Properties