Conversion Table
Root Em | Viewport Height |
---|---|
0.01rem | 0.0148vh |
0.03rem | 0.0444vh |
0.05rem | 0.0741vh |
0.08rem | 0.1185vh |
0.1rem | 0.1481vh |
0.15rem | 0.2222vh |
0.2rem | 0.2963vh |
0.5rem | 0.7407vh |
0.625rem | 0.9259vh |
0.75rem | 1.1111vh |
0.875rem | 1.2963vh |
1rem | 1.4815vh |
1.125rem | 1.6667vh |
1.25rem | 1.8519vh |
1.375rem | 2.0370vh |
1.5rem | 2.2222vh |
1.625rem | 2.4074vh |
1.75rem | 2.5926vh |
1.875rem | 2.7778vh |
2rem | 2.9630vh |
2.125rem | 3.1481vh |
2.25rem | 3.3333vh |
2.375rem | 3.5185vh |
2.5rem | 3.7037vh |
2.625rem | 3.8889vh |
2.75rem | 4.0741vh |
2.875rem | 4.2593vh |
3rem | 4.4444vh |
3.125rem | 4.6296vh |
3.25rem | 4.8148vh |
3.375rem | 5.0000vh |
3.5rem | 5.1852vh |
3.625rem | 5.3704vh |
3.75rem | 5.5556vh |
3.875rem | 5.7407vh |
4rem | 5.9259vh |
5rem | 7.4074vh |
6rem | 8.8889vh |
8rem | 11.8519vh |
10rem | 14.8148vh |
15rem | 22.2222vh |
20rem | 29.6296vh |
30rem | 44.4444vh |
40rem | 59.2593vh |
50rem | 74.0741vh |
60rem | 88.8889vh |
80rem | 118.5185vh |
100rem | 148.1481vh |
Differences Between rem and vh
Root Em (rem) is a relative unit that scales according to the root element's font size, typically the HTML element. Viewport Height (vh) is a relative unit that scales based on the height of the viewport. One vh unit is equal to 1% of the viewport's height, making it useful for responsive design.
Advantages of Using rem
Using rem units allows for better scalability and consistency across different screen sizes and resolutions. Since rem is relative to the root element's font size, adjusting the font size of the root element will proportionally scale all elements using rem units. This is particularly useful for responsive design and accessibility, as it respects user preferences for font size.
How to Convert rem to vh
To convert rem to vh, you need to know the root element's font size and the viewport height. The formula for conversion is:
vh = (rem * root font size) / (viewport height / 100)
For example, to convert 2rem to vh, assuming the root font size is 16px and the viewport height is 1000px:
2rem * 16px / (1000px / 100) = 3.2vh
Frequently Asked Questions
Why should I use rem instead of vh?
Using rem allows for more scalable and consistent layouts across different screen sizes and user settings, improving accessibility.
How do I set the root font size?
You can set the root font size using CSS on the HTML element. For example:
html {
font-size: 16px;
}
Can I use rem for all elements?
Yes, you can use rem for most elements to ensure consistency. However, for full-height elements that need to scale with the viewport height, vh might be more suitable.