CSS Lengths
Description
Many CSS properties require you to specify a length, for examples the width property, the font-size property.
Example
The following code sets Units of Measurement in Properties
<!DOCTYPE HTML>
<html>
<head>
<style type="text/css">
p {<!-- ww w. j av a 2 s .co m-->
background: grey;
color:white;
width: 5cm;
font-size: 20pt;
}
</style>
</head>
<body>
<p>this is a test.</p>
</body>
</html>
To specify a length, you concatenate the number and the unit identifier together.
In the code above, width property is 5cm
. The font size is 20pt
.
CSS defines two kinds of length unit
- absolute
- relative