Тёмный

These CSS best practices might be holding you back 

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

🎓 CSS Demystified: cssdemystified.com?
We’re told about a lot of CSS best practices early on, and while some of them can be very useful, I feel like many of them are more like training wheels that are there so we can focus on other stuff, and eventually it’s a good idea to take them off!
🔗 Links
✅ The Space Tourism project: • Responsive navbar tuto...
✅ CSS Demystified: cssdemystified.com?
⌚ Timestamps
00:00 - Introduction
00:30 - A lot of best practices are like training wheels
01:50 - Class selectors for everything
03:18 - Never use ID selectors
06:30 - Descendant selectors
10:00 - Never use em for font-size
12:57 - Going back over the basics
14:40 - Mobile first
18:37 - !important
21:30 - Any others?
#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!

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

 

7 июн 2024

Поделиться:

Ссылка:

Скачать:

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

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 112   
@niner8275
@niner8275 9 месяцев назад
I wonder if instead of going "mobile first", the best approach would rather be: "least need for style-overwriting", which is actually equal to "accomplish as much as possible with as little CSS as necessary" 🙂
@KevinPowell
@KevinPowell 9 месяцев назад
Yeah, I like to call it the "path of least resistance". The less CSS, usually the better :D
@rand0mtv660
@rand0mtv660 9 месяцев назад
For me usually mobile first does produce the least CSS, but I do agree that it doesn't make sense to go mobile first if that would mean overriding a bunch of styles when a better solution would be a max-width media query.
@nwfashionmedia
@nwfashionmedia 9 месяцев назад
If I'm making a B2B site only for use by a client company's internal staff, I'd probably go desktop-first (I have worked on a few projects over the past few years which didn't even have mobile designs because that just wasn't a use case).
@photomat
@photomat 9 месяцев назад
Our frontend and backend (java) developers have an agreement: Front-end stays away from IDs (they are used for backend operations like refreshing and often generated) and back-end doesn't alter any style-classes. Sometimes backend has to use a styleclass but that is always prefixed by 'js-'
@AdamGaffney96
@AdamGaffney96 9 месяцев назад
I definitely think "mobile-first" held me back a lot. The projects I wanted to work on were things like a chess site, a sudoku site, general mini-games etc. These are things that are best on desktop, but I got so bogged down in mobile first and forward planning for responsiveness that I never even got it working.
@sarcasm_emoji3070
@sarcasm_emoji3070 9 месяцев назад
To an extent, i agree because most, if not all projects can be achieved via desktop but not all projects may work via mobile. But then again, in my opinion advantage of mobile-first > disadvantage of desktop-first. I think as Mr Powell mentioned, you can avoid it at times
@sarcasm_emoji3070
@sarcasm_emoji3070 9 месяцев назад
Maybe I'm feeling the mobile-first work flow because i haven't come across an issue with it🤔
@dogoku
@dogoku 9 месяцев назад
The general advice I give for !important is to use it defensively, rather than offensively. Defensively is like the example you gave with the utility class, where you want to be sure a style will be applied no matter what. Offensively means that you are overwriting an existing selector that is more specific. !important is a shield to protect your own, not a sword to conquer others.
@pdizzlin
@pdizzlin 5 месяцев назад
That’s a great way to think about it! I also think it’s good on utility classes because it forces users to actually remove the utility class from the element if they don’t want the style instead of just overwriting it.
@quantyquanty3724
@quantyquanty3724 9 месяцев назад
I fell in love with this channel when I was searching for answers on the subject specificity. I subscribed and still getting myself schooled about CSS. Thank you.
@williamsa51
@williamsa51 9 месяцев назад
Many thanks for this Kevin and your newsletter. Much appreciated.
@ApprendreSansNecessite
@ApprendreSansNecessite 9 месяцев назад
It took me a while to understand why people were complaining about specificity. I think being a print designer shielded me against it to some extent. When you design you think in terms of style guide / graphic charter / design system, so you come up with rules: "X should look like this, but in this context it should look like that". When you are in a situation where specificity becomes a problem, it's possible that you were simply mistaken about the rules of your design. Instead of placing an `!important` or blaming CSS specificity and make the vow to only use classes, maybe you can simply reflect your newly acquired knowledge about the design in your CSS and style guide
@thought-provoker
@thought-provoker 9 месяцев назад
Kevin, thanks for addressing this. Here's something I've been asking myself for a while: When developing web components, it's certain that there will only be, for example, a single within the component: If it were different, I might have issues with the entire concept of OOD. Hence, I just style that thing inside the component's shadow directly, without a class selector. It seems that defining classes for something unique in an isolated context is overkill - and might even mask OOD problems? What's your suggestion there?
@outpost31737
@outpost31737 9 месяцев назад
Thanks Kevin. Very helpful!
@JimKernix
@JimKernix 9 месяцев назад
I just used a lot of id selectors for a full-stack MERN project where the react-bootrap classes were the same on every page I used them. I could have added my own class as well, but I just decided to add an id for the specific items I needed to style. I rarely do that, but for that case it seemed like the best approach.
@kiravolvo
@kiravolvo 9 месяцев назад
so true. sometimes there is just a need for important on legacy classes or external widgets you need to implement that otherwise won't budge... :) loved the video. thank you
@MuhamedAshraf1
@MuhamedAshraf1 9 месяцев назад
Thanks for these very helpful tips for me as a beginner
@PicSta
@PicSta 9 месяцев назад
I think the mobile first or desktop first approach really depends on the project. Sometimes I think it's easier to remove things or complexity rather than adding it, as it needs much more prep work and thinking upfront. There is no right or wrong in my opinion, naturally what is easier results in the right way. What you mentioned, Kevin, about default styling across all screen sizes is very important and can help massively. I like being very specific with my links, paragraphs, headlines and so on. Great video as always. Thanks for that.
@Zashxq
@Zashxq 9 месяцев назад
the EM vs REM situation actually came up in a major visual regression bug at my job. for some reason, on some pages, the font sizing was absolutely tiny in production despite local testing. i came to discover that additional CSS rules we were being loaded, changing the base font-size, and there was no way to unbundle these rules without a major refactor. a simple switch to EMs for some components reused on those pages solved the issue in maybe 2 or 3 lines of code. flexibility is the key!!
@peteremad5228
@peteremad5228 9 месяцев назад
i think using css framework like tailwindcss solve most of these problems out of the box ...and make development alot easier
@EvanEdwards
@EvanEdwards 9 месяцев назад
You touched on something critical when you mentioned "if you're working with a big team." Best practices are always context dependent: what is best for a custom crafted museum site is completely different than a multi-vendor sales site, and if you're working on a framework for a CMS that clients can add custom CSS to, there's a whole different set of demands. Add in apps that use CSS and allow third party plugins (either online or local, like Obsidian), and there are a ton of edge cases that have even more extreme needs. There is nothing universal except the most basic things: clarity, formatting, consistency, communication (aka comments and/or documentation)... and sometimes when you're prototyping a quick throwaway demo to visually present a concept in two hours, even those can get jettisoned for practical demands.
@thedelanyo
@thedelanyo 9 месяцев назад
For specificity, sveltejs as a frontend engine, which is great for component scope. I can target a div or section in a particular component and it'll not be applied to any of those in the different component, although they may all live in the same page. For my site-wide global css, I tend to use picocss which mostly targets elements
@PascalHorn
@PascalHorn 9 месяцев назад
I like those videos from you, Kevin. Because they explain in a very simple way, why one should always use the most simple and clean way to create what you need, so I can share them with co-workers. 😊 Which adds another point to all of this. Using simple and clean CSS (as well as JS and other stuff) makes it much, much less frustrating for another person, if they ever need to change or fix things later on. In my opinion, a template is never really finished, there's just a launch date. If one has to change things in a template from a co-worker, they can become quite frustrated if the CSS file is messy. I have seen things and I'm sure everybody's freaking out by trying to fix some other persons code being like: id id class class class class div.class[data-has-anchor="stuff"] a > span:first-child
@nilaallj
@nilaallj 9 месяцев назад
I've been using cascade layers in production for a while now. It has changed the way I write CSS quite a lot simply because it makes it so easy to control how all the styles cascade. Now I go crazy with both descendant selectors and ID’s. I reckon it will get even more crazy with nesting and the upcoming @scope rule.
@AntiAtheismIsUnstoppable
@AntiAtheismIsUnstoppable 9 месяцев назад
Generally, I use IDs only for JS hooks. I know querySelector is a thing, but readability and not least performance wise, getElementByID is still easier to understand, it does only one single thing, it has been in JS like forever, and it's faster too. So, you can for example have a JS function hooked to a specific ID, where the content table goes, and then reading all the Hx then making the table placing the table into that ID. Article table of content I never use more than once on a page, so that is a good example. Another example is a JS generated calendar, usually used on blog pages, I never use that more than once either. Small JS tools doing just one single thing and hooking to an ID is very easy to understand, you add the ID in the HTML where the function should be used, and it works. Of course, when you go to more advanced frameworks, often the framework uses class, because the function can be used many times on a page, but the idea is the same.
@Julie-gh5ir
@Julie-gh5ir 9 месяцев назад
Hey ! The subtitles are not available on that video. Possible for you to turn them on ? My english is not very fluent. And I don't want to miss one of your awesome video. Thank you so much for all your work !
@ceilidhDwy
@ceilidhDwy 9 месяцев назад
Mobile first never made sense to me, because at least on the projects I worked on, desktop versions are a lot more complicated. So I make a mobile layout that works flawlessly, start making a desktop layout and surprise this section's layout is 2D and I cannot just use grid because of nesting and sub grids are not a thing yet so I have to redo my html and mobile breaks. There a fewer surprises when you are doing things in reverse, there are hiccups, but you can usually make things work without modifying html at all. And if you are working with clients or designers (meaning clients by proxy), they usually want to see the desktop version first (if they even remember mobile exists) So, in conclusion, waiting for mobile when desktop version is approved not only makes the project take longer, but in the end I'll have to make 3 passes with css instead of 2 I would of course be glad to be proven wrong on this, since that would make my workflow easier
@AlexM86
@AlexM86 9 месяцев назад
You uttered the unspeakable words that send shivers down my spine: page builders. I remember a time I had to inject inline styles with important through js because one of those page builders was extremely liberal with its use of important. Worst css experience of my life honestly
@El_Bald
@El_Bald 9 месяцев назад
HI Kevin I think it would be a good idea to make a video about how you name your custom properties. For instance, where that "- - clr - primary - 700" come from? Sometimes you use (Primary, Secondary and Accent) but other times you use (Primary and Neutral). So, I think it's worth letting us know how you figure it out.
@jshstuff
@jshstuff 9 месяцев назад
I’ve always have a difficult time explaining to coworkers why I use max width media queries. Sometimes I’d encounter a problem and it was just obvious that min-width was the wrong tool and so I max-widthed and thought nothing of it. But then I’d fail peer review because some other dev says “at our company we work mobile-first”, and I’m suddenly conflicted because yes, mobile first is a good thing, but I know min-width is a worse choice in this case. So I concluded that mobile-first as a development methodology is stupid and that it’s maybe only useful to give designers a consistent strategy for designing responsive pages. Developers should, as you said, follow the path of least resistance and shouldn’t feel as though any tool in CSS is wrong to use, so long as it does the job well and your code is easy to understand.
@koenv85
@koenv85 9 месяцев назад
Great video to spark the comments. It is great to read all the comments to see the opinions and know what I can implement. It feels like a mix of very talented CSS people that everyone can learn from.
@SuatBarlak
@SuatBarlak 9 месяцев назад
Two things come to mind while watching this video. I sometimes use the same class to boost its specificity : " .clr-purple.clr-purple".. and also the fakt that you can override an important with a id-Selector. "#content .classname" -> overrides ".classname"-Selector if both use important, even if ".classname" came first.
@Allformyequine
@Allformyequine 9 месяцев назад
Mobile first ... I think for sure depends on the project or even the 'section' great video!
@cataleast
@cataleast 9 месяцев назад
I tend to reach for !important when I'm overriding some CMS-related stuff, like some WP plugin styling or hiding a hardcoded theme element, etc. It's almost always a choice between a quick botch vs. diving into PHP for half an hour :)
@DarKcS2
@DarKcS2 9 месяцев назад
Wordpress themes and plugins :@
@ffpg2003
@ffpg2003 9 месяцев назад
I feel you😂, overwriting wordpress styles is sadly most of the time impossible, without using !important
@WyzrdCat
@WyzrdCat 9 месяцев назад
Yeah overwriting others' bad css and bad markup choices is mainly only time I ever need it
@thought-provoker
@thought-provoker 9 месяцев назад
Yup. It gets funny when the framework already comes with !important styles on basic elements ...
@WyzrdCat
@WyzrdCat 9 месяцев назад
@@thought-provoker uninstalled at that point. If they are doing that with css I shudder to think what's going on under the hood
@lesalmin
@lesalmin 9 месяцев назад
As long as you're working alone with your very own project you can do pretty much whatever you want. When you work as a team member where (for example) one person is responsible for html, another for css and third one for javascript it's good to have common rules for using id:s, classes and data-attributes. One solution is to dedicate id:s for html, classes for css and data-attributes for javascript.
@Matthew1234567890m
@Matthew1234567890m 9 месяцев назад
honestly i nest all the time while using scss haven't run into issues with it either but i know i could, that being said i recently switched to tailwind with react for my own projects don't want do think of class names all the time :D Regarding the media query while i think it can make sense to go for desktop first it seems odd to mix and match it since you would have to adjust your thinking depending on what you're working on. But i haven't worked on any real project or large on either
@tonytony-hz1cg
@tonytony-hz1cg 9 месяцев назад
Hey Kevin. Can you make more video of best practices.
@CodingAbroad
@CodingAbroad 9 месяцев назад
Is there a way to style an element that has position: sticky BUT only apply those styles once it’s anchored and scrolling down the page with the user?
@sarcasm_emoji3070
@sarcasm_emoji3070 9 месяцев назад
Is it recommended to use :nth-of-type when selecting one of the two/three nav's for example? Just to avoid using classes or id's. Provided that there are no more than three of course. Or perhaps it also helps when accessing the DOM???
@user-iq3qu2wo2s
@user-iq3qu2wo2s 9 месяцев назад
Can you do tailwind.css trick for css professional as it is sometimes needed in project
@shoelaced
@shoelaced 9 месяцев назад
How do you get backdrop-filter to work smoothly?? I've never once been able to figure out how to use it without janky scrolling.
@Zirpho
@Zirpho 9 месяцев назад
I've recently found !important useful in combination with custom properties for ensuring consistent styles when working against highly specific styles added by third parties. E.g. woocommerce has lots of very specific styles for various buttons. I want all buttons to look the same so... .button { color: var(--btn-clr) !important; background-color: var(--btn-bg) !important; } I have full control of the button colors, and I'm able to adjust them without more !importants. ( I'm pretty sure you can pick the woo button colors in customiser, but the method still has its uses )
@dgenerationx5220
@dgenerationx5220 9 месяцев назад
Please do video on popover and anchor
@KevinPowell
@KevinPowell 9 месяцев назад
Waiting for better browser support before I make a video on them :)
@akashinigami9284
@akashinigami9284 9 месяцев назад
Kevin, if I may ask how did you come up with the numbers you used for clamp there? or maybe a better question is, how did you first learn how to use calculations for font/color-styling? cause even though I think I'm quite comfy with css since I started coding 1.5 years ago, I still have no idea how to implement those kind of calculations for styling purposes.
@aCitizenJOSerased
@aCitizenJOSerased 9 месяцев назад
In the same manner, I don't quite grasp the use of ems in the media queries, as well. Would love to know more.
@lord_kh4n
@lord_kh4n 9 месяцев назад
Hey Kevin, informative video as always! Do you think it's ok if to go production with Dynamic viewport units right now?
@jshstuff
@jshstuff 9 месяцев назад
I’ve been using dvh in production but if I do I just add a fallback using vh because support is still meh
@KevinPowell
@KevinPowell 9 месяцев назад
I'd use them with a fallback right now. The majority of iPhone users are still on versions that don't support it, and that's usually the most common use case.
@Tiger1AuasfE
@Tiger1AuasfE 9 месяцев назад
Nice video.
@calle90
@calle90 9 месяцев назад
What is this for a font-Family?
@TheThirdWorldCitizen
@TheThirdWorldCitizen 9 месяцев назад
I mostly work with various forums software so I’m an avid advocate of desktop first.
@shaunpatrick8345
@shaunpatrick8345 8 месяцев назад
Why do you assign classes to the Nav elements instead of selecting them by "header nav" and "footer nav"?
@billyhick5738
@billyhick5738 9 месяцев назад
About the mobile-first approach - I tend not to think about it as "adding complexity" (although it frequently is), but as more of a "what layout works for the most devices". I agree that a hamburger menu is definitely more complex than a simple navigation menu, but what if, due to a weird aspect ratio/pixel count on a few mobile devices, your media query doesn't trigger? Now your mobile users are stuck using a desktop menu that doesn't work for them - whereas if the same thing happens with min-width, so a tablet gets misidentifed as a phone, or a laptop as a tablet, sure, the layout might be less intuitive for the device type, but it still works. Is that not better? Just a thought!
@KevinPowell
@KevinPowell 9 месяцев назад
Either way around, min- or max- wouldn't change anything in when it gets triggered though, but if you went min-width only, you're over-writing a lot more styles to "reset" things back to how they were
@judyodiakose6838
@judyodiakose6838 9 месяцев назад
For me, mobile-first is not a thing. I actually do my styling based on the projects. It could be the other way around: a bigger screen first, then a laptop and then a mobile phone. I did a project where I had more elements to add on desktop designs. What do you think? Another issue I had recently on a project was, not being able to overwrite a reset I did in my boilerplate.scss. I did the reset with an element selector with an element selector which has a specificity of 001. I tried to overwrite the reset using an element selector and a class which has a specificity of 011 and it didn't work.
@SuperGylden
@SuperGylden 9 месяцев назад
Wouldn't it be possible to just addressing nav by using "header nav" and "footer nav" as you are already using the semantic mark-up and therefore not having to use class="xx?
@KevinPowell
@KevinPowell 9 месяцев назад
It would be, yup!
@Danachew
@Danachew 9 месяцев назад
I personally still used Id's, but I would say it's more out of habit from what was drilled into me in school than anything else. Single occurrence of a specific element on a page = gets an Id. Multiple occurrences of an element on a page = gets a class. I will say the place that practice tended to run aground later in my coding work was styling dynamically generated content. Like for example a displayed list of article posts. It had to go from "Well there's only *one* title to this article so it gets an Id!" to "This block of code is going to be used several times, even though it's here once in my template."
@dealloc
@dealloc 9 месяцев назад
A mistake I see often is people tend to forget that classes are composable-you can use multiple classes for a single element and scope them. If you keep them small enough you avoid the cascading issues that you didn't intend. I often use classes as a way to define variants of a given base class for reusable components. Say for a button, I could have a base class `.Button` and define variants to changing its appearance based on preference and state; e.g. For size I'd have a `.Button.size-5` that sets properties that changes it size (paddings, font-size, dimensions), A `.Button.purple` that changes its background, foreground and any SVG fills to a specific color scheme (as well for its states) and `.Button.state-loading` for custom states that overrides the previous ones. This also works really well with :where selectors, for selecting, say dark mode class from its nearest ancestor, as well as for states, like `:where(:hover,[data-state=open])`.
@robertbutcher222
@robertbutcher222 9 месяцев назад
Another best practice I’ve heard of awhile ago, though haven’t used for awhile, is putting the styles under each selector in alphabetical order. Unless there’s a vscode extension for this, it seems like it could waste time. Or is this actually a good best practice? If so, is there a vscode extension for this?
@KevinPowell
@KevinPowell 9 месяцев назад
You can use a linter to do that. I personally hate it, and most people I know who write a lot of CSS do as well. The two main arguments I've heard are that it's easier to prevent duplicate properties declaring different things (but even VS code's default linting can catch that), and that if you are going to make a change, it's easier to find something that way, which I don't really get either. I like grouping relate things together, I want position absolute with my top, bottom, left, and right, for example.
@WyzrdCat
@WyzrdCat 9 месяцев назад
Oh my god, that sounds AWFUL. why would anyone ever do that >_< put them logically next to things they are used with, which mostly happens naturally! Alphabetical would be a nightmare!
@espertalhao041
@espertalhao041 9 месяцев назад
I would just avoid using em and rem in media-queries. According to MDN, it will always be calculated from 16px, regardless of the font size. However, it can be extremely confusing for a beginner because they expect it to change based on the font size.
@carradee
@carradee 8 месяцев назад
I usually tweak prebuilt themes for clients, and I often facepalm over how much of the code is patching problems created by the approach in the first place. I've preferred using element selectors for setting root defaults (for mobile *and* desktop), then cascading from there as pertinent since I started nigh 2 decades ago. Sounds like we take the same approach, just describe it differently. :)
@okaniyoshiii9212
@okaniyoshiii9212 9 месяцев назад
Class selectors for everything is a bad idea for me, I prefer your approach where you do some kind of hybrid between class selectors and descendant selectors. That's how I'm working too and I feel this is better because sometimes I don't have to think about how to name everything and loose time just for that. Instead I can just add a class on a container like nav, ul or div and then use element selectors to achieve my goal. For ID selectors, I think this is a good practice to not use it everywhere. This is because when you see and id selector in a stylesheet you can understand that this has been used maybe to create a link using the "#" or maybe this is used to create some interactivity with the :active pseudo class. I mean, if someone use the id selector only once or twice in a stylesheet, you can guess that this is for another reason than just rising specificity so this can sometimes help to understand how a system in the site is working. I never use "em" unit because I feel a little bit uncomfortable with it but this seems to be very useful in some case like you said. Your advices about "mobile first" are great ! I've made a little project today where the mobile version was very simple et the desktop version was very complicated and I've the desktop version first ... WHAT A BAD IDEA ! 3 media querries, a lot of "!important" and a lot of problems with specificity in general ... Starting by the simpliest version and then adding more complexity is a very good advice so thanks for that. The !important is a nightmare for me. I'm working with Wordpress and the other developpers have used "!important" everywhere and now it's a real nightmare ! I should refactor the code but I can't do it alone so I have to throw "!important" everywhere too :/ So yeah, don't use "!important", please ! x) Thanks for this video ! It was very interesting :D Unfortunately I don't have any other best practice to share ^^'
@jamesparson2476
@jamesparson2476 3 месяца назад
Mobile first as popularised by the famous book on responsive design, doesn't prescribe code organisation or style. The author was only saying think about the mobile version before thinking about the desktop version.
@chakirilyass8721
@chakirilyass8721 9 месяцев назад
Best kevin Ever
@greatgreatness896
@greatgreatness896 9 месяцев назад
Hey Powell, am a newbie in programming and web development, please what path would u advise me to follow (backend or frontend). Any suggestions will be highly appreciated.
@KevinPowell
@KevinPowell 9 месяцев назад
Depends what you like to do 🤷 - Try both out, see what you like better?
@ciroseijas8529
@ciroseijas8529 9 месяцев назад
@@KevinPowellGOAT
@WyzrdCat
@WyzrdCat 9 месяцев назад
Backend and front end are less and less separate these days. Firstly definitely learn CSS and HTML and JS fairly well and build things with them before moving on to frameworks.
@kaosce
@kaosce 9 месяцев назад
I would recommend only HTML first (to understand how a web page is working), then add CSS to beautify things. Only these two first because they are the most visual and so the most fun for most beginner. Only after, learn JS. Learning JS after CSS would also prevent you from making beginner mistakes of doing anything interactive with JS where CSS should be used. If you want to add a backend you could probably go for Next or any JS to not have to learn a new language (this one still has React). I personally prefer Django but it's in Python
@JimKernix
@JimKernix 9 месяцев назад
Why is raising the specificity of a nav with an id a problem? What exactly are you doing with the styling and at what point will you change something that won't take effect because of the specificity?
@KevinPowell
@KevinPowell 9 месяцев назад
Most of the problems I've seen with ID selectors are on larger teams where several people are working on a project, and the person who uses it is too focused on the small thing they are responsible for. Either causes issues with re-use, (like styling a tab component with an ID, when you might need several on the page), or with specificity, mostly because the project grows and they need modifier or different versions and the ID starts getting in the way. On smaller projects, other than silly mistakes, they're rarely an issue
@JimKernix
@JimKernix 9 месяцев назад
@@KevinPowell Ok, got it
@vladislavivanov1546
@vladislavivanov1546 9 месяцев назад
Never saw this clamp function. Can anyone explain to me what is used for?
@KevinPowell
@KevinPowell 9 месяцев назад
Allows you to have minimum size, an ideal size (in something that can change, like viewport units), and a maximum size. Basically, you have a size that changes, like a percent or viewport unit, but that has a min and max size "clamping" it
@foxoninetails_
@foxoninetails_ 8 месяцев назад
It's useful to think of !important as an "escape hatch". It's there in case you really need it, but it's a last resort, not a general-purpose tool; you should only resort to using !important when you don't have another reasonable choice.
@svenyboyyt2304
@svenyboyyt2304 9 месяцев назад
The link for CSS Demystified isn't being displayed correctly on mobile
@KevinPowell
@KevinPowell 9 месяцев назад
What's the problem? I just tested and it looked okay?
@aCitizenJOSerased
@aCitizenJOSerased 9 месяцев назад
A very nice video, but oh my, this comment section is a pleasure to read!
@noabald
@noabald 9 месяцев назад
When I find myself with no choice but to select an id, I usually use the attribute selector [id=“”]
@dripcaraybbx
@dripcaraybbx 9 месяцев назад
Instead of .primary-navigation or .footer-nav, why not `header nav` and `footer nav` with just compound element selectors?
@KevinPowell
@KevinPowell 9 месяцев назад
That would work as well :D
@82TheKnocKY
@82TheKnocKY 9 месяцев назад
Mobile first in my opinion doesn't make sense if you're going for a website that's going to be primarily viewed on desktop An admin site or a website that's super artistic.
@mahadevovnl
@mahadevovnl 9 месяцев назад
I dislike that [data-attribute] selectors in CSS seem to have a higher specificity than just class-names. It renders them kinda useless as soft-selectors... Is there a way around this?
@nilaallj
@nilaallj 9 месяцев назад
Attribute selectors have the same specificity as ordinary class selectors, so there must be something else that causes your issue.
@sawzarnilinhtay5551
@sawzarnilinhtay5551 9 месяцев назад
sir, is ur course at udemy??
@KevinPowell
@KevinPowell 9 месяцев назад
No, I don't have any courses on Udemy
@herashak
@herashak 9 месяцев назад
why does Kevin remind me on my dentist more than my dentist
@GiorgiKavtaradze-cy1ye
@GiorgiKavtaradze-cy1ye 9 месяцев назад
👏👍
@gge6021
@gge6021 9 месяцев назад
essentially. Just use tailwind
@rrd_webmania
@rrd_webmania 9 месяцев назад
I hardly ever use css classes. Perhaps vuejs components does not really need them Here I would use header nav and footer nav
@oliver139
@oliver139 9 месяцев назад
That's why I don't understand why people saying Mobile First😂
@Kaptain-T
@Kaptain-T 9 месяцев назад
Almost the first to comment😊
@JlHAD
@JlHAD 9 месяцев назад
I’m strongly against mobile first practice it just doesn’t make sense and web is much easier to develop first and then modify for mobile
@oubaidaawaw7271
@oubaidaawaw7271 9 месяцев назад
why no translate
@ukyo6195
@ukyo6195 9 месяцев назад
!important is important to get the job done. 😂
@bahrambarazandeh3716
@bahrambarazandeh3716 9 месяцев назад
How much do you talk!!! Explain the main topic! All your videos are like this! You make people tired!
@ludanjubara
@ludanjubara 9 месяцев назад
You have to cut your videos to 6-10min.. these are just way too long.
@KevinPowell
@KevinPowell 9 месяцев назад
At this point, it is what it is 😅. I've worked at being more concise and I've improved, but a topic takes as long as it takes. I'm sure I could shave them down more, but it's how I like to present stuff, so most are in this range, with some occasional ones that are shorter and others that are longer 🙂