Member-only story
CSS — Part -5
4 min readJun 11, 2022
CSS Units
In CSS, there are many properties that take “length” values. Example:- width
, margin
, padding
, font-size
, etc. This length value is followed by some unit like px
, rem
, em
etc.
p {
font-size: 25px;
line-height: 50px;
}
A whitespace cannot appear between the number and the unit.
There are two types of length units: absolute and relative.
Absolute Length
- The absolute length units are fixed and a length expressed in any of these will appear as exactly that size.
- these are not recommmended for screen as the screen sizes may vary.
- The units are — px, cm, mm, in, pt, pc
Relative Lengths
- Relative length units specify a length relative to another length property.
- They are preferred for th eresponsive nature of screens .
CSS specificity
Specificity — If there are two or more CSS rules that point to the same element, the selector with the highest specificity value will “win”, and its style declaration will be…