Тёмный

Simplest CSS reset to prevent headaches 

Kevin Powell
Подписаться 915 тыс.
Просмотров 167 тыс.
50% 1

Get the code here: codepen.io/kevinpowell/pen/QW...
#css
--
Come hang out with other dev's in my Discord Community
💬 / discord
Keep up to date with everything I'm up to
✉ www.kevinpowell.co/newsletter
Come hang out with me live every Monday on Twitch!
📺 / kevinpowellcss
---
Help support my channel
👨‍🎓 Get a course: www.kevinpowell.co/courses
👕 Buy a shirt: teespring.com/stores/making-t...
💖 Support me on Patreon: / kevinpowell
---
My editor: VS Code - code.visualstudio.com/
---
I'm on some other places on the internet too!
If you'd like a behind the scenes and previews of what's coming up on my RU-vid channel, make sure to follow me on Instagram and Twitter.
Twitter: / kevinjpowell
Codepen: codepen.io/kevinpowell/
Github: github.com/kevin-powell
---
And whatever you do, don't forget to keep on making your corner of the internet just a little bit more awesome!

Опубликовано:

 

29 ноя 2022

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 127   
@marcialabrahantes3369
@marcialabrahantes3369 Год назад
RU-vid needs to add a way to save or favorite these shorts... simply amazing
@uhmarcel7417
@uhmarcel7417 Год назад
Was just thinking the same. Good material to save and have around
@GenghisD0ng
@GenghisD0ng Год назад
Get Readwise or Pocket
@renealbrechtsen9743
@renealbrechtsen9743 Год назад
I'm pretty sure you can go in to your history and save it to a playlist from there. I know you can on desktop, not sure about mobile though.
@ThePlacehole
@ThePlacehole Год назад
You can already save and favorite them. In the url replace "shorts/" by "watch?v=". Tada! A video you can save, pause, scrub, whatever your heart desires. What RU-vid actually needs to do is to stop breaking things that used to work..........
@ashishkkrishna
@ashishkkrishna Год назад
Just like the shorts and then go view it in your liked videos playlist
@mdnghbrs1283
@mdnghbrs1283 Год назад
This is so much better than my reset.css file. Really minimal. Thanks 4 sharing this sauce
@8koi245
@8koi245 Год назад
never understood those files, it's literally too much
@UnknwnArtst
@UnknwnArtst Год назад
I'm a Frontend engineer and this is my the best subscription ever on RU-vid. Thankful!
@SkippyMcfee
@SkippyMcfee Год назад
I just spent hours banging my head against a wall trying to get some images to resize properly. This saved me soooo many extra lines of code to get them right.
@harrisonhutton
@harrisonhutton Год назад
I've been looking for a video exactly like this for so long. Thank you!
@michaelanthony4750
@michaelanthony4750 Год назад
I was just wondering if you made a video about this. Thanks!
@EvanEdwards
@EvanEdwards Год назад
The Powell Reset: more minimal than Meyer, less opinionated than a full normalize, but a good starting point.
@aryzen2781
@aryzen2781 Год назад
Can you do this instead of separating them: *,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; font: inherit; }
@mohammedmutawakil4080
@mohammedmutawakil4080 Год назад
Always on point ☝️. Thanks for the reminder ☺️
@andsheterliak
@andsheterliak Год назад
I would also inherit the color style: a, button, input, ::placeholder, textarea, select { color: inherit; } or *, ::placeholder { color: inherit; } And the letter-spacing style: button, input, textarea, select, pre, ::placeholder { font: inherit; letter-spacing: inherit; } or *, ::placeholder { font: inherit; letter-spacing: inherit; color: inherit; }
@KevinPowell
@KevinPowell Год назад
Interesting for letter-spacing! True that it makes sense for inputs and buttons, since all the other typography is being inherited. I don't really like the idea of inherited the color for a or ::placeholder though. I guess it depends on the design, but in general, links should stand out in multiple ways (underline and color, for example), and ::placeholder being the same as regular text can make a form look like it's been pre-filled.
@andsheterliak
@andsheterliak Год назад
@@KevinPowell I agree.
@therealpepeu
@therealpepeu Год назад
*, *::before, *::after { box-sizing: border-box; } *{ margin: 0; padding: 0; font: inherit; } html{ color-scheme: dark light; } body { min-height: 100vh; } img, picture, svg, video{ display: block; max-width: 100%; }
@tejasvijb4228
@tejasvijb4228 Год назад
This sir should be in the top
@therealpepeu
@therealpepeu Год назад
@@tejasvijb4228 thank you! I posted it since I had to rewatch the whole thing and pause it to get it all. I hate that you can't scrub these shorts.
@gmcclure
@gmcclure Год назад
this^
@Enduredtimes
@Enduredtimes 3 месяца назад
Pin this bad boy
@ankitaburman5406
@ankitaburman5406 Год назад
We can get enough of Css shorts ❤❤Thanks Kevin for sharing
@adamuk73
@adamuk73 Год назад
Compulsory dark mode for all users. They don't know what's good for them ;-)
@8koi245
@8koi245 Год назад
lmao true
@complainer406
@complainer406 Год назад
Dark mode's actually really hard on the eyes for people with astigmatism. Light mode is an accessibility feature
@revenevan11
@revenevan11 Год назад
​@@complainer406also can be better for viewing on a screen outdoors in bright sunlight
@SquashBox
@SquashBox Год назад
I get headaches when trying to read websites in dark mode. Not sure why, but I would prefer having a toggle.
@cy-one
@cy-one Год назад
@@complainer406 As someone with very heavy astigmatism and glasses that currently don't compensate nearly enough for it, I can agree to this. Light mode is a lot easier and nicer to read.
@pcartisan2721
@pcartisan2721 Год назад
Love it! Thank you KP.
@VOIDMW
@VOIDMW Год назад
Love the color scheme tag, thanks you again.
@eja7444
@eja7444 Год назад
Amazing as always dude! Amazing as always!
@MoHafiz71
@MoHafiz71 Год назад
Thanks 👍 very much Mr. Kevin. I've been waiting for such a video...
@DevMadeEasy
@DevMadeEasy Год назад
Great Content, as usual, thank you so much for sharing it with us, I know how hard is to build a project then edit it, post... Thanks🙏
@andreimaier8126
@andreimaier8126 Год назад
Super useful as always! Thank you!
@NicoHeinrich
@NicoHeinrich Год назад
Love it! Thanks for sharing Kevin :)
@a5tr00
@a5tr00 Год назад
This goes to my saved items :) Thanks mate
@brandon_wallace
@brandon_wallace Год назад
This man is the greatest.
@1909jaya
@1909jaya Год назад
I feel like I got my xmas prezent! Thank you!!
@threeone6012
@threeone6012 3 месяца назад
Pro level tip.
@AbbasAli-yj3fg
@AbbasAli-yj3fg Год назад
love you man!!!!!
@brandon_wallace
@brandon_wallace Год назад
Wow! Nice!
@KSalvatore
@KSalvatore Год назад
Do we need to use color scheme. Because i use toggle button for it. Using root and variable
@stevenholdenpedersen1116
@stevenholdenpedersen1116 Год назад
Is there a reason not to throw the margin and paddings into the *::after/*::before selector?
@lixeletto
@lixeletto Год назад
I like setting links color to currentColor
@rawat1488
@rawat1488 Год назад
why i never thought of that with images
@francm_1
@francm_1 Год назад
Podrías hacer un video explicando lo de prefer-scheme: light dark; saludos desde Ecuador. Gracias por tan buen contenido
@MessageKyle
@MessageKyle Год назад
perfect
@Tony.Nguyen137
@Tony.Nguyen137 Год назад
Why didnt you put the font, margin and padding in the first * selector?
@nomadshiba
@nomadshiba Год назад
💪
@phil5053
@phil5053 Год назад
Nice
@m_nasyr
@m_nasyr Год назад
Very usefull
@GoldenToothBrush
@GoldenToothBrush 6 месяцев назад
Would love to know what the before and after pseudo elements are doing here?
@aaronraycove9517
@aaronraycove9517 Год назад
That chunk of code, just fixed my problem. Still have no idea why it worked though 😕.
@darkopz
@darkopz Год назад
Problem with these shorts is that you can’t save them to a playlist that I’ve found.
@nekochats854
@nekochats854 Год назад
This used to drive me crazy as well! Here's what you do: 1) 'like' the short 2) go to your Library > Playlists > Liked videos 3) click on the three vertical dots next to the short you 'liked' and that menu will have the Save to Playlist option
@PeterJewell2
@PeterJewell2 Год назад
Strange, I managed to save it directly to a playlist as usual. Maybe it's different on desktop?
@darkopz
@darkopz Год назад
@@PeterJewell2 I almost exclusively watch shorts on my phone. I bet you’re right.
@neryskkiran1820
@neryskkiran1820 Год назад
I go to history, and the 3 dots are there, with the save to playlist option. There's a few ways... Wouldn't it be nice if they just let you do it from the short tho? :)
@KevinPowell
@KevinPowell Год назад
Agreed, that would be a nice addition
@ocxigin9220
@ocxigin9220 24 дня назад
Is it advisable for Img to be set as display block
@danielgarr4030
@danielgarr4030 Год назад
On the darkmode reset: isn't it assigning the browser to darkmode and ignoring the user preferences?
@Zedoy
@Zedoy Год назад
Does normalize.css does this reset automatically?
@OrincyWhyteDesigns
@OrincyWhyteDesigns Год назад
🎉🎉
@blaircfleming
@blaircfleming Год назад
Could button { all: unset; } have a place in here?
@dheepshemare5833
@dheepshemare5833 Год назад
Can you do a video on Scss?
@ryangreen7581
@ryangreen7581 8 месяцев назад
Slightly unrelated question: is it possible my css reset(meyers web) is the cause for browser ‘flickering’ when I’m editing my CSS file? I’ve searched high & low on this and it happens on both browsers (chrome & FDE). I’m annoyed & stumped..
@KevinPowell
@KevinPowell 8 месяцев назад
I don't see how it would be, no. Two things though, when you say flickering, could you explain it more? It is shifting? If you're using web fonts, including Google fonts, it could be from those causing a shift when they load in. The other thing is awesome as Meyers reset was, it's a bit out dated now. There are several less aggressive ones that have become more widely used these days. Normalize might be the most common, but there are others too like Andy Bells reset, and a few others too
@7urkoGaming
@7urkoGaming Год назад
Viewport height not cause issues in mobile?
@Ravanger666
@Ravanger666 Год назад
It does, I prefer to use html, body { height: 100%; }
@KevinPowell
@KevinPowell Год назад
That can cause issues with other things, like smooth scrolling and double scrollbars. Really the best is dvh, which I wanted to include, but didn't have the time to in a short, since going into the nuance of browser support isn't easy in a short 😅
@7urkoGaming
@7urkoGaming Год назад
I usually use html { height:100%} body { min-height: 100%; height:0} In case a dont want issues with scrollbars and i need something like a Hero banner taking the full height..
@gioacopeasta
@gioacopeasta Год назад
do you prefer using a reset or a normalize css file?
@KevinPowell
@KevinPowell Год назад
I haven't used a normalize in a long time now
@filippotinnirello
@filippotinnirello Год назад
@@KevinPowell not even -webkit-font-smoothing and -moz-osx-font-smoothing are necessary?
@efari
@efari Год назад
Kevin, is there a reason one would not reset everything to position: relative, since that always fixes position: absolute ? * { position: relative; }
@Issvor
@Issvor Год назад
His latest video about "Container Blocks" explains this, actually. Basically comes down to you not always wanting the immediate parent to have position: relative for certain design styles
@hikari1690
@hikari1690 Год назад
Ooooh so these are what people mean by css reset. Been doing them cause of the headache caused from not doing these 🤣
@Chrosam
@Chrosam Год назад
I like using this more than using vh html, body, #App { width: 100%; height: 100% }
@KevinPowell
@KevinPowell Год назад
That comes with it's own issues, like easy smooth scrolling and potentially dealing with extra scrollbars (even if they are hidden). (I realize 100vh has it's own issues too, i wanted to talk about 100dvh, but not enough time in 60 seconds, so it'll have to be another video, lol)
@KB04
@KB04 Год назад
@@KevinPowellso can we expect a dvh vid soon?
@MirzaMonirulAlam
@MirzaMonirulAlam 10 месяцев назад
Kevin, why didn't you put margin:0; padding:0; font:inherit in pseudo element?
@KevinPowell
@KevinPowell 10 месяцев назад
because they already have all of those. EDIT for more clarity: pseudo elements don't have a margin or padding by default, and will inherit all the font properties, so there's no need to declare any of those
@LuisReyes-zs4uk
@LuisReyes-zs4uk Год назад
Why the dark mode thing? Why does it make lives easier? Thanks.
@harunjonuzi
@harunjonuzi 8 месяцев назад
Isn't this way better? html { box-sizing: border-box; } *, *::before, *::after { box-sizing: inherit; }
@xtiandyc7034
@xtiandyc7034 Год назад
Can this still be used if I will also use tailwind CSS?
@He_isI
@He_isI 9 месяцев назад
Yes. Make sure to put this first in your links. FYI: I’m a beginner.
@AutsajderRR
@AutsajderRR Год назад
How to pause or rewind this fuckin short???
@kjartannn
@kjartannn Год назад
I use tailwind normally but this is super useful for if I ever have to work on a pure CSS project in the future. Great video!
@DillonRedding
@DillonRedding Год назад
I love this idea of resetting font styling for things like headings. Then all elements are purely semantic, and the responsibility of styling stays in the CSS and out of the HTML 🤯
@ppolqx1487
@ppolqx1487 Год назад
I can’t understand can you understand me?
@bunyaints534
@bunyaints534 Год назад
Css kami
@rajasamosa
@rajasamosa Год назад
This is helpful, however I do have a question. I always add a normalize.css from github to my site, does that do what is listed in this video or should I best add all these things manually?
@mvonballmo
@mvonballmo Год назад
Yeah, really like these shorts, but you can't even scrub back if you missed something. I was even hoping I could copy/paste the reset script, but I'm pausing the "video" and copying it down by hand, like a troglodyte. I'm sure I'm doing it wrong -- I'm supposed to just let the content wash over me without learning anything. :-)
@artnikpro
@artnikpro Год назад
Changing the default box-sizing is actually a bad practice. If you will install and use some third party UI component in your app, it may break it’s look
@liimd13
@liimd13 Год назад
I have * { min-width: 0; } for preventing expanding grid items
@StiekemeHenk
@StiekemeHenk Год назад
I hate lightmode but you should keep it the default for accessibility sake.
@KevinPowell
@KevinPowell Год назад
This will only switch if the user preference has been set to darkmode. If I user has lightmode, it'll use that.
@SRG-Learn-Code
@SRG-Learn-Code 7 месяцев назад
I do this: *,*:before,*:after{box-sizing:border-box}*{margin:0;padding:0;font:inherit}html{color-scheme:dark light}body{min-height:100vh}img,picture,svg,video{display:block;max-width:100%}
@zyxyuv1650
@zyxyuv1650 Год назад
I hope I never have to write another line of CSS and AI can do it from now on.
@jhona1429
@jhona1429 Год назад
You forgot: html {font-size: 62.5%}
@Hobbitstomper
@Hobbitstomper Год назад
That's not recommend anymore because it breaks accessibility. If a user with impaired vision sets his browsers default font size to 20, 24 or 32px, they won't be able to read your website. The only reason we used to set html {font-size: 62.5%} in the first place, was to make the conversion from pixel to rem units easier when implementing fallbacks to support older browser that don't support rem. (1rem = 10px) However rem has been supported by all browsers since 2010. So it's safe to say that anyone who uses a 12 year old browser has bigger concerns than font sizes. Just use rem without pixel fallback for font sizes. No need to support 12 year old browsers, but there is a need to support accessibility for different browser default font sizes.
@Issvor
@Issvor Год назад
@@Hobbitstomper What do you mean they wont be able to read the website? ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-pKX7YnkyR8g.html this video does a great job at explaining how using rem affects a website compared to pixel values and he doesn't even mention using pixel values as fallback.
@Hobbitstomper
@Hobbitstomper Год назад
​@@Issvor html {font-size: 62.5%} breaks accessibility because it makes the default browser font sizes ~40% smaller. So when someone with impaired vision sets their default browser font size from 16px to 28px because 16px is too small for them and you then set html {font-size: 62.5%}, now instead of the user getting 28px font size, they get 17.5px font size which makes it again too small for them to read. Just dont use html {font-size: 62.5%} and don't use pixels for font-sizes, use rem. html {font-size: 62.5%} was only used to make the conversion between rem and pixel easier (10:1). I am saying use rem only and not pixel. No need for pixel unit when using font-size. We used to use both, rem and pixel at the same time as fallback for browsers that dont support rem, but those browsers are now 12 years old and there is no need to support them.
@nickwoodward819
@nickwoodward819 Год назад
min-height in the body never works for me
@Ta9i
@Ta9i Год назад
or just use "normalize.css"