<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/why-you-should-never-use-px-to-set-font-size-in-css-v3sat4lss" -->

---
title: Why you should never use px to set font-size in CSS
description: CSS Tricks: Why you should never use px to set font-size in CSS is an important, and poorly understood topic. If you pick the wrong unit, you risk overriding...
canonical: https://daily.dev/posts/why-you-should-never-use-px-to-set-font-size-in-css-v3sat4lss
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Why you should never use px to set font-size in CSS | daily.dev
og:description: CSS Tricks: Why you should never use px to set font-size in CSS is an important, and poorly understood topic. If you pick the wrong unit, you risk overriding...
og:url: https://daily.dev/posts/why-you-should-never-use-px-to-set-font-size-in-css-v3sat4lss
og:image: https://api.daily.dev/og/posts/v3SAT4LsS.png
og:image:alt: Why you should never use px to set font-size in CSS
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Why you should never use px to set font-size in CSS

**[Community Picks](https://daily.dev/sources/community)** · 11 min read · 178 upvotes · 10 comments

## Summary

CSS Tricks: Why you should never use px to set font-size in CSS is an important, and poorly understood topic. If you pick the wrong unit, you risk overriding your users’ preferences, making it stands for “root em,” and the root of a webpage is the tag.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://joshcollinsworth.com/blog/never-use-px-for-font-size>

## Community discussion

Top comments from developers on daily.dev.

**@ndaidong** · 9 upvotes

> each unit has its own use-case. Similar to programming, sometimes we still need static variables.

**@marceloorigoni** · 5 upvotes

> Nah, we should stop using em and rem as sizing and learns how to make responsive sites/apps, not just liquid.

**@craftogrammer** · 3 upvotes

> PX when client cares about his device more, and REM/EM when they actually care about others.

**@prince1456** · 2 upvotes

> not sure we should never use that but its good if we can use alternative way for responsive approach

**@fullstacker** · 1 upvotes

> Thank you for sharing this article! I completely agree that using px to set font-size in CSS can be problematic because it doesn't allow for responsive design. Instead, using relative units like em or rem can be a better option because they are relative to the font-size of the parent element, which makes it easier to create responsive designs that work on a variety of devices

## Similar posts on daily.dev

- [Don’t just attend KubeCon \+ CloudNativeCon, Merge Forward your experience\!](https://daily.dev/posts/don-t-just-attend-kubecon-cloudnativecon-merge-forward-your-experience--l0rpp73x8) · CNCF · 1 upvotes · 0 comments
- [Announcing H2 2026 KCDs](https://daily.dev/posts/announcing-h2-2026-kcds-m96goajm1) · CNCF · 1 upvotes · 0 comments
- [Two months of Open Community Groups](https://daily.dev/posts/two-months-of-open-community-groups-asf52zhbs) · CNCF · 0 upvotes · 0 comments
- [CNCF Unveils Schedule for KubeCon \+ CloudNativeCon Europe 2026](https://daily.dev/posts/cncf-unveils-schedule-for-kubecon-cloudnativecon-europe-2026-ikhcoa5cb) · CNCF · 2 upvotes · 0 comments
- [CNCF Debuts KubeCon \+ CloudNativeCon Japan 2026 Schedule](https://daily.dev/posts/cncf-debuts-kubecon-cloudnativecon-japan-2026-schedule-xp5pyudub) · CNCF · 1 upvotes · 0 comments

---

Tags: [#css](https://daily.dev/tags/css)

[View this post on daily.dev](https://daily.dev/posts/why-you-should-never-use-px-to-set-font-size-in-css-v3sat4lss)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Why you should never use px to set font-size in CSS","url":"https://daily.dev/posts/why-you-should-never-use-px-to-set-font-size-in-css-v3sat4lss","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/why-you-should-never-use-px-to-set-font-size-in-css-v3sat4lss"},"datePublished":"2022-11-10T18:11:30.932Z","dateModified":"2023-12-07T12:02:45.284Z","description":"CSS Tricks: Why you should never use px to set font-size in CSS is an important, and poorly understood topic. If you pick the wrong unit, you risk overriding...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/9bfd2e590ab35676cacd8aef1b32b885","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/9bfd2e590ab35676cacd8aef1b32b885","isAccessibleForFree":true,"articleSection":"Community Picks","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Community Picks","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1655817725/logos/community","url":"https://daily.dev/sources/community"},"commentCount":10,"discussionUrl":"https://daily.dev/posts/why-you-should-never-use-px-to-set-font-size-in-css-v3sat4lss","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":178},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":10}],"keywords":"css","timeRequired":"PT11M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Community Picks","item":"https://daily.dev/sources/community"},{"@type":"ListItem","position":3,"name":"Why you should never use px to set font-size in CSS"}]}
{"@context":"https://schema.org","@type":"WebPage","@id":"https://daily.dev/posts/why-you-should-never-use-px-to-set-font-size-in-css-v3sat4lss","comment":[{"@type":"Comment","text":"each unit has its own use-case. Similar to programming, sometimes we still need static variables.","datePublished":"2022-11-11T04:20:28.730Z","url":"https://daily.dev/posts/v3SAT4LsS#c-MgaLBWYNL","author":{"@type":"Person","name":"Dong Nguyen","url":"https://daily.dev/ndaidong","image":"https://avatars.githubusercontent.com/u/1809619?v=4"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":9}},{"@type":"Comment","text":"Nah, we should stop using em and rem as sizing and learns how to make responsive sites/apps, not just liquid.","datePublished":"2022-11-10T23:41:15.240Z","url":"https://daily.dev/posts/v3SAT4LsS#c-_0gOYlgX-","author":{"@type":"Person","name":"Marcelo Origoni","url":"https://daily.dev/marceloorigoni"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":5}},{"@type":"Comment","text":"PX when client cares about his device more, and REM/EM when they actually care about others.","datePublished":"2022-11-12T03:48:10.551Z","url":"https://daily.dev/posts/v3SAT4LsS#c-9M2zL1W5i","author":{"@type":"Person","name":"Rahul","url":"https://daily.dev/craftogrammer","image":"https://media.daily.dev/image/upload/s--9uhYywIw--/f_auto/v1729970262/avatars/avatar_QvOtOUz9l"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":3}},{"@type":"Comment","text":"not sure we should never use that but its good if we can use alternative way for responsive approach","datePublished":"2022-11-13T01:10:50.093Z","url":"https://daily.dev/posts/v3SAT4LsS#c-kcIz29JVz","author":{"@type":"Person","name":"Ali","url":"https://daily.dev/prince1456","image":"https://avatars.githubusercontent.com/u/20523380?v=4"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":2}},{"@type":"Comment","text":"Thank you for sharing this article! I completely agree that using px to set font-size in CSS can be problematic because it doesn’t allow for responsive design. Instead, using relative units like em or rem can be a better option because they are relative to the font-size of the parent element, which makes it easier to create responsive designs that work on a variety of devices","datePublished":"2022-12-08T21:55:33.641Z","url":"https://daily.dev/posts/v3SAT4LsS#c-7q8sWpW43","author":{"@type":"Person","name":"Fullstacker","url":"https://daily.dev/fullstacker","image":"https://lh3.googleusercontent.com/a/ALm5wu2JiRlRkxfh4XCJNiOPboZLjmBA2jpyVtK-KVgP=s96-c"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1}}]}
```

