Defining a few items at the same time
Many times you will find yourself creating the same rules to more than one item. You might ask yourself is there a way to combine the rules to more than one item? The answer is yes and we will see how to get it done in this lecture. By the end of this lecture you will know how to define rules for multiple CSS selector rules at the same time.
Video Transcript
00:00We now know how to travel through a document.
00:03We know all the different selector rules,
00:05but then the question will arise to you
00:07once you start manipulating CSSs.
00:09You'll notice that many times you'll wanna create
00:12the same rules to multiple elements or to multiple rules.
00:16What do you do in that case?
00:17And that's exactly the topic of this lecture.
00:20We're gonna learn how could you define rules
00:22to multiple classes or multiple,
00:24whatever selector rules at the same time.
00:27So let's see it.
00:28Short, but as always incredibly important,
00:31I wanna talk about another CSS rule
00:34or really about how to batch rules together.
00:37For example, in this case, our footer rule
00:40of this background, width, and padding
00:42might be very relevant also for our article.
00:45Now, if I wanted also these rules
00:47to be applied to my article, which I don't by the way,
00:50what I really want is I maybe want this,
00:52but I also want my article itself
00:54to have maybe a different color.
00:56So what I could do is go ahead
00:58and just set that, take that article,
01:01add it into my element here
01:03and just complete it with a comma and a space.
01:08Now this comma, what it does, it says,
01:09hey, I want this item and this item to have these rules.
01:12Now, the only really critical thing here
01:14is I wanna also make sure that my article
01:16gets overridden after that
01:18and has its own rule on top of it as well.
01:21Now, in a realistic scenario,
01:23I probably wouldn't wanna do it this way
01:25and we'll talk about that in the next lecture,
01:27but it's really important for you to know
01:28that you could add and batch together rules,
01:31a lot of rules at the same time
01:32if you wanted to or needed to.
01:34Now, what I'm gonna do is go ahead here
01:37into my browser and click on refresh
01:38and you're gonna see that now,
01:39oh, to my item, both of my items have the width
01:42and the full gamut, the full space of our application,
01:47both our article, which is our red element,
01:49and our footer, which is this darker browner type of color.
01:55Now, without further ado,
01:56I'm gonna go on to the next topic in the next lecture,
01:58which really talks about performance.
02:01Although we're really early on in our development,
02:03it's a really good idea for us to talk about best practices
02:06at this stage,
02:07because it's gonna save us a lot of hardship.
02:09And when I'm talking about hardship,
02:10I'm talking about making our websites perform
02:13as best as we can.
02:14And when it comes to CSS, less copy, less text,
02:18better performance, and less overriding rules in general,
02:22better performance in general.
02:24So we're gonna talk about that in the next lecture
02:26immediately following this one.
