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

CSS Fundamentals

Working with fonts


From:

CSS Fundamentals

with James Williamson

Video: Working with fonts

In this chapter, I want to spend some time going over some of the common CSS concepts that you are likely to encounter when using style sheets. While the main focus will be to provide you with a broad overview of topics, we will spend some time exploring syntax and best practices to use when authoring styles. I want to start by focusing on fonts. Controlling typography is often the first thing the designers learn to do when using CSS, and for good reason. Typography is so important to your design and what you're trying to communicate that it's just a natural starting point.

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...
CSS Fundamentals
3h 14m Beginner Sep 26, 2011 Updated Dec 13, 2011

Viewers: in countries Watching now:

This course contains a high-level overview of Cascading Style Sheets, while exploring the basic concepts, terminology, and tools of the language. Beginning with an exploration of CSS syntax, author James Williamson explains how CSS modifies text, borders, backgrounds, and color; demonstrates CSS and HTML integration; and contextualizes the current state of CSS. The course also tours some of the most popular CSS editors and frameworks and lists online tools and resources for further study. This course is for people who want a big-picture overview before taking hands-on courses.

Topics include:
  • Understanding basic selector types
  • Integrating CSS with HTML
  • Examining browser rendering differences
  • Exploring CSS specifications
  • Checking browser support
  • Understanding the box model
  • Adjusting margins and padding
  • Positioning elements
  • Exploring basic layout concepts
  • Understanding media queries
  • Introducing CSS3
  • Using CSS Reset
Subjects:
Web Web Foundations
Software:
CSS
Author:
James Williamson

Working with fonts

In this chapter, I want to spend some time going over some of the common CSS concepts that you are likely to encounter when using style sheets. While the main focus will be to provide you with a broad overview of topics, we will spend some time exploring syntax and best practices to use when authoring styles. I want to start by focusing on fonts. Controlling typography is often the first thing the designers learn to do when using CSS, and for good reason. Typography is so important to your design and what you're trying to communicate that it's just a natural starting point.

Remember, if you don't specify a font and format your text, your content will receive the browser's default styling. I highly doubt that that's the look that you are going for. The first thing that you will need to decide when choosing a font for your site is whether you want to use the older, more widely supported system fonts or take advantage of the emerging technique of using web fonts. Let's take a moment to discuss the differences between the two. Now in the past, designers have been limited to using a small set of fonts that are preinstalled on almost every machine.

These are called system fonts, and I have no doubt that you have used them at one time or another. Fonts like Arial, Helvetica, Verdana, Times, Times New Roman, and Courier, and yes, even Comic Sans, are so common on the web that you're more likely than not to encounter at least one of them every time you go online. So, why are these fonts so popular? Well, it has very little to do with the popularity or quality of the fonts, although most of them are quite good, and everything to do with their ubiquity.

Until recently, HTML and CSS contained no mechanisms for displaying a font that wasn't already installed on the client's machine. You could certainly specify that you wanted your web pages to use Garamond, but unless the person viewing your page had Garamond installed, it would fall back to the system's default font. You can see this concept illustrated most clearly by looking at the syntax for declaring font families. Now at first glance, this may look a little odd. Here the designer seems to be asking for more than one font for all paragraphs.

In reality, what this syntax allows designers to do is to provide fallback fonts in case the first one requested isn't found on the client's system. In this case, the first choice would be Arial. If Arial wasn't installed, it would then request Helvetica. If Helvetica wasn't found, it would then request Verdana. And if in the unlikely event that one of those three fonts weren't found, it would finally ask for the system's default sans-serif font, so that at least the text would display in the style that the designer wanted.

Now is there anything wrong with that? No, actually there isn't. Many of the system fonts, like Georgia and Verdana, were designed specifically for the screen, making them very functional choices for web sites. However, recent advances to CSS and browser support now make it possible to use a much wider array of fonts. By now you've probably heard of web fonts. Web fonts is simply the term typically used to describe the technique of embedding font files in web pages using the @font-face method.

This allows web authors to use fonts without worrying about whether they're installed on the client machine or not. The CSS @font-face rule has actually been around for quite some time, but only recently has browser support, font formats, and licensing issues reach the stage where it's actually feasible to use. Web fonts typically work by having an @font-face rule, such as this one, in your styles that point to an external font resource. Now, this could be a font that you host yourself or one that's hosted through any number of recent font hosting services that have appeared to support web fonts.

Now, I know that this syntax looks a little complicated, but trust me, it's not as bad as you think. There are also plenty of online resources that can help you find fonts and even generate the syntax for you. I'll list some of those in the final chapter. If you want a deeper look into web fonts, check out my lynda.com title, Web Fonts First Look. What all this means is that when you are working with fonts in CSS, you have three basic choices: first, you could rely on the browser to supply the user's default font; second, you can specify a preferred system font and then provide fallback fonts all the way down to specifying the generic font family to use in case the client machine doesn't have the defined fonts installed; or third, you can use @font-face to supply custom fonts to the browser.

You could also use a blended approach, where you use web fonts but provide fallback system fonts to the user agent if it doesn't support web fonts. Okay, now that we have we talked little bit about some of the different ways you can use fonts with CSS, we will move on and talk about some of the options for formatting fonts, and we'll do that next.

Find answers to the most frequently asked questions about CSS Fundamentals.


Expand all | Collapse all
Please wait...
Q: This course was updated on 12/13/2011. Can you tell me what has changed?
A: One movie called "Who is this course for?" was added to provide information on what you can expect to get from the course, depending on your level of familiarity with CSS.
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 CSS Fundamentals.

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


OK
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