Categories: DesignDevelopment

Absolute vs Relative sizes in design

When doing flexible layouts, there is no way around using relative sizes, so that fonts and elements resize accordingly.

CURRENT RELATIVE UNITS

  • EM
    Relative to the font-size of the element. The information comes from the browser preset.
  • REM (not supported in older browsers, like IE 8)
    Relative to font-size of the root element
  • PERCENT
    Relative to the container

CALCULATION

If not set differently, 1 em equals 16 Pixel in most browsers, which gives us a calculation basis.

Preset value = 16PX = 100% or 1EM or 1 REM

So 1/16 = 0,0625 is our calculation factor.

  1. PX            EM
  2.   1          = 0,0625
  3.  12 * 0,0625 = 0,75  
  4.  48 * 0,0625 = 3
  5. 250 * 0,0625 = 15,625

EM VS REM

The difference between EM and REM is the inheritance.

The REM value is calculated in reference to the root element, the font size of the HTML, not the BODY,  element.

The EM value is calculated in reference to its parent element.

SUPPORT

Due to limited support in older browsers, you can use graceful degradation in your stylesheet to use both.

  1. li a {
  2. font-size:20px;
  3. font-size:1.25rem;
  4. }

The Pixel value must be added before the REM value !

Enjoy coding …

Alex

I am a full-stack developer. I love programming,  design and know my way around server architecture as well.  I would never feel complete, with one of these missing. I have a broad range of interests, that’s why I constantly dive into new technologies and expand my knowledge where ever required. Technologies are evolving fast and I enjoy using the latest. Apart from that, I am a peace loving guy who tries to have people around him that think the same.  I truly believe in the principle: “If you help someone, someone will help you, when you need it."

Recent Posts

Particle Network Animations in Javascript

What are particle animations? Particle network animations in JavaScript typically involve creating visual representations of… Read More

2 days ago

B&B / Hotel Booking Solutions for WordPress | 2024

BOOKING SOLUTIONS 202x This is my take on a subset of booking, appointment, PMS or… Read More

1 month ago

WordPress Cron + WP-CLI + Ntfy

THE GOAL Create a system cron for WordPress, that is accessible and can be easily… Read More

2 months ago

2024 is here and now :)

2024, what's cooking? Slowly getting into the 2024 spirit. 3 projects coming to a close… Read More

4 months ago

2023 ends and whats next !

Short look back at 2023 This has been a busy and interesting year. I am… Read More

4 months ago

cubicFUSION Grid Tweaker – Elementor Grid made easy.

Elementor Pro provides grid containers as an experimental feature. The options provided are limited, when… Read More

5 months ago