 Hi there my friend and friends. There were a lot of amazing things that were added to CSS this year and actually while I was recording and researching for this video I just kept coming across things and being like oh yeah that was added this year or wow this feature has better browser support than I thought it would and I can't lie it's a really good time to have a YouTube channel that's dedicated to CSS. Now I'm making this video because I'm always asked about how I keep up with all of the new features that are coming to CSS so I figured this would be a nice way to highlight a lot of the new things for everyone to look forward to as we move into the next year and also highlight some features that might have better browser support than you might realize. As we dive into this I just want to say that it is very possible that I do miss a few features along the way here but if I do miss any of the ones that you're excited about please let me know in the comments so that I can highlight them the next time I do one of these updates because going forward I'd like to do one of these updates probably every quarter as long as there's enough to talk about each one and I think there will be just because of how fast CSS is expanding and growing. Also any of the browser support numbers that I do are of the time of recording this so you can check the date when this was published and they're all based on can I use global numbers if you have access to your own sites analytics those are always the best things to check and if you're watching this at any point in the future you might want to check what the actual browser support numbers are using can I use and we might as well finally jump into the first thing that I want to talk about which is nesting which first gained support in chrome in april of this year and has since gained support from both safari and firefox as well nesting allows us to well nest selectors inside of other ones like we've always been able to do with preprocessors like sass and less but there are a few little differences between them but some of those differences are actually being reduced because there is a new more relaxed syntax that only firefox supports right now but that is on the way for both safari and chrome as well and if you don't know what nesting is at all you can see right here that don't reveal my grid template columns and rows you can see here I have this hero grid and inside of there I have a nested media query with all the styles I want for that and then even in here I have this button selector in my page title selector that are nested within my hero text the syntax highlighting is a little bit off just because vs code maybe there's something I could add here that would help out I'm not sure I haven't looked but I'm fine with it not looking fantastic but the main thing is it's just really nice to do and I'd love being able to nest media queries it's by far the my favorite thing so I don't have to put my hero grid again I can just put the media query and keep going from there and for me I think one of the most exciting things about nesting is we have a feature that was added first just this past April and it's already supported by the three browser engines and it currently has over 80 percent support when we use the original syntax which is absolutely just wild and if you use the the current syntax or the the original syntax of it and you know as the browsers gain support for the newer syntax the older stuff still works it's just it's less strict than it used to be I'm not going to dive into it too much in this one you can look into it a bit if you want to know the difference between the two but it basically you can just do an element selector nested without a symbol in front of it going forward and moving on to another feature that has even better browser support is the has pseudo selector I think is what we call it which is coming in at a shade under 90 percent support and the main reason I actually wanted to talk about this because it's been around for a little while it wasn't introduced this year but Firefox is finally getting support for it with version 121 and I love has so much it opens up so many new things that were never possible before in CSS just really fast here is like one example that I like to look at here I have my cards and I might have this media inside of it but like normally my card actually I don't think I need that here normally my card would have some padding on it and so what I could do is if my card let's go find it if my card has a dot media we're going over to a display grid and setting up two columns and the rest of the time we don't have that and other things too you can play with your padding depending on stuff but you know we're saying if my card has this as a child or not even a direct child but if it has this media thing in here then we're just going to say okay now we're changing how this element is working so great and there's so many really other awesome stuff you can do with it I've covered this in videos before I'll link to those in the description and most of the things I'm talking about in this video I have done videos on so if there's something you do want to learn more about check the description and you should find a link either to a video I've done and if I don't have a video I'll link off to another resource instead yeah it's really exciting to see how with has being in all three browsers now and it's a sort of gradually inching up higher and higher in the browser support tables really really awesome to see but up next we're going to look at another one which is text wrap balance which was first added to chrome in May of this year and quickly followed by safari in June sadly firefox doesn't actually support it yet but it's a very nice progressive enhancement as it's primarily to prevent like issues in our text or actually let's just take a look because I think it'd be easier to explain so here we have this where you can see that this is a demo by the chrome for developers blog they put together which is nice and handy and here we have the on balance text and here is with the balance text so it's mostly for headlines or headings the short bits of text I think it only works if you have two to three lines of text and after that it has no impact but it just balances text out to prevent the bottom you know for having two lines on a headline that are unbalanced and you know if a browser doesn't support it they just get this version so nothing breaks it just it might look a little bit nicer if you're on a browser that does support it and the one that's maybe a little bit more exciting here is text wrap pretty which also by the same team they have another demo here where this is for longer pieces of text your paragraphs where you go three or more lines long where sometimes we get orphans and an orphan in typography is when you get this lonely little one single short word all by itself on its lonesome down there and if we turn on pretty balancing it just prevents an orphan from being there so nice and handy it won't be like perfect it's not going to do the balancing so the line will get super short to try and you know balance everything out the same way here where it makes a pretty big difference at times it's just going to make sure that there's no single word sitting all on its lonesome at the end of a paragraph now this is only supported by chrome which only landed in version 117 but I think it does a nice job and once again it's a really nice progressive enhancement and as more browsers get support for it you'll just have more and more users getting a slightly nicer experience so it's just one of those sort of like things you can throw in there as part of a reset it's going to work and you don't really have to worry about it too much after that and slowly over time more and more people will get that better experience next up we're going to talk a little bit about color mix which is I'm going to count it as a new feature for 2023 even though safari started supporting it back in 2022 because it only gained support about halfway through december of that year in safari and it was followed by chrome adding it in march and firefox adding it in may and now with all three browser engines having support for it color mix is already at about 85 percent support which is incredible for such a new feature and just a really fast look at how this one works it's basically you can mix two colors I have a purple here and a cyan here and then my one in the middle I'm just doing a color mix and I'm mixing my color one and my color two and now there are a few things that are a little bit strange but you have to you do have to choose what color mode you're mixing with and that will actually change the result as you can see there and there is a shorter and longer thing that's even a little bit different so here if I did if I switch shorter to longer we'll see that I think yeah we go the other way around the circle anyway it can be a little bit funky but it's actually a really powerful feature that can be really useful for color schemes and everything so definitely worth checking out and while we're on the topic of colors and here I put in lch both lab and lch gained support in safari way back in september of 2021 but they only landed in chrome and firefox this year and lch here is for lightness chroma and hue and because hue is one of the things here one of the ones that we can play with it's a little bit similar to hsl where it's easy to know what color you're getting but it has the added benefit where it lines up better with human perception and so if I go with this like sort of washed out yellow I think it's a nice example because as I go through the hue here you can see it's always sort of like the same we're getting a few fallbacks but don't worry but we're getting sort of the same level of color if you want to say whereas if I can pair that to hsl which is right here um if I'm and here's the final output so let's get a really saturated color and as we go through here like the blue is actually kind of dark and then as we go into this like that's really bright yellows tend to be really really bright and then as soon as you get to the orange it's sort of darker again so lch in terms of just shifting through the hue gives you much more uniform results and it's much more as I said in line with human perception the problem with lch is it's a little bit weird to use because you have to deal with the chroma and there's it has to do with how color models work and you know where the what colors are actually available to see um and what our monitors can actually output but let's say I go into like a very high lightness so we're going bright I can actually get into like this really bright green over here so you know uh let's go right there I get this really bright I'm gonna even go a bit more this way there we go I can get this like super vibrant really bright green but the problem is I have a really small window where I have this lightness chroma uh yeah this lightness and chroma that are available because as soon as I go out of that like there there is no greens and like if I go into the blues they don't exist within this color model so it all of a sudden that hue that was really easy to follow it becomes a little bit trickier because I just don't have a blue in there and then the opposite as I go darker my blues uh and we actually darker not darker is it darker I see this is well here as I'm going through the lightness you can see the chroma that's what I was thinking but as I go through the lightness the chroma shifts and it's more the purples I was thinking um so here the purples in this area has this like huge range of chroma available that's only in a few of the different colors and or hues and and stuff so you can see it's a little bit weird in that sense um and definitely takes a little bit of playing around with maybe to get the colors you want and I was hoping it would be easier to use there's definitely some tricks to LCH but I'm still really happy that we have it because it actually does open up more colors than are available uh if then if you're using HSL and RGB the other thing is you have LCH and OK LCH and I would actually recommend using the OK LCH version you're just going to get a little bit more consistency with your colors and everything along the way so just there is those two and you also have the lab as I said you probably aren't going to use that so much for actually writing in colors but you might use it for when you're doing color mixes and you're mixing two colors you might be mixing it using lab or something like that and continuing on our trend of color functions that safari was the first to add we have relative colors as well which was only added in safari in march of this year followed by chrome just last month and well we're still waiting on firefox for this one and I won't lie this one looks really strange you can see here I have uh some css looking at it uh but it's really cool because what we can do is we can take a color and then I can choose something like HSL or RGB and I can actually change parts of it so I'm saying I want my color from so we're basing it on steel blue but I'm taking my H my S my L and then you know maybe I need it to be transparent I just do a 0.5 here and then I'm getting the 50 opacity on that color even though it's steel blue which is just a keyword cool right and this could be anything this could be an HSL an RGB a lab whatever you want any color could be here but then the next thing that's cool is I can also play around with these so I could say calc and I could just say I want my hue to be plus 100 and then it changes my hue it adds 100 to the hue that was steel blue if steel blue is an HSL or I can go to my saturation I can do calc and on the calc here let's say times 1.5 and it will become more saturated or I can say times 0.5 and it's going to become less saturated so this one definitely opens up a lot of possibilities but because it's not in Firefox yet and because chrome just added it support for it is below 50% right now but with chrome having added it in it should go up pretty fast from here now moving on to a feature that people were asking about for a really long time we have container queries which are about to hit 90% support and that also means they are in all of our browsers as well so let's take a look at this one I'm going to jump on over to this demo that I have set up and you can see this sidebar here where I have these items that are stacked on top of each other as this gets narrower at one point it runs out of room and it jumps underneath here and when it goes down below it has a lot more room and they stack one next or don't stack they go one next to each other instead of being stacked and then as we continue to go smaller in space everything stacks once again and this is all happening because I'm using a container query so if I come and I take a look in here let's zoom way in on my dev tools I have this container that's set up around there and then if I take a look at my ol that's right here it just has this display of grid right there but as we get more room for it you can see I have my container coming in so when the container so in this element the parent of my ol has a width of 35 or bigger I get my grid template columns coming in and it gives me three columns and what's nice about this is I'm not worrying about the viewport I'm worried about how much room this ol has to live in so if we go even bigger once again now even know we're at a larger viewport these are going and stacking again here because the parent doesn't have a lot of room if I was doing this with a media query I'd need one to say at this large screen size I need them to stack then I would need to worry about where my breakpoint is for this to switch match that breakpoint to make it go to three columns and then also come down and match whatever breakpoint this is to make it go back to the way it was before and now I don't have to worry about any of that I just say if it has enough room then it goes next to each other if it doesn't have enough room it stacks and that's it it's wonderful and this is just like a really simple example container queries or something we waited for for a long time everyone was excited they're here and we can see why they're just they're going to make our lives so much easier going forward and another feature that has even better browser support than that is cascade layers which now have over 93% support at the time of recording this and these allow us to create layers within our CSS at layer right there and this isn't something I've actually used a ton of even though I have done a demo or a video here on YouTube about them and it's just because I haven't really had a huge need for them but I do see their usefulness and now that support is getting better it might be something that I actually do start looking into a little bit more going forward and I recently did a survey and from the results of that one of the biggest complaints with CSS that people had was project maintenance and if that's the same for you you might want to look into how layers work because just as an example here I have these components that are set up so my layer of components if you see here I have my layout and then I have my components coming after that and so if I come and I look at my component right here I have my background set and my color set right here and this button if we come and look in my html is right here and it's a link within right here right I have these two links that are inside of my ul which are in my nav list this is just a dot button if I come down into my layout now I have this really high specificity selector changing the color of my links because I wanted those links to be this green color that we can see right here normally if we weren't using layers or if I change let's just change the order of these I can take layout off from here and put layout afterward which makes it more higher specificity you can see I've lost the text the text is still there it's just now that you know now that this selector is overwriting it so it's getting the color of lime green as my text color so this is so if we go back now we have even though this is a lower specificity selector and this is a really high specificity selector this one is winning because it's on what's considered the more important layer so this could be a really nice way to deal with project maintenance and not having to worry so much about specificity as much because you group things you have your reset maybe a framework your base layer your layout your utilities you organize them in the order that you want them to work and then they're just going to work every time your utilities could even be element selectors doesn't really make sense but if they were element selectors they would overwrite ID selectors coming from your components so it could be a nice way to improve the maintenance of your projects without having to worry so much about how other people are authoring their CSS as long as they're organizing it in the correct layer and now let's go on to the next one which is one that we're going to throw in here even though it gains support way back in March of 2022 which is the CSS trigonomic functions and it was safari once again that added them way back then but chrome and firefox only got around to them in march of this year but with all three of them on board they're already at over 88% support right now and i'm really not much of a math person at all but i've looked at them before i see how they can be really useful and other people that are much better at math like an attutor who put this video together highlights some of the amazing things we can do where all of the animation stuff that's happening here that used to have to rely on javascript now we can do with css we're just basically updating a couple of things here in the javascript but all of the styling stuff is done with css using trig if you need circles and animations around circles or anything like that it's it's exactly what you're looking for and if you know about how these things work better than i do you can probably already think of other things that they could be useful for as well and as we go through all of these things if you'd like to keep up with css but you'd like to do so on a more regular schedule than waiting for me to put out one of these videos every now and then i do also have a weekly newsletter where i share general advice as well as resources and interesting sites that i come across every week and also what i've been up to each week as well and if you don't want any other emails in your inbox you can also get it as a podcast or if you prefer a video you can get the same content over on my second youtube channel you can find links to all of those in the description below but back to the update there's no way i could go through an update like this one without talking about subgrid i've already made five videos on them and four of those videos i actually made in 2021 i've been championing for subgrid for so long now basically ever since firefox gained support for it back in 2019 so it feels a little bit funny to be doing a new features list for something that a browser supported for four years now but it only gained support within safari in the middle of last year and it only landed in chrome in september of this year it's super frustrating that it took this long but better late than never it does have only about 79 support right now thanks to chrome adopting it so recently but it should rise quickly from here and once again for a quick demo i actually used subgrid on this part of the same one we was doing a lot of new features here on this one and once again in the dev tools if i move my face out of the way you can see that we have a grid set up and then i have a subgrid set up and the reason i wanted to have a subgrid here is because i wanted this text to live across these two columns of the main grid but i didn't want this one to go outside of this part here and i could have done this without subgrid by having just not bothering with this hero text the problem then is you're sort of getting all of these extra rows that are being created on the main grid that i didn't want i wanted one row on my main grid uh so i just wanted a text box in there but then i needed this text to go out i didn't want to muck around with negative margins or weird stuff or having to come on this one and add a margin to it or something i just wanted that you know my button and my text here to fit the first column and this text to go across two and with subgrid i just tell the parent that you're going across two columns and this text goes on two and then this one goes on one and it just works it's it's fabulous uh and there's a lot of really good use cases for subgrid this one once again is a simple one but if you want to know more as i said i've done several videos on them and you can check for the links in the description uh to find out more because i'm in love with subgrid i'm so happy it's finally here and moving on to the next one it's actually something i've been keeping a close eye on for a really long time now and i actually do have a bit of content planned around it as well which should be coming out really soon either just before this or just after this video uh which is view transitions now sadly view transitions are only in chrome right now having been added in march of this year but it also goes to show you the dominance that chrome has on the market as it already has over 66 percent browser support and there's actually two different parts to view transitions one of them that's the currently supported thing by chrome at the moment is for making it easy to transition things when you update your dom on a single page so you have a bit of javascript make a change you know you click a button you update the dom and then you can just have a transition from the old state to the new state super simply the more impressive thing though which is only behind a flag in chrome right now allows for transitions between pages making multi page sites feel like single page apps and astro has actually completely leaned into this in a very big way and i absolutely love this demo that they put together for it so not only have they leaned into it but they've also built in um you know a polyfill into the system so even though i don't have it enabled in my flags right now it works and so this is a multi page site you can see that this image if i go back the image you know i click this one the image transitions over isn't that just amazing and this is a multi page site as i go through these if it's playing what if i go back and it's still playing down here at the bottom as well um not sure how the music part of it down here works but just this transition is so nice they've put together several demos this one's like a really simple one but it just shows that you can have something animate across makes it feel much more just amazing and you can do other transitions than this you can just have the whole page fade like cross fade from one thing to the other but it's all the ones where like the titles and other stuff like move from one place to the other that makes it feel much more just immersive and much more like an spa and something i'm really looking forward to gaining more browser support and sticking with animation related things i recently took a look at how we can use the new animation timeline with the scroll function to make a css only parallax which we can see right here and so you just scroll down you can see like all these different pieces are moving at different speeds which is really really awesome and we can pull the code for that one up i have it right here off screen and so just looking we can see that i'm all i'm really doing is this animation timeline of scroll so i put animation i give it a name uh the animation is just transitioning stuff up and down and i have a scroll on there and it works and so you can just link your animations to scroll without having to use javascript which is just really nice uh and in this video i sort of just scratched the surface of what we can do with it i do have plans to do a much bigger deep dive on everything about it coming up at one point in the not too distant future now as for support for this it is only in chrome right now and it's about 65 percent support uh although it is behind a flag in fire fox as well and for me for some reason this is one of those features that doesn't seem to be getting enough attention yet as i really think it's going to make a lot of really complex animations a heck of a lot easier and getting you know these ones are only supported in chrome and getting even more into the cutting edge we have scoped css which just landed with chrome 118 at the beginning of october and scope has been something or a feature that people have wanted as part of css for a really long time now and it's finally starting to become a reality and scope is really interesting and just as a really quick example here if we take a look uh here we have a class of title a class of title and a class of title on all three of the headings here and so if i came in and i said my title is color lime green for some reason obviously they would all become lime green but maybe you only want to affect the ones that are inside of an article and nothing else now of course we could say that this is my article and then choose my dot title that way but we do have more options than that so what we can do instead is here i can do an at scope and we can say scope for my article and then we're going to select all of that and we're almost there there we go uh you can see that it is working and we're only selecting our titles that are inside of the article but even more interesting than that is you can choose where your scope is starting and finishing and all i have to do is here where i have my at scope i can just write two and then i write where i want the scope to finish so in this case i want anything that's inside an article but i don't want it to affect my email sign up so i just say to email sign up and by doing that you can see that we've styled this one but we're not selecting anything that's here and let's just come and we'll copy this and we'll paste it down here so we're still in my article we'll close that paragraph off and you can see this is still getting styled here so we're staying as long as we're inside the scope of the title it's working but if we reach an email sign up that styling won't actually bleed off and go into the email sign up but it will work anywhere else so it's a really interesting thing that i think might look a little bit weird it's going to take some proper planning to use it correctly but it allows us to scope our styles to use them in specific areas and i think it's going to be really powerful and something we start seeing more and more often once browser support for it starts to increase shifting gears a little bit we have a simpler feature which is user valid and user invalid and these are two pseudo classes that have been supported by firefox since 2021 but only landed in safari back in may and in chrome this month which is november they're actually very similar to valid and invalid which you're probably already familiar with but here's a very quick example where we just have this form element and so because it's a type of email and there's nothing that means it's invalid which is really annoying but as soon as i come in here and let's just say i do like i put in something it's still saying it's invalid which is correct but as soon as we turn that into an at something.com now it's a valid one this one down here instead of using the invalid i'm using user invalid and what that means is it's waiting for the user to interact with it before it decides whether it's actually invalid or not and this makes so much more sense right so we have an email field it's a required field we need them to put an email address in if i click in and click out i haven't really interacted with it yet i haven't done anything with that field so it goes okay whatever we're going to leave it but as soon as we come in and we put in in my email address and.com well it's completely fine but if i stopped here now it's saying that it's invalid i've started to input something i left the field i didn't fill it out the way i needed it to and we're getting the error there and of course this isn't perfect you still want to be doing server side validation and stuff but you could even have it this checking using regex and other things to make sure you're getting much better matches here or if you need passwords that have certain requirements and stuff just for a really simple invalid like user invalid and styling it up that way you know that could be really helpful but again don't rely on this instead of server side validation this is just to make sure that you're getting through this first step and it just makes it so much easier to style and is so much better than using the invalid version and one other new feature that i'm really really looking forward to is the text box trim and it also it's text box trim and text box edge and this is a really fun one even though it's supported by zero percent of all browsers now i thought it would be a good one to talk about first of all because it's coming it is in this safari technical preview right now and it's something that i've been waiting for for a really long time this article here came out in 2020 to sort of talk about the idea behind it uh ethan weing here has been championing this for a long time and even i sat in on a meeting with ethan and some others as part of the working group that was going over the inline element spec which this included and it's something i really hope actually becomes a thing and basically if you come in and like select text you know there's like that extra space on the top and the bottom and this can be really annoying if you have a button and then you put padding on the top and bottom of the button sometimes the padding on the top and bottom is not the same because when you have your text selected the height of the text is different on the top and the bottom right and this really depends on on the text itself we'll probably see it even look at all that extra space on the top and there's not very much on the bottom when you take the descenders into account on this font and it's different for every font too the idea originally was going to be letting trim from what i understand that's now our text box trim and text box edge where we define the edge and then we can trim to that edge and basically it lets us like slice off that extra space and there's a nice example here where you might have some setup like this and you have a gap of 32 pixels on your grid but the problem is because of that extra spacing you actually end up with 39 on the top and 42 on the bottom even though you wanted 32 on both and you define 32 on both you got a lot more with this feature let's go away medium with this feature we're going to be able to like slice off that extra all all these extra pieces of that text and just line things up exactly where we're going to want to and it's something like i said that i've been waiting around for for so long now and i'm happy to see a browser finally making some progress on it and that was a really big update and i'm sure i've missed out on a few things along the way here so if there was a feature i didn't mention that you're really looking forward to and you'd like me to talk about in a future video please leave a comment down below and let me know about it once again if there was any features along the way that you're interested in there should be a ton of links down below this video and with that i would like to thank my neighbors of awesome johnny tim simon andrew and web on demand as well as all of my other patrons for their monthly support and of course until next time don't forget to make your corner of the internet just a little bit more awesome