new course
CSS grid landing page tutorial (36min)

Lesson info

Lesson info

Making manual style changes to each and every element is tedious and time-consuming. And entering repetitive values for hours and then trying to update those values one by one can be frustrating. Classes save styling information that you can apply to as many elements as you want throughout your project. 

Here we’ll cover:

  1. ‍Creating classes
  2. ‍Applying classes
  3. ‍Editing classes
  4. ‍Creating class variants by duplicating classes or by adding combo classes

Explore this project

Want to dig into the project featured in this video and see how everything is put together? We've included the full project we used when making this lesson, and we've shared the link right under this very paragraph.

View and clone this projectDownload lesson assets
Clone this projectDownload project assets


Making manual style changes to each and every element is a pain. It takes a ton of time to enter repetitive values, and once you've done that, changes to those values can seem even more frustrating. Classes contain styling information, and you can apply these classes to as many elements as you want throughout your project.

We have three things to cover here — really straightforward: creating classes, applying classes, and editing classes. Let's create a class.

Now this page has a number of sections, and each section has a heading inside at the top. These headings have been dragged right in — nothing has been applied — nothing has been styled. So we're styling from scratch.

With our element selected, we can begin styling right away. We can make changes to our layout like margin. We can adjust typography — maybe choose a different font or adjust the font color. We can adjust all sorts of style values.

The big takeaway here is that the moment we began styling, a class was automatically created. And when we intend to reuse (or even just organize) this class, we can double click it to rename. Let's call this Best Heading Ever. And you can call it whatever you want.

As an alternative, you can select any element that doesn't have a class applied, and instead of styling first, you can actually start by clicking in and naming a new class.

That's creating classes.

Applying classes is where things start to get interesting. Now we can see inside our Selector field that this element — this heading — has the Best Heading Ever class applied. But right now, this is the only element that's using that class.

So let's go down to another heading and select that one. And if we click inside our Selector field, we can type in Best Heading Ever. Hit Enter. And the class has been applied.

Let's do it again to this heading. This time, we can see the class name appears as we start typing it out, so we can use the keyboard arrows or the mouse to select our class.

Now what if an element already has a class? Here's a heading which already seems to have a different class listed in the Selector field. If we hover over and click on the down arrow, we can remove that class. And just the like the others, we can click inside and apply our Best Heading Ever class.

That's applying classes.

Finally, let's edit our classes.

Once a class has been created, we can select any element that's using our Best Heading Ever class.

When we go in and make a change, that change affects all instances where that class is used throughout the project. No more manually changing each and every tiny detail. You do it once. Classes do the heavy lifting.

And if we want to rename our class? Maybe it deserves a promotion? Again, just double-click, and type the new name. This will change the name of the class throughout the project.

So, we can create classes which contain all our style information. We can apply classes to as many elements as we'd like. And of course, we can edit the styling on these classes, and those changes will affect the styling on each and every element that's using that class.