Start learning with our library of video tutorials taught by experts. Get started

CSS3 First Look

Using web fonts


From:

CSS3 First Look

with James Williamson

Video: Using web fonts

Writing an @font-face declaration is only the first half in the process of using web fonts. Once you have the declaration defined, you can then reference the font's defined name throughout the rest of your styles. To utilize our ChunkFive font, we now need to find the font-family declarations that we wanted to add it to, and modify those font stacks. So I have the main.css file. Then you might want to open up the index.htm or explorers.htm as well to test a little bit later on. Okay, so what I am going to do first is I am going to find the items on the page that I want to reformat using our new font.
Expand all | Collapse all
  1. 3m 5s
    1. Welcome
      1m 20s
    2. Using the exercise files
      1m 45s
  2. 31m 30s
    1. What is CSS3?
      5m 26s
    2. The current status of CSS3
      3m 35s
    3. An overview of CSS3 capabilities
      2m 24s
    4. Can you use CSS3 now?
      5m 31s
    5. Detecting support for CSS3
      9m 0s
    6. Understanding vendor prefixes
      5m 34s
  3. 1h 9m
    1. An overview of child and sibling selectors
      3m 11s
    2. Using child and sibling selectors
      7m 17s
    3. An overview of attribute selectors
      3m 19s
    4. Using attribute selectors
      8m 32s
    5. Pseudo-class UI selectors
      5m 56s
    6. Negation pseudo-class selectors
      6m 48s
    7. Target pseudo-class selectors
      5m 39s
    8. Structural selectors
      3m 58s
    9. Nth-child selector syntax
      10m 0s
    10. First, last, and only structural selectors
      5m 39s
    11. Using structural selectors to write more efficient code
      8m 52s
  4. 45m 28s
    1. Color formats in CSS3
      7m 9s
    2. Transparency in CSS3
      9m 10s
    3. CSS3 gradients
      4m 11s
    4. Creating linear gradients
      13m 57s
    5. Creating radial gradients
      11m 1s
  5. 49m 8s
    1. Working with web fonts
      6m 38s
    2. @font-face syntax
      4m 52s
    3. Downloading sample fonts
      6m 5s
    4. Writing @font-face declarations
      7m 57s
    5. Using web fonts
      6m 42s
    6. Using text shadows
      7m 14s
    7. Creating multi-column text
      9m 40s
  6. 50m 55s
    1. An overview of the flexible box model
      4m 42s
    2. Controlling box orientation
      5m 2s
    3. Setting element flexibility
      12m 59s
    4. Distributing boxes
      7m 54s
    5. Controlling box alignment
      12m 38s
    6. Working with box-sizing
      7m 40s
  7. 1h 5m
    1. Using border-radius
      6m 20s
    2. Creating custom rounded corners
      10m 21s
    3. Understanding border images
      5m 15s
    4. Using border images
      8m 52s
    5. Creating box shadows
      8m 58s
    6. CSS3 backgrounds
      4m 55s
    7. Controlling background size
      8m 46s
    8. Creating multiple background images
      6m 4s
    9. Using background-origin
      3m 18s
    10. Clipping background content
      3m 2s
  8. 40m 8s
    1. An overview of CSS3 2D transforms
      4m 26s
    2. Using 2D transforms
      8m 16s
    3. Setting transform origins
      5m 24s
    4. An overview of CSS3 transitions
      5m 0s
    5. Animating CSS properties
      6m 12s
    6. Using easing in animations
      5m 41s
    7. An overview of 3D transforms
      5m 9s
  9. 37m 56s
    1. Understanding media queries
      6m 18s
    2. Strategies for targeting multiple devices
      6m 4s
    3. Writing styles for target screen sizes
      12m 11s
    4. Deploying styles through media queries
      3m 55s
    5. Basing media queries on page orientation
      2m 24s
    6. Targeting media queries for iOS devices
      7m 4s
  10. 1m 6s
    1. Goodbye
      1m 6s

Watch this entire course now—plus get access to every course in the library. Each course includes high-quality videos taught by expert instructors.

Become a member
Please wait...
CSS3 First Look
6h 34m Appropriate for all Nov 29, 2010

Viewers: in countries Watching now:

In CSS3 First Look, staff author James Williamson provides an in-depth introduction to the newest CSS standard, detailing its modular format, history, and current level of browser support, while also demonstrating its capabilities and applications. The course includes tutorials on using new selectors, modifying typography and color, working with the box model, and understanding media queries. Exercise files accompany the course.

Topics include:
  • Understanding the history of CSS3
  • Working with the new selectors
  • Adding transparency and gradients
  • Specifying web fonts with @font-face
  • Understanding the advances to page layout
  • Looking at CSS3 box model capabilities
  • Using 2D and 3D transforms
  • Understanding media queries
Subject:
Web
Software:
CSS
Author:
James Williamson

Using web fonts

Writing an @font-face declaration is only the first half in the process of using web fonts. Once you have the declaration defined, you can then reference the font's defined name throughout the rest of your styles. To utilize our ChunkFive font, we now need to find the font-family declarations that we wanted to add it to, and modify those font stacks. So I have the main.css file. Then you might want to open up the index.htm or explorers.htm as well to test a little bit later on. Okay, so what I am going to do first is I am going to find the items on the page that I want to reformat using our new font.

To do that, I am just going to test this in a browser so you guys can see what it is that we're going to be targeting. Explore our world your way, we're going to use ChunkFive for that, Tour Spotlight, I want to use ChunkFive for that and Explorer's Podcast, and then in our callouts, these headlines, Tour Spotlight and Monthly Specials, I want to use Chunk Five for that as well. So I am going to close this and go back into my CSS file. Now the first selector I need to find is on about line 116. It's the callOut h1. Those are the sidebar divs or those callOut divs and it's the heading for those guys.

So I always like to have my font declarations towards the top. It's just me. So right at the very top of this I am going to type in font-family and here I am going to build my own font stack. I am going to put the ChunkFiveRegular. Remember that is the name that we used, and at this point, maybe I am thinking hey! Chunk would have been better. After that I am going to follow that up with Georgia. So you need to give it an alternate font. Times and then serif. So that gives us some fallback content in case ChunkFive doesn't load for whatever reason.

It will use Georgia. All right, after that, I am going to type in font-weight. Since this is a headline, I want to do normal, so it's not bold because this is a very bold font. And then I'm going to do a little bit of letter spacing here. I am going to do 1 pixels worth of letter spacing, at a smaller font size. These Chunk Five can get kind of tight. So by doing 1 pixel worth of letter spacing that's at least give me a little bit of extra space between them. All right! Next I am going to scroll down and find the mainContent h1. It's on about line 312.

That is right there. mainContent h1. And you'll notice that we already have a font declaration there, so we're just going to modify this. So it's going to say normal 2.5em. That's fine. I am going to remove the Times New Roman. I've got a bunch of these already and I don't need that. But at the very front of this, I am going to do ChunkFiveRegular and then another comma. So exactly what we had before. As a matter of fact, you should get to a point where you can just copy and paste these declarations. Margins, I am going to change this up a little bit.

You can see right now, for top margin I have .5ems and nothing on sides and then the bottom is .25 ems. Well, what I am going to do is I am going to take that top margin and get rid of it as well. It all has to do with the weight and the spacing of the font. It's a little bit of a bigger font. Letter-spacing, instead of -1 pixels, I am going to actually add a pixel, so again space this out a little bit. I am also going to change the color of this. For color, I am going to do #193742. Now, why am I doing that? Well, the original color of this is black, and this is such a large font and so solid that if you leave it black, it just sort of dominates everything else.

So using the sort of blue accent color that's used elsewhere in the site will help tone it down a little bit. All right! The next thing I need to do is go to find the spotlight h2 selector. spotlight h2. And it's going to be a little further down the code. There it is, on line 700 at this point. Your line numbers may differ a little bit from mine depending upon how you like to format your CSS. Now, this doesn't have a font-family declaration, so again, what I am going to do is just go to do this right up top. I am going to do font-family: ChunkFiveRegular. Another value of copying and pasting this would be, if you get it right the first time, you don't have to worry about misspelling it again and having the font not work.

Sometimes you'll spend just a ton of time wondering why your font resource isn't downloading. You'll look through all your code and your font-family declaration and you'll find that you just left out an e or something as you declared it. So there is a lot of moving parts to this that go wrong. All right! After that, we're going to do font- weight and that's going to be normal. Again, we just don't want that to be bold or bolded, and then we'll do some letter-spacing here as well and we'll do 1 pixel's worth of letter spacing. So I am going to save this and I want to preview this in any of my browsers, and we're just fine.

You can see in Firefox, there is our custom font, Explore your world your way. As we get down, Monthly Specials has it, Tour Spotlight has it, and the Did You Know has it. I could also check it out in Safari to make sure it's working there. Indeed, it's working in Safari, and what about Opera? See if it's working in Opera. It is working in Opera. Cool! Finally, how about Internet Explorer? And indeed, it's working in Internet Explorer as well. Cool! Now, one problem here and let me point this out. If I go to one of my other pages like this Explorers page, the headline up here also gets it because it is a mainContent h1.

That is so small that it begins to close up and it's a little too small for that particular font. So I want to revert that back. So sometimes you have to be careful when writing these new selectors. You want to make sure that you're not overwhelming maybe some of the other ones. So in this case, I need to go and find the mainContent h1 page ID selector, because that is the one that is controlling that particular font and that is on about line 351 or so. It's going to be in that area. So I am just going to scroll up until I find it. There it is right there. And here again, I am just going to go up and do a font-family declaration here.

I am just going to use the regular Georgia font stack for this, so Georgia, Times New Roman, Times, and serif. So if I save that, test this in a browser again, and click on Explorers, I can see that now that's gone back to just being regular Georgia and it's a little bit more readable. So my main advice regarding the use of web fonts is to carefully consider how they're going to impact your design before you use them. Obviously, you're adding additional overhead to your site because these font resources need to be downloaded. Heavy usage of web fonts often can cause a noticeable delay in the font rendering as well, so there might be a little bit of a pause before the fonts are fully rendered.

Also, make sure you test your design in several browsers to ensure consistency in how your font renders. Keep in mind that you may have to make several subtle typographic adjustments in order to get the look and feel that you want for the font that you've chosen. Using web fonts is a great way to enhance your site design and offers exciting new capabilities for you in controlling your site's typography. You just want to make sure that you've planned carefully, so that you can execute it properly.

Find answers to the most frequently asked questions about CSS3 First Look.


Expand all | Collapse all
Please wait...
Q: I'm following along with the video "Transparency in CSS3".  James shows us how to achieve transparency in Internet Explorer by going to Kimili.com and entering a HSLA value to generate code for transparency.

Here that code:

background: transparent;-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#BF0E0C0B,endColorstr=#BF0E0C0B)"; /* IE8 */
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#BF0E0C0B,endColorstr=#BF0E0C0B); /* IE6 & 7 */ zoom: 1;

When this code is added to my HTML file it removes transparency on browsers that do in fact support it. So I'm left with NO transparency. Why?
A: The problem is in the filter code. If the IE background is called last, the first "transparent" declaration will remove all previous colors, regardless of browser. To resolve this, place the rule inside a conditional comment for IE or remove the "transparent" declaration at the front of the rule.
Share a link to this course
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.
Upgrade now


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.

Upgrade now

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

Congratulations

You have completed CSS3 First Look.

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


OK

Course retiring soon

CSS3 First Look will be retired from the lynda.com library on April 24, 2014. Training videos and exercise files will no longer be available, but the course will still appear in your course history and certificates of completion.


Become a member to add this course to a playlist

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

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

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:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Welcome to the redesigned course page.

We’ve moved some things around, and now you can



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.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com 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 lynda.com.

Sign up and receive emails about lynda.com and our online training library:

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

   
submit Lightbox submit clicked