Relative Lengths
Relative Lengths
Relative length units specify a length relative to another length property. Relative length units scale better between different rendering medium.
Unit | Description | |
---|---|---|
em | Relative to the font-size of the element (2em means 2 times the size of the current font) | Try it |
ex | Relative to the x-height of the current font (rarely used) | Try it |
ch | Relative to the width of the “0” (zero) | Try it |
rem | Relative to font-size of the root element | Try it |
vw | Relative to 1% of the width of the viewport* | Try it |
vh | Relative to 1% of the height of the viewport* | Try it |
vmin | Relative to 1% of viewport’s* smaller dimension | Try it |
vmax | Relative to 1% of viewport’s* larger dimension | Try it |
% | Relative to the parent element |