🚨 Heads up! This course is no longer supported. We recommend checking out our Webflow Essentials course.
How to make a CSS Class
Questions
Student Gallery
Be the first to share something.
Course info
Overview
- You'll need a laptop (Mac or PC)
- Dreamweaver CC installed. Dreamweaver can be downloaded from theAdobe website here.
Can I use this tutorial with Adobe Dreamweaver CS4, CS5 or CS6?
Daniel Scott
Founder of Bring Your Own Laptop & Chief Instructor
I discovered the world of design as an art student when I stumbled upon a lab full of green & blue iMac G3’s. My initial curiosity around using the computer to create ‘art’ developed into a full-blown passion, eventually leading me to become a digital designer and founder of Bring Your Own Laptop.
Sharing and teaching are a huge part of who I am. As a certified Adobe instructor, I've had the honor of winning multiple Adobe teaching awards at their annual MAX conference. I see Bring Your Own Laptop as the supportive community I wished for when I was first starting out and intimidated by design. Through teaching, I hope to bring others along for the ride and empower my students to bring their stories, labors of love, and art into the world.
True to my Kiwi roots, I've lived in many places, and currently, I reside in Ireland with my wife and kids.
Downloads & Exercise files
Transcript
Okay. You can see the names of them there. So these are, these are the selectors. We, in a previous tutorial looked at styling what is called a tag, and that includes things like your H one, your H two, your P tags. And we looked at the A tag, which is your hyperlink. So those are tags.
So we're gonna style a different kind of selector now. So instead of this tags, we're gonna look at what's called a class selector. Now think of a tag selector as a predefined, um, selector. So somebody else has written this thing called H two H one, and we know that it's to do with our heading one. The P tag is to do with our paragraphs. Now say we wanna make our own custom one.
That's where a class comes in. A class can be used, uh, can be named by us and can be told to go anywhere it likes. So let's say that, um, the client comes back and says, yes, I like this H one, but this word rentals. I'd like to be in bold and green for whatever reason. Okay? Now, using my current tools, I could go into the H one and style it, but I'd style the whole H one.
If I make it green, even though I highlight just this bit a rentals, and I say, I want you to be now a green and enter, you'll notice the whole H one becomes a green. It's what they call block level selector. It means that, um, if you style the um, tags, it means it styles every H one. If you had two H ones on this tag, it would style both of those. So that's not gonna work for what we need. So I'll put this back to our blue.
What I want is to use this new kind of selector called a class to style this last little bit of rentals. So it doesn't really matter where your cursor is to start this part. What you need to do is make sure over here on the right that you've got your, you want to go into the CSS file. I want to create a selector. And I don't wanna use any of these ones. I want to create my own one.
Now, to create a selector, you need to put a full stop in front of it, okay? So it needs a full stop and then you can give it a name. You can give it any name you like, making sure that you don't use spaces. We'll give you problems and don't use any of the things like asterisks and dollar signs and at symbols, anything like that. So just numbers and letters please. So we're gonna call this class, uh, we're gonna call it highlight.
Um, you can call it anything you like. You call this green and bold. You can call it anything you like. Okay? So I'm calling this one highlight now, just underneath here. So I'm gonna enter, it allows me to create this, um, the properties for this class.
So zoom out a little bit, okay? And what I want to do is Jump down to the text and I want to make it green like the client asked. Okay? So I've dragged my hue slider and I've dragged the circle over to the top right hand corner just to get the right kind of green that I want of the enter. And I'd like to play around with the style, not the style I want the weight. Okay, so underweight, I'm gonna look at, um, we've got, it's all normal at the moment.
I'm gonna change it to bold. Okay? And lo and behold, nothing happens. Okay? So you've created this class in your CSS sheet called highlight. Now we need to apply it.
So what happens is classes get applied on top of tags. So I've got this one called my H one. You can see it down here. If I highlight this thing here, that is my H one on top of this, just this little special bit I'm going to apply. Um, it's already got my format, H one. I'm gonna apply the class called highlight.
So this thing here now has the H one tag and a SPAN class called highlight. Alright? So that's how you create a class and apply it on top of a tag. Um, let's check out the CSSC just quickly. And you'll notice in here I've got my H one, there's my H two's, my p-tech. And here's this last, um, last little guy here, which is my class.
It's got a full stop highlight, okay? And I've just changed the color and made the font weight bolt. Alright? Um, that's it for this tutorial. I'll see you in the next one.