Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
Now that we've taken a look at declaring font families and font sizes, I want to take a moment to talk about font style and font weight. You may know that better as bold and italic, but it's typically what the font-style and font-weight property allow us to do. Although just like everything else in CSS, there are a few details that you need to know about these. So I've opened up the font-weight.htm file and you can find that in the 04_04 folder. Again, not a whole lot going on here in terms of structure either.
We have a heading 1 followed by a paragraph followed by heading 2 followed by another paragraph and inside this last paragraph, we have some text inside of the span tag that we're going to use as it says to practice italicizing the text. Now here is what I want to do. I want to initially go down and just create a brand new rule right here for the span tag and inside that, we're going to use the property, font-style: Now font-style has a couple of different keywords that you can use and Aptana is being very nice because it's actually showing you those formats.
So that's really nice. Inherit basically is a keyword that you can use a lot on several properties and if you use inherit, it's basically saying hey, go out to the parent element, find out what its value is and inherit that. And that's very common on almost all properties. So really, the keywords we're focusing on are italic, normal, and oblique. Italic is saying use the italic version of this font if you have one, normal is saying don't italicize this text and then oblique is saying I want you to use the oblique version of the font.
Now there is a little bit of a difference between oblique and italic. Oblique is basically telling the browser to skew the text by certain amount and it's very helpful for when there is no italic version of the font. Italic is saying hey, I would prefer you, instead of skewing the text, I'd prefer you go out and actually use the italic or oblique version of the font. That's why you're going to see almost 90 % of the time people using italic when they want to italicize their text so that is what we're going to do. So we're going to say italic, we're going to save that, and I'm just going to go ahead and preview that in one of my browsers. And indeed I can see you right here, inside the span tag, the text is indeed italicized.
You know there is not really a lot going on with font-style but font-weight has a few more options that we need to take a closer look at. So I'm going to go back into my code and what I'm going to do is I'm going to go up to this h2 selector. This is going to be targeting this heading 2 right down here and just below that, I'm going to type in font-weight. Now the values that I have for font- weight and Aptana is kind of helping me out here, notice that I do have some numeric values and they go from 100 all the way up to 900 and that's actually what's considered to be, it's called the darkness value of the font, which is kind of weird, but essentially, it is the boldness of the font going from 100, which would be the lightest, all the way to 900 which would be the boldest or darkest, if you will.
But we also have some keywords here too. We have bold, bolder, lighter, normal and of course, inherit, which is pretty much around all the time. Most of the time when you see this, you're just going to see somebody come in and say bold or normal. So if I say bold and I test this, I don't really see any change because heading 2s are by there default bold. So if I come in and said and say no, no, no I want normal and if I save and test this, I can see that now that heading 2 is no longer bolded.
Now you might be wondering about some of those other values. Remember we had bolder, we had lighter. In a lot of cases, you'll have a font that has several different versions of that font and some might have a light version of it or regular version or bold version or even a bolder or black version of the font. So in that case, if you have several different families of the font within that, those values can sort of help you utilize that. Let me show you what I mean. I'm going to go into my heading 2 here and I'm going to change the font family for this.
What I'm going to do is I'm going to use a font that I know is installed on this system and that I know has multiple families and this is installed on most Macs. So if you're on a Mac with me, you can use this. If you're on a PC or if you're on some other system, I would recommend going out to your fonts wherever they're installed, looking through them, and finding a font family that has a light version, a regular version maybe even a medium and a bold version so that you can try this along with us. All right. So what I'm going to do is I'm just going to declare the font, Avenir LT STD So let's go ahead and choose that.
That's a font that has several different families, some of them are light, some of them are bold, and we're going to sort of compare the different weights against each other. So if I come in and I say lighter and I save this page and let's test this in a browser. And when I do that, I can see that I'm using a very light version of the Avenir font. If I chose normal and saved it and refreshed it, you can see that that gains a little bit of weight that's the regular version of it and if I say bolder and save that, I get a much bolder darker version of that.
Now this works just the same way. If I say bold, for example, and save this and test it, you can see no real change to the weight, but it works the same way for these numeric values. So anything from about, say, 100 to 400, I mean you'd have to have a really, really complex font for 100, 200, 300, 400 to work. You're really usually looking at three variants if you have them and anything from, say, 100 to almost 400 is going to give you that lighter version. Anything in the 400-600 range is going to give you the medium or regular version and anything at 700 above is typically going to give you the bold version.
So if I say font-weight: 100 and save that, you can see that it's going to go back to that lighter version. If I come up and say font-weight, say, 400 and save and test that, it's going to give me the medium version and if I come up and say 700 all the way up to 900 and save and test that, it's going to give me the bold version. So the numeric values can work for you when you have a font family that has those different variants of the font itself. That means that the font that you're controlling has a lot to do with the capabilities of font weight and even font style because if the file does not have an italic version, it's going to oblique the font for you within the browser.
So those two properties are really, really straight forward but remember that you can gain even greater control over what you can do with them if you know the properties of the font family that you're working with.
Get unlimited access to all courses for just $25/month.Become a member
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.