Table of Contents
Loading...
PX to REM Converter
PX to REM Conversion Tables
Pixels (PX) to REM
Pixels | REM |
---|---|
1px | 0.0625rem |
2px | 0.125rem |
3px | 0.1875rem |
4px | 0.25rem |
5px | 0.3125rem |
6px | 0.375rem |
8px | 0.5rem |
10px | 0.625rem |
12px | 0.75rem |
14px | 0.875rem |
15px | 0.9375rem |
16px | 1rem |
18px | 1.125rem |
20px | 1.25rem |
24px | 1.5rem |
25px | 1.5625rem |
28px | 1.75rem |
32px | 2rem |
36px | 2.25rem |
40px | 2.5rem |
44px | 2.75rem |
48px | 3rem |
50px | 3.125rem |
56px | 3.5rem |
64px | 4rem |
72px | 4.5rem |
75px | 4.6875rem |
80px | 5rem |
90px | 5.625rem |
100px | 6.25rem |
REM to Pixels (PX)
Assumes standard default browser font-size of 16px
REM | Pixels |
---|---|
0.01rem | 0.16px |
0.03rem | 0.48px |
0.05rem | 0.8px |
0.08rem | 1.28px |
0.1rem | 1.6px |
0.15rem | 2.4px |
0.2rem | 3.2px |
0.5rem | 8px |
1rem | 16px |
2rem | 32px |
3rem | 48px |
4rem | 64px |
5rem | 80px |
6rem | 96px |
8rem | 128px |
10rem | 160px |
15rem | 240px |
20rem | 320px |
30rem | 480px |
40rem | 640px |
50rem | 800px |
60rem | 960px |
80rem | 1280px |
100rem | 1600px |
PX to REM Conversion in CSS
PX (pixels) and REM (root em) are two units used to define element sizes in Cascading Style Sheets (CSS). Understanding how to convert between them is crucial for creating responsive and adaptable web pages.
Here’s a breakdown of PX to REM conversion:
1. Units:
- PX (Pixels) is an absolute unit representing a fixed number of pixels on the screen. It is independent of the user’s font size settings.
- REM (Root Em): A relative unit based on the font size of the root HTML element. By default, the root font size is 16px in most browsers. So, 1rem is equivalent to 16px.
2. Why Use REM?
- Responsiveness: REM allows elements to scale proportionally with the user’s font size preference. This is essential for responsive web design, ensuring your website adapts to different screen sizes and user preferences.
- Maintainability: Using REM in your stylesheets makes it easier to maintain consistent font sizes across your website. Changing the root font size automatically adjusts all REM-based elements.
3. Conversion Formula:
To convert PX to REM, divide the pixel value by the root font size (usually 16px):
rem_value = px_value / root_font_size
For example, to convert 24px to rem assuming a 16px root font size:
rem_value = 24px / 16px = 1.5rem
4. Important Points:
- The conversion is dependent on the root font size. If you change the root font size in your CSS, the REM values will have a different effect.
- Browsers typically use a default root font size of 16px. However, it’s good practice to explicitly define the root font size in your CSS for better control.
- While REM offers advantages for responsiveness, there can be situations where PX might be preferred, such as for fixed-size elements like icons or borders.
5. Additional Considerations:
- Browser Compatibility: While REM is widely supported, it’s always a good idea to check compatibility for older browsers.
- Nested Elements: When using REM within nested elements, the font size inheritance applies. The REM value is relative to the closest parent element’s font size, not the root font size.
Share
Looking for fresh content?
Get articles and insights from our weekly newsletter.
By entering your email, you agree to receive Elementor emails, including marketing emails,
and agree to our Terms & Conditions and Privacy Policy.