This lesson is exclusive to members

Responsive Web Design Essentials - HTML5 CSS3 Bootstrap

How to add a horizontal rule using HTML5 & CSS3 in VS Code

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_63

You need to be a member to view comments.

Join today. Cancel any time.

Sign Up
Hey everyone, nice simple one. We got no line, now we've got a line. Super simple, we're going to add a border to the box of the heading, we'll talk about the HR tag as well. Let's jump into VS code and make it happen. 

First up let's talk about, the line we need is this one here, right? So on my mock-up I've got this line that runs across the document, up the top here, kind of like between the Header and this Main Hero box here. It's kind of like a light gray. I've picked that color there, 'CCCCC'. Let's show you how to do it. 

So the bad way, well it's not a bad way, just doesn't seem to be used that much very often, and it has some drawbacks, so between the Header and the Main, I'm just going to stick it right here in the middle, and we're going to use this tag. If you've done any of my previous courses, this HR tag is what we use, the Horizontal Rule, and it appears on the page, it's perfect, it's got a lot of styling on it, which is probably the biggest problem with it. Weirdly about an HR tag as well, it doesn't have a closing HR, doesn't need it. I don't know why, just magic, doesn't need to do that whole thing. 

There's a couple of tags that do that. So the reason we don't do that is, I don't know, in the HTML5 documentation it says, "Hey, we're not using this anymore as a ruler, we're using it as, like a content break, and we're going to hide it." You should make it so it's styled, so you can't see it, and it's used to break up content. It still works but let's just not use it anymore, and I'll show you the easiest way to get around it; super easy. 

In our case-- because the other drawback with HR, it's something on your page, and I'm going to have to have this on every single page, underneath every Header. So a nice way to get around it is either we're going to add a border, like we did for the buttons here, on the bottom of either the Header or the top of the Main. Either way will get us to the right place, let's find the Header. Oh, it's kind of weird. You'll notice how the bracket was there, it's not broken, it's just, it annoys me. I like it to be separated out like that. 

So we're going to use Border. I spelled it right today, Border-bottom. And just like we did before we can put a kind of a row. So the first one is how white it is, and then it's going to be solid, and then it's going to be gray. I love this, you can use gray with an A or an E, same color. I don't think there's even American or English versions of the spelling. I think just there's two spellings of the same word. I'm probably wrong about that, but anyway, there you go. I've got this-- oh there is a light gray for both of those. Both spelled the same, you can have both the spellings. 

You can see, it's doing the exact same job, and it's just a more simple thing, whereas the other one had all this kind of really weird depth to it. The HR has some weird styling to it, kind of old-school. We've got solid, you've got dotted. There's lots of different stylings for it. It's turned pretty small, make it nice and big so you can see it, in case you want giant dots, but that's it, nice short video. Easy to do lines, don't use the HR anymore. Just find one of the boxes that applies. 

Now there are going to be times when you're like, "Actually I want a small little line across," and you might use the HR. You might just style it to get rid of all the extra bits. I'm not going to cover how to remove all the kind of built on styling for it. You might find that yours is actually nice, a straight line using the HR, because the CSS reset you're using might have cleared it up, but the one we're using from Chris Mayer is not. All right, that's it, I'll see you in the next video.