v4: Can't set $font-size-base to a pixel value
See original GitHub issueCurrently, $font-size-base is defined as:
$font-size-base: 1rem !default;
If you attempt to define your base font size using pixels, for example:
$font-size-base: 14px;
Then SASS will not compile because of Incompatible units: 'rem' and 'px'. in various calculations. It seems like you should be able to define a font size using pixels. If you are working with a designer who is using Sketch or something, you can sure bet that they have their font’s defined in pixels. A designer is not going to have any clue what a rem is.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:8 (3 by maintainers)
Top Results From Across the Web
How to change Bootstrap's global default font size?
Bootstrap uses the variable: $font-size-base: 1rem; // Assumes the browser default, typically 16px. I don't recommend mucking with this, but you can.
Read more >Why you should never use px to set font-size in CSS
If the current font size is 20px , then 1em = 20px (though again: you shouldn't set font sizes in pixels—this is just...
Read more >Use Rems for Font Size to Respect User Preferences
Using pixels is a particularly bad practice for font sizing because it can create some accessibility problems for users with vision impairments.
Read more >Font Size Idea: px at the Root, rem for Components, em for ...
This way you can adjust font-size at a module level, which is pretty easy. The chances the type within a single module have...
Read more >font-size - CSS: Cascading Style Sheets - MDN Web Docs
Setting the font size in pixel values ( px ) is a good choice when you need pixel accuracy. A px value is...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Hi @Jakobud you should always avoid doing fonts in px, it’s not good for accessibility.
Let me help you with your designers using sketch issues 😃
You can set up a function that transform px to rem like this:
Then if the designers set a 36px font size, you use it like this:
This is a flexible solution that will let you use
rems and your designerspx. We are using it at our project with successful results. In fact we use this for all our measurements, the only thing we do in px areborder-with. Designers use px we do prem 😃hope it helps!
setting the base font size in pixels overrides any minimum font size the user may have set in their browser, or any minimum default rem size a browser on a specific platform has been set to. not all use 16px default - for instance, from memory, browser on some kindle devices uses 20px or more