Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Setting up @font-face

From: Typography with CSS in Dreamweaver

Video: Setting up @font-face

The key to web fonts is the @font-face declaration. This small bit of CSS code allows you to incorporate nonstandard fonts into your web page. With the @font-face declaration, you can change headings like this into headings like this. Let's go through it step by step. So I'm going to go over to main.css, and let's just go straight into Code View and scroll down past the opening comments there, and we'll put-in our @font-face declaration right at the top of all of our other CSS rules.

Setting up @font-face

The key to web fonts is the @font-face declaration. This small bit of CSS code allows you to incorporate nonstandard fonts into your web page. With the @font-face declaration, you can change headings like this into headings like this. Let's go through it step by step. So I'm going to go over to main.css, and let's just go straight into Code View and scroll down past the opening comments there, and we'll put-in our @font-face declaration right at the top of all of our other CSS rules.

So we start with @font-face and then open up a curly brace, and I'll just close that out so that we have a complete statement, and now we enter-in a font-family property. Now the name of the font that you enter here is the name you'll use when you're inserting it into the CSS rules as part of other font families. I'll put this in quotes, and the name is DragonwickFGRegular.

We'll close that off with a semicolon. We want to find the source for this font. It is a local file that I have within the directory here. So I'll go ahead and highlight the URL and then press Return or Enter so I can browse for it. It's in Chapter 3, in the 03_05 folder. You'll see an _fonts folder, and then there are four variations of this. We're going to start by choosing the Embedded Open Type variation with the file extension of EOT and click Choose.

Then again, close it out with a semicolon. Not all browsers support all font formats, so you need to use multiple formats and include them in the @font -face declaration correctly. Although Internet Explorer 9 now supports the Web Open Font Format, WOFF file extension, and the TrueType format, earlier versions of Internet Explorer only recognize the Embedded Open Type or EOT format. Moreover, unless you're careful, the earlier versions of Internet Explorer will load all the other formats.

So to avoid that issue, you have to use a little code trickery. So let's continue with our @font-face declaration, and we'll put-in another source. This time instead of putting in a URL, we're going to say that it's local, which means that it's going to be on the user's system. What we're trying to do is to avoid actually picking any of the files on the user's system. So we'll put-in an opening parenthesis and a pair of quotes and this time instead of a font file name, we'll actually put-in an exclamation mark which is extremely likely not to be the name of any font that is on a user system.

We'll follow that by closing off the parenthesis and then putting-in a comma. I'm going to put this on the second line here, just give it a little bit of space to show that it's all part of the same source. So this is where we're going to bring in the other two formats. So we'll do a URL, and this time, I'm going to go ahead and just copy this path, paste that in, and change the file extension from EOT to WOFF; that's the Web Open Font Format.

Then after I close the parenthesis, I'll put-in another attribute which is format, and in quotes WOFF. Close the parenthesis and add a comma, so we can add in the next format. Again, a URL version, and let's copy that, and then paste it in here. Our final format is a TrueType and they use a file extension of TTF.

We will again put in the format attribute with TrueType. Now, if you're typing along with me, and you notice that whenever I type a single quote, a double quote appears, that's because I'm using Dreamweaver 5.5. If you're not seeing that, you're probably on Dreamweaver 5. This whole technique that we're seeing here was developed by a gentleman named Paul Irish who called this method the Bulletproof Technique, which seems to be actually quite true, and it's in wide use throughout the web.

Now that you made it possible to use a linked font, you must apply the font family to the desired selector. So let's go to Design View and open up the CSS Styles panel. I'll go ahead and select the h1 tag which is what we're going to look to replace, and I'll see which rule is already controlling the font, and that's the #mainContent h1. So let's go to that code by right- clicking on that, and choosing Go to Code. I'm just going to add in my new font name right in front of the existing font family, DragonwickFGRegular. Okay.

Let's save our page, go back to Design View, and you should see it immediately appear. If you don't see the font-face right away, just click Refresh. Changing a single font is a pretty simple example, but you can see the power of web fonts immediately. Not only is this text selectable and thus can be copied and pasted, but it's also eminently more search engine-friendly. Of all the improvements brought by HTML5 and CSS3, I really think that web fonts place among the most impactful, as they open the door for a far truer expression of the designer's artistry.

Show transcript

This video is part of

Image for Typography with CSS in Dreamweaver
Typography with CSS in Dreamweaver

36 video lessons · 8057 viewers

Joseph Lowery
Author

 
Expand all | Collapse all
  1. 3m 52s
    1. Welcome
      1m 19s
    2. Using the exercise files
      2m 33s
  2. 19m 16s
    1. Working with the Property inspector's HTML tab
      2m 0s
    2. Making the most of the Property inspector's CSS tab
      4m 57s
    3. Defining and changing type with the CSS Rule Definition dialog
      6m 16s
    4. Modifying type directly in the CSS Styles panel
      6m 3s
  3. 19m 45s
    1. Understanding type measurement unit options
      2m 50s
    2. Working with pixels
      2m 34s
    3. Defining a percentage-based page with ems
      6m 51s
    4. Letting users set page type size
      7m 30s
  4. 17m 36s
    1. Getting to know the basic font categories
      1m 32s
    2. Employing web-safe fonts
      3m 20s
    3. Defining new font families
      3m 22s
    4. Exploring CSS3 typeface options
      3m 9s
    5. Setting up @font-face
      6m 13s
  5. 9m 39s
    1. Dispelling the myth of web-safe colors
      1m 13s
    2. Applying color to type
      4m 52s
    3. Incorporating semi-transparent type
      3m 34s
  6. 19m 46s
    1. Setting the font-weight
      3m 48s
    2. Mandating font case
      2m 25s
    3. Exploring font variants
      1m 50s
    4. Utilizing white space effectively
      3m 40s
    5. Changing letter and word spacing
      2m 20s
    6. Defining first-line variations
      2m 19s
    7. Inserting drop caps
      3m 24s
  7. 20m 17s
    1. Applying CSS3 text effects
      5m 26s
    2. Designing type gradients
      8m 27s
    3. Rotating text with CSS transform
      6m 24s
  8. 15m 21s
    1. Implementing advanced headings with HTML5
      3m 11s
    2. Preparing CSS3 multiple-column layout
      4m 50s
    3. Future type: Defining CSS Regions
      7m 20s
  9. 24m 51s
    1. Styling unordered lists
      6m 51s
    2. Specifying a sequence with ordered lists
      5m 14s
    3. Applying definition lists
      7m 19s
    4. Targeting list items with CSS3 nth child
      5m 27s
  10. 20s
    1. Next steps
      20s

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
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

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 Typography with CSS in Dreamweaver.

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
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.

Are you sure you want to delete this note?

No

Your file was successfully uploaded.

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
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.