This lesson is exclusive to members

Responsive Web Design Essentials - HTML5 CSS3 Bootstrap

How to change the default font type color size on a website using 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_44

You need to be a member to view comments.

Join today. Cancel any time.

Sign Up
Hi there, this video we're going to talk about the default font, and changing it, because by default it is black, and it's Times New Roman. We want to change that for every tag that's on the site, rather than doing it individually. Up until now we've been doing it per tags. So H1 is now Arial, and then the P-tag is now Arial. Let's just do it once for the whole site. It's pretty easy, the short version is, just add it, Font family to the Body Tag, job done . Now why is this video so long? Because I want to talk about Specificity as well, so hang around for that. Yeah, let's get going. 

So we've got our default font, it is Times New Roman, and black, and it is 16 points, that's the default. We want to change that, because what we did in the last project, is every H1 we made Arial, then we made the P-tag Arial. So we individually did it, but it'd be great just to change them all by default, and it's really easy. We use the body Tag. Body Tag is the whole thing on the page. So in this tag here, we need to say, the font is family, and it's going to be Arial, in this case. We'll do fancy fonts in the next video, but that now will be this, the Heading, so we got an H1 over here, where is he? There it is, an H1, the P-tag, they're all Arial, plus I want the default for the site to be a color of white. Not wheat. 

So that's what you need to do, kind of the beginning of everything, or beginning of a website, it's just throwing some of that kind of overall default stuff, and then later on you can kind of override it, so let's say that-- I want to kind of talk about Specificity again in CSS, because this is quite generic, it's at the top, the Body tag, everything's in the Body tag, so this is kind of very generic. So all you need to do is put something very specific, so, like an H1, to say, actually I want the H1 to be a different size. So we're going to go, font, font size, even, and we're going to pick like 80 pixels just because, because at the top, actually we didn't set a size up here, did we? 

Let's say we want to change the color of it, instead of the font size. We're going to say, we're going to use a font, oh, we're going to use a color of, let's say, just, I'm going to use-- the cool thing about VS code is that, because I've used these in the code earlier on, it suggested them to me. So I'm going to use, oh, not any one of them, but you get what I mean. So I'm going to make it black now. So at the top it said be white, but down here it said, be black, and because this is more specific, body generic, H1 is a little bit more specific, it's going to override it. 

Now when there's not a really clear specificness to it, say you've got two H1s, this ends up happening, it seems dumb now when they're right next to each other, but when you've got a really long CSS document, or that you're using somebody else's site, and you don't know where, if somewhere in this code the H1s been turned, made white, or black, or purple. You just can't work out where, all you need to do is, further down the cascade, so it's a cascading style sheet, the browser reads it from the top to the bottom, and if there's things that are equally specific, then the last one wins, so down here if I say, be red, this one will win because it's after this. 

So the top, it's being white, like it's going through some, I don't know, it's been told lots of things, at the top it says, be white, everyone be white, and it says, be black, and then be red, and the red will win because it's further down the list. The H1 will win over the Body Tag every time, doesn't matter where it is, because it's more specific. Let's test that out, let's grab the H1, let's cut it, so it's not down there anymore, it's just above everything. Here we go, paste it in, wrong way pasting. Paste it in, save it, and it should still be red. 

So it's a mixture of the flow, the cascade, and it can be troubling sometimes, because you're like, you're throwing things in everywhere, and you're like, "Why is it this? I've told it to be white." It's because it's the last thing in the cascade. So it's a mixture of the flow, the cascade, the waterfall, coming down to more-- and then a mixture of specificity. It's a hard word to say, that one. 

So I'm going to get rid of this red, and I'm going to change the color back to white, and just leave the font size there. Let's get into the next video, where we start adding some fancier fonts, because we're all tired of you, Arial. It's time to go, and I'll see you in the next video.