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

Using font shorthand notation

From: Dreamweaver CS4 with CSS Essential Training

Video: Using font shorthand notation

In an earlier movie on setting up CSS preferences, we instructed Dreamweaver to use shorthand notations for margins, padding, background, list and borders but not for font. At the time I mentioned how incorrect application of the font shorthand can cause problems. So I tend to like implementing it on a case by case basis. In this movie, we'll take a closer look at the properties that we can set for the font shorthand notation and the problems that its careless use can cause. So here we have a file, notation.htm, opened and this has a few examples of font shorthand notation.

Using font shorthand notation

In an earlier movie on setting up CSS preferences, we instructed Dreamweaver to use shorthand notations for margins, padding, background, list and borders but not for font. At the time I mentioned how incorrect application of the font shorthand can cause problems. So I tend to like implementing it on a case by case basis. In this movie, we'll take a closer look at the properties that we can set for the font shorthand notation and the problems that its careless use can cause. So here we have a file, notation.htm, opened and this has a few examples of font shorthand notation.

So here are all the properties that we can set through font shorthand notation. We have style, variant, weight, size, which has the optional ability to pass line height into it, and finally family. Unlike margins and padding, you can arrange the notation in almost any order that you want. In fact, there are only two values you must have and they must be in a certain order. Each font notation must contain both a size and a font family. They have to be in that order and they have to be the last two values submitted.

This type of flexibility allows us to write shorthand notation in several ways. Let's take a look at the three examples that we have listed here. So our first example would pass an italic, small-caps, bold, a font of 1.2 ems in size and a line height of 2 along with Arial and sans-serif as the font declaration. Now let's spend a little bit time looking at line height. Notice that the font size and the line height are separated by that forward slash. And in this case, for the line height, we are passing a multiple value and not an em value.

Line height is actually the only property that's not a specific font property that can be passed with the font shorthand notation. So if we don't have a lot of information to pass to the user agent on a specific element's font properties, it's really easy just to shorten things up a bit. For example, in the one below this we are passing bold, italic, 2 ems in Arial and sans-serif. We are leaving off things like small-caps that we are not setting. But take a look at Example 3. Here we are just passing a size and a font family. And in reality, that's all we really need to do.

However, there is one problem with shortening the shorthand notation the way you are seeing here. Any problem that's left out is a side, its default value for that element regardless of what is inherited or previously assigned. To explore this concept a little further, we'll practice with font shorthand notation and experience how it can get you in to trouble. So I'm going to switch over to my galleries.htm file and there are a couple of things I want to point out. We have some headings that we are going to start to style, and we would like to reduce the weight of the heading selectors by using font shorthand notation.

Well, if I look inside my galleryArticle divs, inside the mainContent, I can see that I have several headings. We have these h1 tags, followed by h2 tags and if I scroll down through the article, I can see that I have a few h3 tags. So I want to go ahead and rewrite their styles so that they are maybe not taking up quite as much code and shorthand notation offers us a really intriguing way of doing that. Well I'm going to go ahead and switch to a Split Screen view. Notice that we are using a Vertical split screen. You can get that by going up to View and making sure that it says Split vertical.

And for my related files I'm going to click on the main.css, so I'm focusing on the style sheet. You might also want to reposition your Design view so that you are looking at least at one of the headings, if not as many as you can. I am going to go ahead and scroll all the way down to the very bottom of my code, because I have stored some styles down there. So if you go all the way down to about line 626, you are going to see a comment that says Add CSS exercise code here, and that's what we are looking for. So let's take a moment to review what's going on here before we talk about customizing the CSS with font shorthand notation.

And I'm just going to resize that out a little bit so I can see these a little better, there we go. Okay, so our first rule is a group selector that's grouping the h2 and the h3s together and italicizing them. You can see that's happening, those h3s are italicizing, this h2 is italicized but the h1 is not. And then each individual selector, we have the h1 selector, the h2, and the h3. They all have specific font information that they don't necessarily share. So what we are going to do is we are going to ahead and edit these, and the first thing I'm going to do is just remove some of the existing font styling so that I can replace it with one line of code.

So I'm going to go to my mainContent .galleryArticle h1 and I'm going to start from the bottom. And I'm going to remove font weight, notice that's being set to normal and I'm going to remove line height, notice that's set to 1.75 ems, and I'm going to remove font size which is 2.5 em. So you got to remember all that. You may say, why did I start from the bottom? Well, if there is one thing that I try to avoid typing if I can, it's all these font family declarations. They take a lot of typing, you might misspell something by mistake, maybe forget to put quotation marks around something.

So I kind of like to let those settings handle that and what I'm going to do is just remove font-family and just make that font. So this will become my font shorthand notation. All right, so the next thing I'm going to do is go ahead and place in all the things that I just took out. So I'm going to type in normal, so we don't get any bolding then I'm going to do a space. Notice we don't put commas between these, we put spaces. And then font size was 2.5 ems. I'll do a forward slash to pass along the line height of 1.75. I need to make sure also that I have a space here between Georgia and line height.

So I'm going to go ahead and Save All. Then I can see my heading1 doesn't change at all but the font shorthand notation is doing exactly what I asked it to do. Wonderful! Now I'm going to scroll down and do the same thing to the galleryArticle h2 and the galleryArticle h3. So in a very similar fashion I'm going to go through and remove font weight normal, line height of 0, and a font size of 1.2. And then it will modify our font family declaration to just be the font shorthand notation. So again, remember, we took out normal, and then we just passed in 1.2 ems for the size, forward slash 0 for the line height.

And again make sure that you add some space between that value and Georgia, and then save the file. The last one we need to modify is the mainContent h3, and this one really does not have a lot being passed into it. Just the size and a family. Well that's all we really need for font shorthand notation so I'm going to remove the size, I'll go ahead and shorten that down to just font. And then in front of the font I'm going to pass the size, and it's .95 em and then a space. So then I'm just going to do a Save All. And before we test this there is one more thing that I need to change here.

Notice that the mainContent h3 rule is not as specific as the other two heading rules. We have mainContent .galleryArticle h1, mainContent .galleryArticle h2. Well, dealing with specificity and font shorthand notation is something that you really need to take serious consideration about. So I want to make sure that the values that I'm passing here are definitely passed along. So I'm going to make this a little bit more specific by typing in .galleryArticle h3, and then we'll go ahead and do a Save All. Okay, cool.

Let's go ahead and preview that in our browser and see how we did. Everything looks pretty much the same except for the fact that h2, and all of my h3s are not italicized even though I'm explicitly asking that those guys be italicized. All right, so what's happening here? Well, let's review our font shorthand notation because that's what causing the problem. All right, if I go down to my mainContent .galleryArticle h2 selector, you can see what I'm passing. I'm passing normal so that it's not bold and then 1.2 ems, 0 for line height, and then the font family.

So where is the problem? Well you will notice I didn't pass anything in for italic. For your font styles, you can either have italic or you could have normal. And for font weight, you can either have bold or you can have normal. But I just passed one normal value here. So the browser doesn't know which one I wanted, whether it was font style or font weight, so it does both. So in this case, I also need to add an italic to it, perfect. So now I have italic and normal. Now if I go down to my h3, I face a similar problem. I didn't explicitly specify whether I wanted it to be italicized or not.

Now for a header, its default is not to be italicized. So I shouldn't have assumed that it was. In fact, because of its specificity it is now overwriting this because a normal declaration is being passed along with that. So you can see that not declaring a value can sometimes get you in trouble so now I'm going to go ahead and type in italic and then a space. So now we don't really need the group selector above it. So I'm going to go ahead and get rid of that just to clean up my code a little bit. Let's do a Save All, and we'll preview that in our browser. Okay, great.

Now we are seeing both of those guys italicized and they are looking the way that we want them. So you can see that using font shorthand notation can save a lot of time and code when specing your type in CSS. But improper use can cause some unintended side effects, especially for nested elements or group selectors that overwrite previously set properties. Take great care when deciding to use the font shorthand and double check to make sure you are not adversely affecting the desired element or any of its related elements.

Show transcript

This video is part of

Image for Dreamweaver CS4 with CSS Essential Training
Dreamweaver CS4 with CSS Essential Training

120 video lessons · 41520 viewers

James Williamson
Author

 
Expand all | Collapse all
  1. 7m 50s
    1. Welcome
      1m 18s
    2. Do I need to know CSS to use Dreamweaver?
      2m 15s
    3. Using the exercise files
      1m 30s
    4. Setting up a custom workspace
      2m 47s
  2. 1h 2m
    1. Separating structure from presentation
      4m 14s
    2. Adding meaning with ID and class attributes
      7m 50s
    3. Understanding basic selectors
      11m 10s
    4. Understanding complex selectors
      11m 21s
    5. Examining the Cascade
      10m 16s
    6. Understanding order of inheritance
      5m 2s
    7. Understanding specificity
      5m 43s
    8. Using Dreamweaver to resolve conflicts
      7m 4s
  3. 52m 48s
    1. Working with starter pages
      2m 1s
    2. Defining fixed, elastic, liquid, and hybrid
      6m 3s
    3. Understanding starter page structures
      6m 25s
    4. Modifying CSS globally
      8m 58s
    5. Moving CSS between files
      12m 31s
    6. Preparing custom starter pages
      10m 9s
    7. Creating custom starter pages
      6m 41s
  4. 1h 25m
    1. Designing with CSS in mind
      3m 13s
    2. Using Fireworks to create site prototypes
      2m 41s
    3. Defining page structure
      8m 52s
    4. Creating the initial layout
      10m 24s
    5. Page creation and asset sharing
      11m 20s
    6. Using common libraries to create site prototypes
      5m 11s
    7. Building interactive prototypes
      17m 6s
    8. Optimizing images in Fireworks
      11m 47s
    9. Exporting web graphics from Fireworks CS4
      2m 43s
    10. Exporting interactive prototypes
      3m 11s
    11. When to export XHTML and CSS from Fireworks CS4
      8m 34s
  5. 48m 28s
    1. CSS workflows in Dreamweaver
      1m 17s
    2. Using the CSS Styles panel
      5m 12s
    3. Setting CSS preferences
      9m 50s
    4. Understanding Dreamweaver's CSS visual aides
      3m 50s
    5. The Code Navigator
      6m 5s
    6. Controlling CSS with the Properties Inspector
      8m 52s
    7. Using Related Files
      4m 35s
    8. Working with Live view
      4m 12s
    9. Working with the Reference panel
      4m 35s
  6. 1h 13m
    1. Declaring font families
      4m 57s
    2. Creating custom font family declarations in Dreamweaver
      6m 0s
    3. Understanding units of measurement
      6m 14s
    4. Controlling font sizing
      8m 41s
    5. Controlling line spacing
      7m 20s
    6. Controlling vertical margins
      7m 52s
    7. Horizontally aligning text
      3m 16s
    8. Vertically aligning text
      5m 30s
    9. Vertically centering block-level elements
      10m 31s
    10. Setting column width
      3m 33s
    11. Using font shorthand notation
      9m 15s
  7. 1h 10m
    1. Background properties
      4m 33s
    2. Using background images
      5m 16s
    3. Controlling background image tiling
      5m 33s
    4. Positioning background images
      4m 42s
    5. Using percentage values for positioning
      5m 10s
    6. Creating custom list bullets
      5m 23s
    7. CSS drop shadows
      7m 40s
    8. Image replacement techniques
      7m 24s
    9. Adding screen-only content
      7m 51s
    10. Complex background graphics
      9m 10s
    11. Using CSS Sprites
      8m 0s
  8. 38m 48s
    1. Reviewing table tag structure
      4m 48s
    2. Using thead and tbody for styling
      5m 45s
    3. Styling table captions
      4m 30s
    4. Styling headers
      8m 29s
    5. Styling table content
      4m 18s
    6. Creating alternating row colors
      3m 29s
    7. Using pseudo-class selectors for tables
      2m 27s
    8. Creating custom table borders
      5m 2s
  9. 43m 37s
    1. Examining form structure
      3m 26s
    2. Styling fieldset and legend elements
      7m 42s
    3. Styling form elements globally
      6m 31s
    4. Using classes to identify form elements
      5m 55s
    5. Styling user feedback
      6m 10s
    6. Adding user interaction
      2m 52s
    7. Styling Spry form validation fields
      11m 1s
  10. 44m 48s
    1. Using lists for navigation
      1m 40s
    2. Creating horizontal menus pt. 1: Stripping list styling
      3m 28s
    3. Creating horizontal menus pt. 2: Displaying links horizontally
      3m 54s
    4. Creating horizontal menus pt. 3: Styling links
      5m 25s
    5. Creating horizontal menus pt. 4: Rollovers
      3m 48s
    6. Creating horizontal menus pt. 5: Indicating current page
      3m 48s
    7. Creating horizontal menus pt. 6: Modifying cursor usage
      2m 11s
    8. Creating horizontal menus pt. 7: Positioning menus
      3m 8s
    9. Styling vertical menus pt. 1: Vertical menu considerations
      6m 42s
    10. Styling vertical menus pt. 2: Defining width for link elements
      4m 46s
    11. Styling vertical menus pt. 3: Using background graphics with navigation
      5m 58s
  11. 1h 40m
    1. Box model review
      7m 4s
    2. Understanding margin collapse
      7m 15s
    3. Reviewing normal document flow
      11m 0s
    4. Understanding floating
      8m 56s
    5. Containing and clearing floats
      9m 26s
    6. Understanding relative positioning
      5m 30s
    7. Understanding absolute positioning
      5m 29s
    8. Understanding the AP Elements panel
      11m 57s
    9. Understanding fixed positioning
      2m 24s
    10. Using Dreamweaver to define document structure
      10m 11s
    11. Creating a two-column layout
      17m 1s
    12. Using Dreamweaver's Design-Time style sheets
      3m 49s
  12. 28m 59s
    1. Introducing Spry widgets
      2m 18s
    2. Updating the Spry framework
      45s
    3. Examining the default Spry styles
      6m 36s
    4. Modifying tabbed panels through CSS
      5m 18s
    5. Styling Spry widgets
      8m 49s
    6. Organizing Spry style sheets
      5m 13s
  13. 34m 49s
    1. Creating print style sheets
      2m 57s
    2. Assigning media types
      3m 29s
    3. Styling type for print
      9m 21s
    4. Suppressing element printing
      3m 29s
    5. Controlling page breaks
      8m 39s
    6. Using @media blocks
      3m 5s
    7. Creating alternative style sheets
      3m 49s
  14. 35m 22s
    1. Using Dreamweaver's Browser Compatibility Check
      3m 58s
    2. Fixing code errors with Adobe's CSS Advisor
      4m 45s
    3. Strategies for browser compatibility
      5m 8s
    4. Implementing browser compatibility
      8m 18s
    5. Formatting code for deployment
      3m 15s
    6. Creating modular style sheets
      3m 38s
    7. Assembling modular style sheets
      6m 20s
  15. 38s
    1. Goodbye
      38s

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 Dreamweaver CS4 with CSS Essential Training.

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.