This lesson is exclusive to members

Responsive Web Design Essentials - HTML5 CSS3 Bootstrap

How to add rounded corners to a button or div tag in HTML & CSS

Daniel Walter Scott

Download Exercise Files Download Completed Files

Contents

Certificates

We’re awarding certificates for this course!

Check out the How to earn your certificate video for instructions on how to earn yours and click the available certificate levels below for more information.

Introduction

I recommend hosting your new website with Bluehost, you can get a big discount by signing up with this link: https://www.bluehost.com/track/byol/byol_webess_57

You need to be a member to view comments.

Join today. Cancel any time.

Sign Up
Hi everyone, this video is going to be all about radiuses around the corners of buttons, but we'll do it to images and we'll do it to Div tags as well. We'll do big ugly radiuses, like this, and nice simple ones like this. Ooh, nice and small, plus we'll do random ones like this, or this, or this. You get the idea, rounded corners. This video is like four minutes long, but really, just add border radius to your buttons, and you'll be done, but if you want the full load down, let's watch to the end. 

To add little rounded corners to the edges of our button, or Div tags, or any sort of box, it's super easy. In VS code we're going to find my button. I'm going to say, you have a border radius of whatever you want. I'm going to use pixels, and I'm going to say, I want it to be 2 pixels, and that will do all four corners. So let's have a little look, and look, got little rounded corners. Let's make them a bit more obvious just so you can see. 12, giant rounded corners. So you can do individual corners. I'll show you a couple of things to do with border radius while we're here. 

First of all it doesn't matter what you apply it to, as long as it's a box and it's got edges. Let's have a look at-- what have we got? These cards, Cards 1, 2, and 3, they will work, Cards 1, 2, and 3. You, paste. So Card1, rounded corners, this image, a little bit weirder. It's in a box, but it is, like if I do it to Hero Box2, which is the box he sits in, where is Hero Box2? If I do it to this, it's not going to work. The box is, but then there's this image inside of the box. So what we need to do is say, if there's an image, if it's inside of Hero Box2, then-- so you actually apply it to the image. 

The only reason I'm making it a Compound Class is, just because I don't want to do it to all images on the document. You might like that. Image, inside of Hero Box2. Did it to all images. Hero Box2, is he? In Hero Box2, am I just making up names to stuff? Oh yeah, it's going to work, Hero2. Let's go to Hero Box2. Here we go. So that is it, could be anything. You get the idea, right? 

The other thing you can do with border radius, is we've just done it for all four corners, like we did with Padding, you can use either 1, which does them all, 2, which does top and bottom, left and right. So I could do 12, and let's say, 3, or 0, let's do 0, for the top and bottom. So you've got the first one, you get what I mean. Hard to explain. Top left is the first, then this one gets skipped. So you get it. I'm like, explaining, that's what that does. And if you want to do 4, it's going to go, start on the top left, go around, and the next one's going to be 3, or 6, then the next one's going to be 100. It's going to go through all of these. 

Now what ends up happening for 100, is that's not actually 100 pixels. It goes as far as it can. So that's as far as it can. It could be 1,000, it wouldn't matter. So you can use that to your advantage, I can just make them all 1000 pixels, and it gives you that kind of pill shaped box, because it just tries to fit it out until it goes into a circle, and then it can't go any further. 

You can do kind of neat tricks with it, you might go 0 pixels, 1000, and, 1000, and then 0. It's all right, here you go. You can do interesting little shapes with it. You get the idea. I'm going to put in two pixels, because I just want this, like real subtle little edge on it. And that is Border Radius, my friends, nice and easy, but I stretched it out for a few minutes. Let's get on to the next video.