Conversion Table
Root Em | Em |
---|---|
0.01rem | 0.01em |
0.03rem | 0.03em |
0.05rem | 0.05em |
0.08rem | 0.08em |
0.1rem | 0.1em |
0.15rem | 0.15em |
0.2rem | 0.2em |
0.5rem | 0.5em |
0.625rem | 0.625em |
0.75rem | 0.75em |
0.875rem | 0.875em |
1rem | 1em |
1.125rem | 1.125em |
1.25rem | 1.25em |
1.375rem | 1.375em |
1.5rem | 1.5em |
1.625rem | 1.625em |
1.75rem | 1.75em |
1.875rem | 1.875em |
2rem | 2em |
2.125rem | 2.125em |
2.25rem | 2.25em |
2.375rem | 2.375em |
2.5rem | 2.5em |
2.625rem | 2.625em |
2.75rem | 2.75em |
2.875rem | 2.875em |
3rem | 3em |
3.125rem | 3.125em |
3.25rem | 3.25em |
3.375rem | 3.375em |
3.5rem | 3.5em |
3.625rem | 3.625em |
3.75rem | 3.75em |
3.875rem | 3.875em |
4rem | 4em |
5rem | 5em |
6rem | 6em |
8rem | 8em |
10rem | 10em |
15rem | 15em |
20rem | 20em |
30rem | 30em |
40rem | 40em |
50rem | 50em |
60rem | 60em |
80rem | 80em |
100rem | 100em |
Differences Between rem and em
Root Em (rem) is a relative unit that scales according to the root element's font size, typically the HTML element. Em (em) is a relative unit that scales according to the font size of the parent element. This makes rem useful for overall consistency, while em is useful for scalability within components.
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 em
To convert rem to em, you need to know the root element's font size and the parent element's font size. The formula for conversion is:
em = rem * (root font size / parent font size)
For example, to convert 2rem to em, assuming the root font size is 16px and the parent font size is 16px:
2rem * (16px / 16px) = 2em
Frequently Asked Questions
Why should I use rem instead of em?
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 fine-tuning certain elements within components, you might still use em.