REM vs. EM: How To Choose the Right CSS Unit

August 26, 2024 by
You probably don’t dream about CSS element sizing at night, but if you’re building a website or an app, this topic is definitely worth thinking about. While some CSS units play nicely with your responsive design, others might show a rebellious streak. Being able to tell the different characters can save you some major headaches […]


You probably don’t dream about CSS element sizing at night, but if you’re building a website or an app, this topic is definitely worth thinking about.

While some CSS units play nicely with your responsive design, others might show a rebellious streak. Being able to tell the different characters can save you some major headaches down the line.

Take the pairing of REM and EM. Which should you use, and why?

Stick with us for the next few paragraphs, and we shall reveal all!

REM vs. EM in a Nutshell

If you’re looking for a quick answer, here’s the TL;DR version:

  • REM: This unit is based on the root element (usually the tag.) No matter what else happens on the page, your sizing will stay consistent.
  • EM: This unit looks up for guidance. If the parent element changes, your sizing will follow suit.

If you want to remember the difference, keep in mind that the “R” in REM stands for “root.”

Comparison Of Rem Vs. Em Units In Css, Showing How They Relate To Root And Parent Elements Respectively.
Rem Vs. Em: How To Choose The Right Css Unit 21

Nerd Note: Why do both units end with “EM”? This isn’t an abbreviation. Back when all text was printed, typographers used the width of a capital M as a benchmark for text sizing. Pretty nifty, right?

So, which one should you use?

Well, that depends. 

If you want text to adjust to its surroundings, EM might be the better option. But if you want sizing to stay consistent across your whole website, you should switch to REM.

Why?

  • EM: More flexible, but can get messy if you’re not careful.
  • REM: Consistent sizing, great for responsive design.
DreamHost Glossary

Responsive Design

Responsive design enables a website to adapt to the screen size of the device it is being viewed on. The website will therefore look differently on different devices.

Read More

Still confused? Don’t worry, we’ll dive deeper in a second.

Just remember this for now: REM is usually the safer bet for most websites.

Related Article

How to Learn CSS In 2024 (Fast & Free)

Read More

Understanding REM and EM

Alright, let’s get into the weeds a little bit.

Both REM and EM are relative units. That means they maintain the same size relative to a specific yardstick.

This type of sizing plays a key role in responsive design.

Absolute sizes (e.g., px) always stay the same, meaning text can appear tiny on a desktop and huge on a phone. In contrast, relative units can adapt to different devices and layouts.

In a digital context, REM and EM are still primarily used to measure text. However, you can also use these units for:

  • Margins
  • Padding
  • Width and height
  • Line height
  • Border properties
  • Box shadow
  • Positioning
  • Media queries

In other words, REM and EM are useful whenever you want flexible sizing within your design.

Right, that largely covers the common ground between these two units.

Now, let’s take a closer look at what makes each of them unique.

Get Content Delivered Straight to Your Inbox

Subscribe now to receive all the latest updates, delivered directly to your inbox.

Getting To Know REM

REM stands for “root em.” When you use this unit, you’re defining how big something should be, relative to the font size of your root element (usually your tag.)

Most browsers default to 16px for the root element. However, it’s a good idea to define your default font size using CSS.

You can do it like this:

html { font-size: 16px; /* Your base font size */ }

Whatever size you choose becomes 1rem. This is your new baseline for the entire page.

Any figure that’s bigger or smaller will change the size of your target element, relative to your chosen default.

It’s a bit complicated to explain clearly, so here is an easy example:

html { font-size: 16px; /* Your base font size */ }
body { font-size: 1.2rem; /* 19.2px */ }
h1 { font-size: 2.4rem; /* 38.4px */ }

In this scenario, we’ve defined the font size of the tag as 16px. This is our baseline of 1rem.

We want our body text to be a little bigger than that. So, we set the font size to 1.2rem. That’s 120% of the baseline.

The main header on our page needs to be way bigger. By setting the font size to 2.4rem, we can make the headline 240% the size of our baseline.

You’ll end up with something like this:

Diagram Of Font Sizing In Rem Units. Html At 16Px, H1 At 2.4Rem (38.4Px), And Body At 1.2Rem (19.2Px) With Example Text.
Rem Vs. Em: How To Choose The Right Css Unit 22

Why Use REM?

What are the advantages of this system?

In CSS, REM units offer some pretty good benefits:

  • True consistency: Everything scales proportionally based on the root size, so your design will always look exactly how you intended on any device.
  • Responsiveness: Proportionate scaling means your website or app can adapt to a wide range of devices.
  • Easy maintenance: When all your styles are based on the same root setting, it’s easy to make sweeping changes as needed — You don’t need to visit every single element and change the font size manually. This also saves you a lot of time.
  • Great accessibility: Quite a lot of people actually change the default font size of their browsers to make text easier to read. By using REM sizing, your design can adapt to these user preferences.

Of course, it’s not all sunshine and rainbows. There are some drawbacks:

  • Third-party wildcards: If your site includes embedded content, you might find that text and other elements don’t follow your REM rules.
  • Tricky calculations: Figuring out exactly how big 1.2rem is going to be requires some math.
  • Great power, greater responsibility: When you can alter the size of text across your website so easily, you need to be careful with edits to avoid site-wide design disasters!

As a general rule, REM should be your go-to for most projects. It’s easier to handle than EM sizing, and the results are more predictable.

However, there are times when EM is useful.

Getting To Know EM

EM is a tricky customer. This unit is based on the font size of its parent element — like a chameleon adapting to its surroundings.

The confusion begins when you start nesting. Most elements inherit their default font size from their parent. But what if the parent also uses EM sizing? You could end up with a tangled mess of proportionality pretty easily.

Here’s a simple example:

Say you have a page that contains a

. Inside that box, we have a tag containing some text.

Now, take a look at the CSS for this HTML snippet:

html { font-size: 16px; /* Starting default size */ }
div { font-size: 1.2em; /* 19.2px */ }
p { font-size: 1.2em; /* 23.04px */ }

We started by defining the default font size for the whole page. So far, so good.

Next, we said that

content should be 1.2em. In other words, our text should be 120% of the parent element default.

To finish up, we also make the font size 1.2em.

Font Sizing In Em Units Diagram Showing Nested Text Elements And Their Relative Sizes Based On Parent Elements.
Rem Vs. Em: How To Choose The Right Css Unit 23

Now wait a minute! There is a significant increase in the text’s size, as measured in pixels.

Why’s that?

The element has looked at the font size of its parent

(19.2px) and taken that as the default. And because we asked for 1.2em, we get text that is 120% of the default size.

These kinds of errors are easy to make when you work with the EM unit.

EM Is Great for Specific Sizing

Aside from the drawbacks, the EM unit can be really useful for sizing specific components.

Say you want to create a button that always takes up roughly the same amount of space within its parent element.

Your HTML code might be:

To style your button, you could use EM units for font-size and padding.

The CSS would look something like this:

.button {
    font-size: 1em; /* Size relative to the parent text size */
    padding: 0.5em 1em; /* Padding scales with the font size */
}

The code above gives us a simple button with a little bit of padding around the text.

Em Sizing For Ui Components, Showing Button Padding Scales With Parent Font Size While Maintaining Consistent Proportions.
Rem Vs. Em: How To Choose The Right Css Unit 24

If the parent element’s font size scales upward, the font size and padding of the button will follow suit.

In this way, you’ll be able to maintain the same visual balance between elements within the parent, even if you change devices or zoom level.

Why Use EM?

Given all the confusion, why would you use EM at all?

Well, it does come with some benefits:

  • Contextual scaling: Elements scale based on their parent’s size, giving you more nuanced control over sizing throughout your design.
  • Component-based design: EM units are great for creating self-contained, reusable components that maintain the same proportions.
  • Precise control: You can fine-tune sizes at each document structure level, without making wholesale changes.
  • Responsiveness: Like REM, EM units allow your design to adapt to different screen sizes and user preferences.

As we’ve seen, there are also some drawbacks:

  • Compounding effects: Nested elements can lead to unexpected sizes, as EM values start to stack up.
  • Maintenance challenges: Changing a parent element font size affects all child elements, which can lead to unintended consequences — such as huge body text and tiny titles.
  • Complexity in large projects: As your project grows, keeping track of all the relative sizes can become challenging.

In summary, EM can be incredibly useful for component-based designs and when you need precise control over element relationships. It’s more flexible than pixel-based sizing, but requires more careful planning than REM.

REM or EM: Which Should You Use?

Well, that was a lot of interesting information. However, if you’re building something, you just need to know which CSS unit to use.

Here’s our verdict:

  • REM is the better choice for most projects because it’s more scalable, and provides better control.
  • EM can be a valuable tool for specific scenarios involving nested styles.

It’s also worth noting that both REM and EM are generally better for modern design than absolute units like px.

They’re also more practical for sizing text in comparison to other relative units, such as viewport units (vh/vw) and percentage (%).

Let’s look at REM vs. EM from an eagle’s eye view:

Feature REM EM
Inheritance Consistent with root element Relative to parent element
Scalability Excellent More limited
Complexity Lower, due to consistency Higher, due to contextual sizing
Maintenance Easy — changes to root size cascade Can be trickier with nested elements
Accessibility Works well with user preferences May require adjustments
Best for Global spacing and layout Component-specific scaling

REM and EM: Font Sizing FAQS

The guide should have cleared up most of the confusion surrounding these very similar units.

But if you still have questions, here’s what you need to know!

Should I use REM or EM for responsive design?

REM is generally the better choice for responsive designs as it allows you to create consistent and scalable layouts that adapt to different screen sizes.

The only exception is when you want to create discrete units, where all the elements maintain the same size ratio.

How can I avoid complexity when using EM units?

To avoid complexity with EM units, try to limit the nesting of elements. Use REM for global sizing and EM for minor adjustments within specific components.

Is there a recommended base font size for REM?

While there’s no strict rule, a common base font size for REM is 16px. However, you can choose any value that suits your design preferences and accessibility requirements.

Dive Deeper Into CSS

Want to learn more about digital design? We’ve got lots of great CSS learning resources:

Responsive Design Matters

The CSS unit is a component that’s often overlooked, as we mentioned at the start of this guide.

However, if you want to create a website or app that looks good on every device and works for every user, it’s important to think about the details of the design.

The debate between REM or EM doesn’t really matter too much in the end — The most important thing is that your site is accessible, responsive, and easy to use!

Just remember that a pretty interface means nothing if your site or app won’t load. When it comes to providing your users with the best experience, consider upgrading your hosting with DreamHost.

We offer a 100% uptime guarantee on all our shared hosting plans, with optimized servers and great security features. Sign up today to see the difference for yourself!

Dedicated Hosting

Get DreamHost’s Most Powerful Hosting

Our dedicated hosting plans are the ideal solution for high-traffic sites that require fast speeds and consistent uptime.

See Plans

Jennifer is Designer II at DreamHost and is responsible for branding, design, and UX/UI. In her free time, she enjoys crafting, cooking, and camping. Follow Jennifer on LinkedIn: https://www.linkedin.com/in/nhijenniferle/


Your Dream Website Is Just One Click Away

At Ericks Webs Design, we believe every business deserves a stunning online presence — without the stress. We offer flexible payment options, a friendly team that truly cares, and expert support every step of the way.

Whether you’re a small business owner, a church, or a growing brand, we’re here to bring your vision to life.

✨ Let’s build something amazing together.

— no pressure, just possibilities.

Latest News & Website Design Tips

Stay up-to-date with the latest insights, trends, and tips in business website design. Explore our newest articles to discover strategies that can help you elevate your online presence and grow your business.

Why Your Website is Your #1 Sales Tool in 2025

Why Your Website is Your #1 Sales Tool in 2025

The article “Why Your Website is Your #1 Sales Tool in 2025” highlights the importance of having an effective website as the key to driving sales for small businesses. It emphasizes that a well-designed website acts as a digital storefront, attracting customers with engaging content rather than clutter. With studies showing that consumers prefer informative articles over advertisements, businesses should focus on solid branding, SEO, and mobile-friendliness. Regular updates and maintenance are crucial to keep the site relevant. Ultimately, the article stresses that your website is your number one sales tool in 2025, urging small businesses to invest attention and care in their online presence.

Track & Improve Conversions with These Tools

Track & Improve Conversions with These Tools

The article “Track & Improve Conversions with These Tools” emphasizes the importance of transitioning casual website visitors into loyal customers for small and medium businesses in South Texas. It discusses leveraging tools like Google Analytics to understand audience behavior, A/B testing to optimize calls-to-action, and Hotjar to enhance user engagement. The article also highlights the role of social proof through testimonials and the significance of defining a unique selling proposition (USP) to stand out in a competitive market. With the right strategies and tools, businesses can effectively track and improve conversions, ensuring a successful online presence.

Capture More Leads with Popups (Without Being Annoying)

Capture More Leads with Popups (Without Being Annoying)

The article “Capture More Leads with Popups (Without Being Annoying)” explains how business owners can effectively use popups to attract leads while maintaining a positive user experience. Rather than appearing immediately, popups should be timed to appear after visitors engage with the site. Clear, friendly messaging and relevant offers tailored to site content are essential. Incentives, such as discounts, can encourage email sign-ups by fostering relationships. Testing various popup styles and ensuring they reflect the brand’s personality can enhance user connection. Ultimately, when used thoughtfully, popups can be a powerful tool for capturing more leads without being intrusive.

How to Use Social Proof to Drive Sales

How to Use Social Proof to Drive Sales

The article “How to Use Social Proof to Drive Sales” emphasizes leveraging social proof to enhance online presence and drive sales for local businesses. It highlights the importance of customer reviews, encouraging satisfied clients to share their experiences on platforms like Google and Facebook. Utilizing social media to showcase success stories and engaging with the audience is also recommended. Creating detailed case studies can provide evidence of results, while showcasing accolades and community involvement builds trust. Overall, businesses can harness social proof to strengthen relationships, establish credibility, and ultimately boost sales in a competitive digital landscape.

5 Website CTAs That Work Every Time

5 Website CTAs That Work Every Time

The article “5 Website CTAs That Work Every Time” emphasizes the importance of effective Call to Actions (CTAs) for improving website engagement. It highlights five key CTAs: “Get Your Free Quote Today!” encourages initial interaction; “Subscribe for Exclusive Tips & Tricks!” builds an email list while providing value; “Let’s Chat!” makes reaching out easy; “Check Out Our Portfolio” showcases previous work to build trust; and “Join Our Community” fosters a sense of belonging. The piece underscores that well-crafted CTAs transform a passive website into an engaging platform, ultimately boosting customer interaction and loyalty.

The Psychology Behind High-Converting Website Design

The Psychology Behind High-Converting Website Design

The article “The Psychology Behind High-Converting Website Design” highlights the importance of an effective website for boosting local businesses. It emphasizes that first impressions are crucial, as users form opinions within 50 milliseconds. Key elements for high-converting website design include visual hierarchy, clean layouts, and color psychology to evoke emotions. Engaging content is essential; it should resonate with the audience, tell stories, and feature clear calls to action. Building trust through easy navigation, social proof, and secure sites is vital for converting visitors into customers. Finally, the website should be adaptive, regularly updated to reflect new information and keep visitors engaged.

Create a Landing Page That Converts Like Crazy

Create a Landing Page That Converts Like Crazy

The article “Create a Landing Page That Converts Like Crazy” emphasizes the importance of an effective landing page for businesses of all sizes. It outlines key strategies to enhance conversions, starting with understanding your audience’s language and preferences. The author recommends using clear headlines, engaging visuals, and strong calls to action. Building trust through social proof, ensuring mobile responsiveness, and optimizing for SEO are also highlighted as crucial elements. Finally, the importance of monitoring analytics for continuous improvement is stressed. The article encourages business owners to collaborate with web design experts to create landing pages that truly convert.

Lead Magnets You Can Add to Your Website Today

Lead Magnets You Can Add to Your Website Today

The article “Lead Magnets You Can Add to Your Website Today” discusses how small business owners can enhance their online presence by using lead magnets. A lead magnet is an incentive, like a freebie, offered in exchange for a visitor’s email address. Suggested lead magnets include e-books, checklists, free trials, discount codes, webinars, and email courses, all designed to attract and engage potential customers. The article emphasizes the importance of making lead magnets easily accessible on your website and using analytics for performance tracking. It encourages businesses to embrace these strategies to convert visitors into lifelong customers, ultimately contributing to their growth.

Why You’re Losing Clients Without a Strong Homepage

Why You’re Losing Clients Without a Strong Homepage

The article “Why You’re Losing Clients Without a Strong Homepage” emphasizes the critical role of a well-designed homepage in attracting and retaining clients. It likens a confusing homepage to a messy store, which can drive potential customers away. A strong homepage should provide clear information about your offerings and resonate with the community, including using local visuals and language options. It’s vital to ensure mobile-friendliness and keep content updated to maintain engagement. A compelling homepage serves as a professional welcome mat for visitors, significantly impacting client retention. In summary, a strong homepage is essential for business success, especially in competitive markets like South Texas.