Start your free trial now, and begin learning software, business and creative skills—anytime, anywhere—with video instruction from recognized industry experts.

Start Your Free Trial Now

Using @font-face

Using @font-face provides you with in-depth training on Web. Taught by James Williamson as part of t… Show More

CSS: Core Concepts

with James Williamson

Video: Using @font-face

Using @font-face provides you with in-depth training on Web. Taught by James Williamson as part of the CSS: Core Concepts
Expand all | Collapse all
  1. 4m 54s
    1. Welcome
    2. Using the exercise files
      4m 2s
  2. 1h 8m
    1. Exploring default styling
      4m 56s
    2. CSS authoring tools
      2m 29s
    3. CSS syntax
      4m 45s
    4. Writing a selector
      4m 10s
    5. Setting properties
      8m 40s
    6. Common units of measurement
      7m 47s
    7. Inline styles
      5m 1s
    8. Embedded styles
      5m 19s
    9. Using external style sheets
      10m 35s
    10. Checking for browser support
      8m 48s
    11. Dealing with browser inconsistencies
      5m 30s
  3. 2h 15m
    1. Structuring HTML correctly
      2m 51s
    2. Element selectors
      4m 52s
    3. Class selectors
      6m 4s
    4. ID selectors
      3m 27s
    5. Using classes and IDs
      10m 7s
    6. Element-specific selectors
      4m 35s
    7. The universal selector
      5m 42s
    8. Grouping selectors
      4m 49s
    9. Descendent selectors
      7m 32s
    10. Child selectors
      5m 7s
    11. Adjacent selectors
      5m 30s
    12. Attribute selectors
      12m 43s
    13. Pseudo-class selectors
      3m 54s
    14. Dynamic pseudo-class selectors
      8m 29s
    15. Structural pseudo-class selectors
      6m 45s
    16. Nth-child selectors
      13m 10s
    17. Pseudo-element selectors
      12m 40s
    18. Targeting page content: Lab
      8m 56s
    19. Targeting page content: Solution
      7m 59s
  4. 44m 54s
    1. What happens when styles conflict?
      4m 0s
    2. Understanding the cascade
      5m 47s
    3. Using inheritance
      8m 26s
    4. Selector specificity
      6m 55s
    5. The !important declaration
      4m 5s
    6. Reducing conflicts through planning
      3m 33s
    7. Resolving conflicts: Lab
      6m 45s
    8. Resolving conflicts: Solution
      5m 23s
  5. 1h 47m
    1. Setting a font family
      7m 10s
    2. Using @font-face
      9m 19s
    3. Setting font size
      7m 35s
    4. Font style and font weight
      6m 52s
    5. Transforming text
      3m 58s
    6. Using text variants
      2m 49s
    7. Text decoration options
      4m 26s
    8. Setting text color
      3m 2s
    9. Writing font shorthand notation
      8m 49s
    10. Controlling text alignment
      6m 33s
    11. Letter and word spacing
      9m 11s
    12. Indenting text
      4m 30s
    13. Adjusting paragraph line height
      10m 30s
    14. Controlling the space between elements
      6m 41s
    15. Basic text formatting: Lab
      8m 45s
    16. Basic text formatting: Solution
      7m 14s
  6. 2h 1m
    1. Understanding the box model
      16m 53s
    2. Controlling element spacing
      14m 29s
    3. Controlling interior spacing
      10m 50s
    4. Margin and padding shorthand notation
      6m 27s
    5. Adding borders
      8m 57s
    6. Defining element size
      10m 7s
    7. Creating rounded corners
      6m 58s
    8. Background properties
      2m 51s
    9. Using background images
      5m 11s
    10. Controlling image positioning
      10m 25s
    11. Using multiple backgrounds
      7m 5s
    12. Background shorthand notation
      5m 25s
    13. Styling container elements: Lab
      7m 56s
    14. Styling container elements: Solution
      8m 17s
  7. 47m 51s
    1. Color keyword definitions
      5m 4s
    2. Understanding hexadecimal notation
      6m 5s
    3. Using RGB values
      4m 58s
    4. Using HSL values
      5m 17s
    5. Working with opacity
      2m 23s
    6. Using RGBa and HSLa
      3m 8s
    7. Styling drop shadows
      5m 38s
    8. CSS gradients
      6m 32s
    9. Working with color: Lab
      4m 26s
    10. Working with color: Solution
      4m 20s
  8. 1m 58s
    1. Additional resources
      1m 58s

please wait ...
Using @font-face
Video Duration: 9m 19s 8h 52m Beginner


Using @font-face provides you with in-depth training on Web. Taught by James Williamson as part of the CSS: Core Concepts

View Course Description

In this hands-on course, James Williamson demonstrates the concepts that form the foundation of Cascading Style Sheets (CSS), including styling text, adding margins and padding, and controlling how images display. The course also explores the tools needed to work with CSS, the differences between embedded and external styles, how to use selectors to target elements, and what to do when styles conflict.

Topics include:
  • Exploring default styling
  • Writing a selector
  • Setting properties
  • Working with common units of measurement, including ems and pixels
  • Structuring HTML correctly
  • Understanding the cascade and inheritance
  • Setting a font family, font size, text color, and more
  • Understanding the box model
  • Styling container elements
  • Working with RGB vs. HSL values
  • Styling drop shadows

Using @font-face

Now that we have discussed the syntax behind defining a font family and using a font stack, I want to talk about Web fonts. Web fonts allow designers to use the in-line @font-face rule to define an external font as a font family to use within the page. The font referenced is an external resource that the browser then request and uses on the page. This means that designers can now use any font they wish, providing they have the proper license to use the font and access to the font itself.

The way that we defined fonts in the last movie where we just defined a regular font family stack, that relies on the client machine to have the fonts installed. This technique @font-face essentially allows you to use any fonts that you have reference to, the browser will request the font and then display it. Let's take a closer look at how this works. I have the web-fonts.htm file open from 04_02 directory. What I want you to do is at the very top of your style declarations, above any of the other rules, we're just going to do a comment.

So I am going to do /* and I am just going to type in @ font-face rule declarations and then */ to close the comment out (/*@font-face rule declarations */). And just leave myself a little bit of space. So the way that this works is we are using @font-face rule to basically group all these external resources together and say this is what we are going to name the font. Then later on in our styles, we reference that font name in our normal font stacks and that's the resource that it uses.

The actual declaration @ font-face is a little complex. So in order to make life a little bit easier for you, you'll find in the 04_02 folder, a folder called assets. I am going to open that up and inside that I am going to open up syntax.txt. So this is just a text file that already has the syntax written inside of it. It's going to save us a little bit of typing and this is going to make it a little bit easier for us to go through the syntax in terms of how this works. So what I am going to do is I am going to copy the very first @font-face declaration.

You will notice I need the first line, including the curly braces, the opening curly brace and then the closing curly brace as well. So I am going to go ahead and highlight all of that and copy it and then in Web fonts in that sort of clear space that I created here, I am going to paste it. So let's go over a little bit of what the syntax is doing. I am not going to go over line by line because there is a lot there. But one of the first thing that we do is we declare a font-family name for this and this is essentially us telling the browser hey, whenever I use this name of this font, I want you to go grab this font and use it.

We are giving multiple locations for this font to our browsers and that's because it's still very new in terms of its implementation, and different browsers require different types of font. So you have to supply it with several different resources. Now those fonts themselves, currently I have them located in the _fonts directory. I am going to open that up and you can see here all these different font types, there is the Cantarell font. Now we are going to be using in this lesson Cantarell, which was an Open Source font that is free to distribute and it was created by the very talented Dave Crossland.

Be sure to read more about the Cantarell font, it's really nice. But you have to have access to these resources. Now there are several different ways that you can have access to those resources and I am going to talk to you about them towards the end of the movie. So just so, you know, when it points to those fonts that where it's pointing to. The next thing we do is at the very end of this, where we have requested all these resources that we need in order to make this work and all the various browsers, we then basically declare, and this is optional what font-weight we want applied when this font is applied.

Often times there are several different fonts within a font-family. There might be Cantarell Bold, Cantarell Heavier, Cantarell Lighter, Cantarell Regular and we get to choose what we want to use. So I'm saying that when font-weight is applied as normal and font-style is normal I want to use Cantarell-Regular. That's essentially what I am doing here. So now the next thing I want to do is I want to use the font. In order to use it, I have to go down to where I might have some additional font-family declarations and I am going to replace those. So I am going to replace the font stack that we have got currently going on in the body tag and I am going to replace that with Cantarell, and the spelling and capitalization matters here, Arial, and the reason I am using sans-serif font there as a fallback is because Cantarell is sans-serif itself, and then Helvetica, sans-serif.

So other than the initial @font-face declaration and the use of a nonstandard font with in the font stack, the font stacks are really kind of exactly the same as we had them for. I am going to save this, and then I want to test this in one of my browsers and when I do that I can see that I am using Cantarell. How cool is that? I am going to go back into my page and I want to go back to that syntax.txt file. You may have noticed that this was not the only declaration in this file, we have several different declarations.

We have three more in fact. I am going to go ahead and copy all three of those and then over in our webfonts.htm just below my initial font- face declaration I am going to paste them. Now it's very important that these font-face declaration's show up at the very top of your code. You want to make these available anywhere in your styles, and if you have the font-face declaration little bit further down, they might not be available. All right, so what's going on? I mean all of these are using the exact same font-family name, but you will notice this one is Oblique, this one is Bold and this was BoldOblique.

I am also saying okay, use Oblique when the font-style is Italic and the font-weight is normal. Use Bold when the font-weight is normal but the font-size is Italic and use BoldOblique when both the font-weight is Bold and the font-size is Italic. The order that you place these matters. Most of the time you want to go Normal, Italic, Bold, BoldItalic. If you don't do that a lot of browsers sort of have a little bug that shows up. The next thing I am going to do is I am going test this, so I am going to go down in my Styles and right after my body selector, I am just going to write a selector for all of my links that goes ahead and applies the font style of Italic to that.

So now I am going to Save this and test it, make sure enough my links are now Italicized. They are actually using the oblique version of the font, they are not going ahead and skewing those characters within the browser. I want you to consider this a very brief introduction into how web fonts work. There's a lot more to consider before you start using web fonts in your project, not the least of which is ensuring that you got a proper license to use the fonts you want for your site. Just because you have a font on your hard drive doesn't mean you can use it on your web site.

You have to be very familiar with the terms and license to do that. Now I want to give you a couple of resources that can help you learn more about Web fonts. So let me switch over to my Chrome browser and here is this is one of the foundry sites that actually offers hosting for web fonts and they have got an article written back in February for The New Bulletproof @ Font-Face Syntax and this is the syntax that is being used most widely by the designers and implementers right now.

I will say that the syntax has continued to evolve over the last couple of years and I wouldn't be surprised if we see it change a little bit more but if you're looking to have this syntax sort of walk through and explained to you why it's done a certain way, why certain things are omitted or added this is definitely the article to read, and it's got a bunch of updates and comments in it that can help you out as well. Another site that you definitely want to bookmark and go to is The lovely thing about this site is that it offers a tone of free fonts that you can use commercially or privately in your Web sites.

Not only does it offer the fonts, but it also offers you what it calls @font-face kits, this will give you a download that includes all of the fonts, the fonts-license and CSS with all of the syntax already written in it using the new bulletproof syntax. So this really is just an amazing resource if you are a designer that wants to start using web fonts. Now if you use these fonts you have to host them on your own web site. You may not want to do that and they're a lot of hosting services out there now such as type kit,

Google actually has a free hosting service, the Google fonts API that you might want to research, where you can go and have another service host those fonts for you so that you are not hosting them on your own site. Now finally, if you want to learn more about web fonts, I would recommend my Web Fonts First Look course where I go into the syntax in detail, I talk about some of the hosting companies out there, some of the options and what your responsibility as a designer is in terms of using and utilizing web fonts on your own page. So be sure to go give that look after you finish with this title.

There are currently no FAQs about CSS: Core Concepts.






Don't show this message again
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.

Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ .

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Join now Already a member? Log in

* Estimated file size

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.

Mark all as unwatched Cancel


You have completed CSS: Core Concepts.

Return to your organization's learning portal to continue training, or close this page.


Upgrade to View Courses Offline


With our new Desktop App, Annual Premium Members can download courses for Internet-free viewing.

Upgrade Now

After upgrading, download Desktop App Here.

Become a Member and Create Custom Playlists

Join today and get unlimited access to the entire library of online learning video courses—and create as many playlists as you like.

Get started

Already a member?

Log in

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

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.

You started this assessment previously and didn’t complete it.

You can pick up where you left off, or start over.

Resume Start over

Learn more, save more. Upgrade today!

Get our Annual Premium Membership at our best savings yet.

Upgrade to our Annual Premium Membership today and get even more value from your subscription:

“In a way, I feel like you are rooting for me. Like you are really invested in my experience, and want me to get as much out of these courses as possible this is the best place to start on your journey to learning new material.”— Nadine H.

Thanks for signing up.

We’ll send you a confirmation email shortly.

Sign up and receive emails about and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from

Sign up and receive emails about and our online training library:

Here’s our privacy policy with more details about how we handle your information.

submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.