px vs rem: what to use for font-size in your CSS

  Рет қаралды 49,395

Coder Coder

Coder Coder

Күн бұрын

🔥 My course: Responsive Design for Beginners! coder-coder.com/responsive/
💻 Become a full-stack web dev with Zero to Mastery: academy.zerotomastery.io/a/af...
In this video I talk about why I use the rem unit instead of px (pixels) for font-size in my CSS styles. And I show you how I use rems and convert them to px in my Sass/SCSS workflow!
0:00 - intro
0:48 - how to change base font size in the browser
1:45 - font-size computed with rem units is accessible
3:32 - using px for font-size is not accessible
5:09 - why not just use zoom?
6:24 - absolute and relative units in CSS
7:22 - how em differs from rem
11:21 - the 62.5% hack for easier px to rem conversion
13:32 - I use a Sass function to convert instead
____________________________
SUPPORT THE CHANNEL
⭐ Join channel members and get perks: / @thecodercoder
👏🏽 Hit the THANKS button in any video!
🎨 Get my VS Code theme: marketplace.visualstudio.com/...
WANT TO LEARN WEB DEV?
Check out my courses:
🌟 Responsive Design for Beginners: coder-coder.com/responsive/
🌟 Gulp for Beginners: coder-coder.com/gulp-course/
RECOMMENDATIONS
⌨ My keyboard-- get 10% off with code THECODERCODER -- vissles.com/?ref=mu96kxst5w
💻 Other gear -- www.amazon.com/shop/thecoderc...
📚 My Favorite Books -- coder-coder.com/best-web-deve...
📺 My Favorite Courses -- coder-coder.com/best-web-deve...
🔽 FOLLOW CODER CODER
Blog -- coder-coder.com/
Twitter -- / thecodercoder
Instagram -- / thecodercoder
#webdevelopment #coding #programming

Пікірлер: 111
@ngoako
@ngoako 2 жыл бұрын
I've been learning and forgetting this for forever, it finally clicked! Thank you! I think I'll try the percentage hack for projects sass-less projects and the mixin for when I learn sass😌
@TheCoderCoder
@TheCoderCoder 2 жыл бұрын
Awesome!! I'm glad this could help explain things for you 😁
@hozay6552
@hozay6552 2 жыл бұрын
Very interesting video! I love how you brought up the function for sass later on. Really helpful! Thank you!
@SeniorJuniorDeveloper
@SeniorJuniorDeveloper 2 жыл бұрын
Love your content, always amazing explanations thanks!
@LifeAtMH41
@LifeAtMH41 2 жыл бұрын
After looking at one of your videos, I started using 'em' and rem() fn in my projects. Thanks for these. Especially for that rem() fn.
@_unknown7_
@_unknown7_ Жыл бұрын
Literally answered every question that I had related to the rem vs em explanation. 💗♥♥
@darialysak4591
@darialysak4591 20 күн бұрын
I am a designer, but you answered to all my questions about rem and em, thanks a lot!
@shubhamdhage6935
@shubhamdhage6935 2 жыл бұрын
you just got a new sub :) thank you for providing amazing content.
@sebastianmesa6255
@sebastianmesa6255 2 жыл бұрын
Thanks coder coder. this is super helpfully.
@ryanwright3965
@ryanwright3965 2 жыл бұрын
Wow. I just discovered your channel. Your videos are awesome. Keep it up!!
@jeet4180
@jeet4180 2 жыл бұрын
This is really very helpful. Thank you
@sknadeem340
@sknadeem340 2 жыл бұрын
Love your work.... ❤️❤️Keep making awsem videos...
@sornt
@sornt 2 жыл бұрын
very good video. thank you. it is something I haven't clear understand before.
@themussseee
@themussseee Жыл бұрын
I finally understand rem and ems thank you so much
@malamincamara5939
@malamincamara5939 6 ай бұрын
Naaa, I’m definitely subscribing to you. Your explanation is CLEEEAAAN!
@ammarshorbagy3852
@ammarshorbagy3852 Жыл бұрын
Thank you very much, I am from Egypt and the translation helps me a lot 😍
@adrianmin713
@adrianmin713 2 жыл бұрын
As always quality video! I was just wondering could we just set the base font size to 10px instead of 62.5%? Thank you for the amazing content.
@babinio7458
@babinio7458 2 жыл бұрын
another great tutorial !
@itsmenow9870
@itsmenow9870 Жыл бұрын
Thanks for the info 💯❤️
@KentaroxKondo
@KentaroxKondo Жыл бұрын
とてもわかりやすいです。ありがとうございます!
@wpxpert98
@wpxpert98 Жыл бұрын
This video is really helpful, thank you
@ax-coding631
@ax-coding631 2 жыл бұрын
Really helpful, thank you!
@jabeztadesse
@jabeztadesse 11 ай бұрын
Responsive font is just a must! Specially if you're using clamp it get's rid of all the font "jump" issues
@iamkhenny_07
@iamkhenny_07 7 ай бұрын
Wow amazing stuff 😊
@hookerrabbit
@hookerrabbit 2 жыл бұрын
New to your channel. Great content. equally great presentation. Thank you.
@immathiasyde
@immathiasyde 2 жыл бұрын
Em's could be used in such a manner that two text elements differ in ems, and have their common parent element to specify its font size in rem's. Like having a title to be double the size of a paragraph.
@imkir4n
@imkir4n 2 жыл бұрын
Good info thanks Jessica ❤️
@efthymiosn3381
@efthymiosn3381 2 жыл бұрын
Awesome! Thanks a lot!
@bikalrai8987
@bikalrai8987 2 жыл бұрын
one vid to make me subscribe to your channel, first vid i have watched of yours, thanks for the detailed explanations
@salaheddineaksaim4348
@salaheddineaksaim4348 2 жыл бұрын
Really helpful, thank you!.
@danaharley3565
@danaharley3565 2 жыл бұрын
I like the way you explain it to us
@simonehenry9041
@simonehenry9041 2 жыл бұрын
thank you for this! finally clicked in my brain
@bryankersten54
@bryankersten54 2 жыл бұрын
Awasome video! thank you so much! :D
@alpinelux407
@alpinelux407 2 жыл бұрын
Thank you so much for making videos for us, will you also gonna teach backend in this channel in future?
@TheCoderCoder
@TheCoderCoder 2 жыл бұрын
I've done mainly frontend in my career, and only a little backend, so I will most likely not do much backend stuff, unless I start learning it myself 😅 Thanks for watching!
@victorcesarquispeatencio3290
@victorcesarquispeatencio3290 2 жыл бұрын
Amazing 🤩
@alphatras4573
@alphatras4573 2 жыл бұрын
Thank you very much!
@joeariaratne8426
@joeariaratne8426 2 жыл бұрын
Don't skip the ads guys.. needs all the support she can get ...
@alimohammad1593
@alimohammad1593 2 жыл бұрын
Okay.,after 100years later,,We got your special video❤️❤️❤️
@fedestock1815
@fedestock1815 15 сағат бұрын
Thank you!
@jsbitswithbill8765
@jsbitswithbill8765 2 жыл бұрын
That rem() fn is a great idea!
@s_liyarli
@s_liyarli 2 жыл бұрын
it helped me a lot, love from Azerbaijan
@FilipCodes
@FilipCodes 2 жыл бұрын
Very usefull vid 😁
@Basic-computer-ai
@Basic-computer-ai 2 жыл бұрын
I love your teaching
@maissendeveloper
@maissendeveloper Жыл бұрын
thanks for your great videos !! but i'm wondering why we don't use 10px directly instead of 62.5% ?? and what if the default font size is not set to 16px, won't the 62.5% be useless ?
@ArielBerloto
@ArielBerloto 2 жыл бұрын
You're awesome!
@heheboi812
@heheboi812 2 жыл бұрын
Hello, in a recent project I did in which I used px, increasing the text size in Chrome on my phone is still scaling the font size even though its in pixels! Any thoughts?
@coderjaber
@coderjaber Жыл бұрын
Jessica when u will publish Responsive Design for Beginners course ?
@chiaza7735
@chiaza7735 2 жыл бұрын
CSS Queen 🏅
@brymstoner
@brymstoner Жыл бұрын
it's cool. i understand the different units. but because of the unnecessary maths, i find it much easier to just use px. remove the guesswork altogether.
@3101leonardo
@3101leonardo 2 жыл бұрын
Hi! I know you get this question a lot, but what is this theme you are using? I really want this extension lol
@ChristopherClaudioSkierka
@ChristopherClaudioSkierka Жыл бұрын
Hi there, you are nice to listen too when you explain things. Can you please tell me at 8.07 min in the video for example is the screen split with vs code on left and is the right side devtools? also how did you split your screen like that? many thanks in advance
@Troyzhen
@Troyzhen Жыл бұрын
The three dots in the top right of devtools (which is on the right side) you’ll see options on where to dock your dev tools window.
@Coder-Journey
@Coder-Journey 2 жыл бұрын
You're the best
@AhmedABD0077
@AhmedABD0077 Жыл бұрын
So for padding and margin ..etc can I use rems cuz it is more easy ?
@topicsmixer1107
@topicsmixer1107 2 жыл бұрын
what is the tip u should give who is learning react :)
@mohammedlayes9248
@mohammedlayes9248 2 жыл бұрын
Hi! If you don't mind me asking, what does font-size: 100% do, please?
@banjo4856
@banjo4856 10 күн бұрын
My question here is, does this rem and em matterrs in padding and margin as well, or it's only useful for font-sizing
@blackarchiteck4226
@blackarchiteck4226 2 жыл бұрын
Just found your page today love ❤️ your work and content. Just sub too
@ankurvishwakarma8731
@ankurvishwakarma8731 Ай бұрын
Can we also use rem for width and height?
@dmraushan
@dmraushan Жыл бұрын
62.5% hack was amazing 😂
@joefads5040
@joefads5040 2 жыл бұрын
I've been using rem for paddings and margins (alongside fonts), but when scaling the browser font size up the paddings/margins scale to much causing sentences to be broken up onto multiple lines to the point where it feels like a worse experience/un-readable. Any thoughts on this?
@TheCoderCoder
@TheCoderCoder 2 жыл бұрын
hmm, in that case perhaps you could try using px to set the padding and margin so they will always stay the same?
@joefads5040
@joefads5040 2 жыл бұрын
Ahh I'm so stoked you replied thank you! 😁 Yeah I was reading what seems like the only aritlce on medium saying not to using rem/em for layouts. I'm really leaning towards updating my blog layout rem values over to px values. Feels like a zoomed in experience rather than just a visual text aid. BTW I loved the rem sass mixin/fn!! 😍 I'm a massive fan of accessibility and sass, so I really enjoyed this video 😊
@TheCoderCoder
@TheCoderCoder 2 жыл бұрын
Cool 👍🏼 I'll have to research what units are recommended for padding and margin, px might be better for some things!
@RameshKumar-mv3jd
@RameshKumar-mv3jd 2 жыл бұрын
With the HTML percentage "hack", couldn't you set it to 6.25% and eliminate the need to divide the final rem units by 10?
@TheCoderCoder
@TheCoderCoder 2 жыл бұрын
omg I have never considered that! I actually can't think of a reason why that wouldn't work. will have to research that!
@RameshKumar-mv3jd
@RameshKumar-mv3jd 2 жыл бұрын
@@TheCoderCoder awesome, I hope it works
@aftabhussain3986
@aftabhussain3986 Жыл бұрын
I didn't get it can you elaborate please
@chukwudiconfidence3195
@chukwudiconfidence3195 8 ай бұрын
I am having a problem with mine
@funformic997
@funformic997 2 жыл бұрын
You type code so I do not see, please your zoom display
@sako4822
@sako4822 2 жыл бұрын
Very interesting video!. Really helpful, thank you!.
@cutipets8706
@cutipets8706 2 жыл бұрын
I think for the padding and margin things gets dif?
@justamongus7541
@justamongus7541 2 жыл бұрын
Ok now jessica is being consistent 😅😆
@TheCoderCoder
@TheCoderCoder 2 жыл бұрын
😅😅
@fatesteyneit2990
@fatesteyneit2990 2 жыл бұрын
is it wrong to just define the size on the body so you could use em everywhere? or am I missing something
@bx557
@bx557 2 жыл бұрын
Do you use px in any case in your projects or just rems and ems?
@TheCoderCoder
@TheCoderCoder 2 жыл бұрын
I try to never use px, but sometimes I get lazy and use it for border-radius 😅
@thedeveloper9896
@thedeveloper9896 2 жыл бұрын
You Look like my teacher 😂 also thank you I will start using rem!
@TheCoderCoder
@TheCoderCoder 2 жыл бұрын
Yay! 😁
@safdardahriwal7503
@safdardahriwal7503 2 жыл бұрын
Hello thank you so much for valuable knowledge .I need your help how can I contact you?
@smerspl7175
@smerspl7175 8 ай бұрын
Hello! I've some problem with it. While I'm using for example: padding-left: rem(30) padding-right: rem(30) it all works, but if I want to use padding: 0, rem(30) or padding: rem(0), rem(30) it doesn't work, somebody know why?
@TheCoderCoder
@TheCoderCoder 8 ай бұрын
You don't need the commas when using multiple values for "padding". If you want to only set padding-left and padding-right, you can write "padding-inline: rem(30)". Hope this helps!
@ahmedragab7934
@ahmedragab7934 2 жыл бұрын
❤❤❤
@shubhamujjwal328
@shubhamujjwal328 2 жыл бұрын
nice
@dmitriikulbaka1862
@dmitriikulbaka1862 2 жыл бұрын
Hello! But what if the font in the layout is 12px or 18px?
@rravensspace3617
@rravensspace3617 2 жыл бұрын
I believe you would do 12px/16px = 0.75rem and 18px/16px = 1.125rem. Because 1 rem = 16px, providing you use html { font-size: 100%;} Hope that is understandable.
@dmitriikulbaka1862
@dmitriikulbaka1862 2 жыл бұрын
@@rravensspace3617 Yes. I understood. Thanks.
@questific
@questific 2 жыл бұрын
Thank you so much Jessica 🥰 💀
@TheCoderCoder
@TheCoderCoder 2 жыл бұрын
Sorry, I think you may have mistaken me with someone else? Not sure who Samantha is 😅
@questific
@questific 2 жыл бұрын
@@TheCoderCoder OMG IM SO SORRY 😭😭😭😭
@zakariakhaled1871
@zakariakhaled1871 Жыл бұрын
I think that u speaking about r.e.m beauty 😭😭
@geoffreyking1
@geoffreyking1 Жыл бұрын
what if em doesn't have a parent font size?
@TheCoderCoder
@TheCoderCoder Жыл бұрын
If there's no parent, it will be based on the browser settings base font size, default is 16px
@coolemur976
@coolemur976 2 жыл бұрын
You should take a look at "CSS px vs rem in 2021 - Use px and Here's Why" on yt
@TheCoderCoder
@TheCoderCoder 2 жыл бұрын
I've seen it-- he makes good points about wanting consistency across websites which totally make sense. Ultimately I believe that a feature should behave the way its designed. So I personally prefer to allow the base font-size changing to affect a website text size, since that's what a user is expecting when they change it. I think eventually users will primarily use zoom for this and base font-size may go away from browser settings, but until then I'll be using rems :)
@coolemur976
@coolemur976 2 жыл бұрын
@@TheCoderCoder You should use px just to push internet to the right direction imo. The more devs use px, the sooner all browsers rely on zoom instead of rems. Px is the right way to measure things in web development.
@saburex2
@saburex2 2 жыл бұрын
the client asks for rems, you use rems, also they make the page responsive
@briandsouza7854
@briandsouza7854 2 жыл бұрын
Short Answer is Accessibility.
@irffan
@irffan 2 жыл бұрын
62.5%
@AbhishekSharmaOP
@AbhishekSharmaOP 2 жыл бұрын
I am so scared of web development.I always forget things and in the end i feel like i learned nothing.What shall i do ?
@TheCoderCoder
@TheCoderCoder 2 жыл бұрын
You can always look things up online if you don't remember it right away-- professional web devs always have to do that! And just keep trying one step at a time, and practicing by building even small examples to practice a specific concept
@MrWhoever
@MrWhoever Жыл бұрын
0:56 I'm using firefox but.. video closed. :P
@ezra3871
@ezra3871 2 жыл бұрын
Happy programmer day everyone!
@TheCoderCoder
@TheCoderCoder 2 жыл бұрын
Oh wow, I didn't know! Yay 🎉🎉
@ziggerwebdesign1704
@ziggerwebdesign1704 Жыл бұрын
I haven't used pixels in years
@dailymeow3283
@dailymeow3283 2 жыл бұрын
rem wins
@adammuhtarif
@adammuhtarif Жыл бұрын
Salman hersi is a somali guy 😅
@mariuszm439
@mariuszm439 2 жыл бұрын
worst explanation ever sad!
@TheCoderCoder
@TheCoderCoder 2 жыл бұрын
😢
@toscaantosca4541
@toscaantosca4541 2 жыл бұрын
Thanks for the video! If you don't use sass like me (any reason), you can use this: :root { --rem: calc(0.0625 * 1rem); // 1px if document font size is 16px } h1 { font-size: calc(32 * var(--rem)); // 32px }
Stop using pixels in your CSS! How and why to use REM and EM.
6:39
Pretty much every website uses the wrong font size…
15:33
Theo - t3․gg
Рет қаралды 62 М.
Dynamic #gadgets for math genius! #maths
00:29
FLIP FLOP Hacks
Рет қаралды 19 МЛН
Они убрались очень быстро!
00:40
Аришнев
Рет қаралды 951 М.
Eccentric clown jack #short #angel #clown
00:33
Super Beauty team
Рет қаралды 28 МЛН
He tried to save his parking spot, instant karma
00:28
Zach King
Рет қаралды 19 МЛН
What's the Perfect Font Size on Any Device in Web Design?
7:09
Creative Crew with Brad Hussey
Рет қаралды 10 М.
Are you using the right CSS units?
6:30
Kevin Powell
Рет қаралды 441 М.
What is NPM, and why do we need it? | Tutorial for beginners
14:27
Coder Coder
Рет қаралды 292 М.
How to test a local website on your phone
7:48
Coder Coder
Рет қаралды 382 М.
Learn web development as an absolute beginner
12:57
Coder Coder
Рет қаралды 2,8 МЛН
CSS em and rem explained #CSS #responsive
16:54
Kevin Powell
Рет қаралды 376 М.
ЭТОТ ЗАБЫТЫЙ ФЛАГМАН СИЛЬНО ПОДЕШЕВЕЛ! Стоит купить...
12:54
Thebox - о технике и гаджетах
Рет қаралды 148 М.
С Какой Высоты Разобьётся NOKIA3310 ?!😳
0:43
ПРОБЛЕМА МЕХАНИЧЕСКИХ КЛАВИАТУР!🤬
0:59
Корнеич
Рет қаралды 3,7 МЛН