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

Defining a percentage-based page with ems


From:

Typography with CSS in Dreamweaver

with Joseph Lowery

Video: Defining a percentage-based page with ems

As noted in the introductory video for this chapter, the percentage-based ems have a lot to recommend them, including easy scalability and better accessibility. However, defining your em sizes to match your pixel-based comps can be a hassle. Let me explain why and show you a way around that issue. If no percentage font size is declared, the default is assumed to be 100%. While this is fine, it makes it difficult to relate ems to pixel sizes. Let me walk you through the math.
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

please wait ...
Watch the Online Video Course Typography with CSS in Dreamweaver
2h 30m Intermediate Jul 29, 2011

Viewers: in countries Watching now:

Dive deep into key typographic concepts and learn how to manipulate type in Dreamweaver. Author Joseph Lowery introduces Dreamweaver type tools and shows how to perform basic text modifications, establish the appropriate type unit, integrate custom web fonts, and apply drop shadows, gradients, and other effects. The course also provides in-depth tutorials on structuring text with headings, paragraphs, columns, and lists, and offers a preview of Adobe's proposed CSS Regions.

Topics include:
  • Modifying type in the CSS Styles panel
  • Understanding the different type measurement unit options
  • Allowing users to set page type size
  • Employing web-safe fonts
  • Exploring CSS 3 typeface options
  • Setting up @font-face
  • Applying color and transparency to type
  • Styling the font weight, case, and letter spacing
  • Inserting drop caps
  • Rotating text with CSS transform
  • Laying out text in multiple columns
  • Incorporating ordered and unordered lists
  • Targeting lists items with the nth-child selector
Subject:
Web
Software:
Dreamweaver
Author:
Joseph Lowery

Defining a percentage-based page with ems

As noted in the introductory video for this chapter, the percentage-based ems have a lot to recommend them, including easy scalability and better accessibility. However, defining your em sizes to match your pixel-based comps can be a hassle. Let me explain why and show you a way around that issue. If no percentage font size is declared, the default is assumed to be 100%. While this is fine, it makes it difficult to relate ems to pixel sizes. Let me walk you through the math.

The default font size for text in browsers is equivalent to 16 pixels. If a comp calls for text that's 14 pixels tall as with the paragraph text that we see here, you'll have to figure out the percentage of 16 that is equal to 14. While the math isn't really that difficult, it's 14 divided by 16, it's a pain to have to figure out for every heading, paragraph, table cell, and list item in a design. A far easier approach is to set the initial overall font size to 62.5%.

This has the effect of establishing a Base 10 System because 62.5% of 16 is 10. This means that if you wanted your p tags to be 14 pixels tall, you would make them 1.4 ems and your 26-pixel tall h1 would be 2.6 ems, and so on. Suddenly, your em conversion problem has vanished. So let's put that technique to practice and I'll show you how to overcome one of the ems measurement units inherent problems along the way.

So in Dreamweaver, I have opened resources.htm from the Chapter 2 > 02_03 folder, and I'm in Live view. My CSS STYLES panel now is open in Current mode, so we can make some selections and see the related rules. We're going to start by going to the body tag and changing the font size percentage. So here, you can see over in the CSS STYLES panel because no other element is selected on the page, it defaults to the body rule, and you can see by looking at the font property that we're using the shorthand technique.

So I'm just going to go ahead and put in the percentage size here, 62.5%. Now if you're not using the shorthand technique, you could just enter in a font-size property and make that 62.5%. I'll go ahead and hit Return and you'll see a radical change. So let's go in and make the necessary adjustments. I'm going to work top to bottom here. So let's go ahead and start off with the word, Resources, which as you can see is in a div called pageID, and over here we have the rule, #mainContent h1pageID.

So I'm going to go ahead and add in a font size for here, and according to the comp I'm following, which I don't have on screen, this should be 22.5 pixels tall. So I'll make that 2.25 ems. Now let's work with my h1 tag, the "Got questions" that you see here, and this will change the font size to the equivalent of 32 pixels or 3.2 ems.

Now I'm going ahead and just typing in the two letters em to make it a little bit quicker. If you're not that familiar with the syntax, you can always choose that option from the dropdown list. Alright, what about our main body paragraphs? So in this case, because I want this to be a more universal solution, I'm not going to go with the first rule that was selected, which is #mainContent #mainArticle p, instead I want to go for something more general which is #mainContent p or paragraph, and this will affect a paragraph anywhere, not just in the div called mainArticle.

So font size, we want this to be the equivalent of 16 pixels. So it's 1.6 ems and let's work our way down a little bit more. Here's a h2 tag that needs to be 25.5 pixels high. So now we'll add a font size equivalent to 25.5 pixels and I'm sure you've gotten into the rhythm of this, so we'll put in font size and make it 2.55 ems.

You're basically just shifting over the decimal point. Now let's do one without a decimal point, this h3 tag that we see here, we'll give it a font size equivalent to 20 pixels and now we've gotten all of our text headings and paragraphs handled. Let's continue to scroll down the page a bit. Everything is looking good, until we get to the list items. Now because these are in an li tag instead of a p tag, they still appear too small.

So we'll have to specify a CSS rule for them and the one we're looking for is the #mainArticle li and you can see that here. So we want this to appear the same size as the text, which if you recall, was 1.6 ems. So I'll put in a font size of 1.6 ems. Alright, looking pretty good! Now here is that catch that I've been telling you about with ems. Whenever you have a nested tag like a li inside of an li, you get a very strange reaction.

It actually can grow bigger. So what you need to do is to specify a rule just for this area. There's a couple of ways to approach this, but one primary technique is just to set the font size to 100% and that will work regardless of how many nesting levels that you have. Alright, I am going to go ahead and put my cursor in here and let me expand this box just a little bit, so you can see that, in fact, there already is a CSS rule for the nested list items. Here we have "#mainContent #mainArticle li li." So font size and we want this to be, as I said, 100% and again, I'm just going to go ahead and type that in.

Now everything is exactly the same size on our page and we're looking pretty good. Let's scroll down just a bit more. Now you'll notice that the footer paragraph, if I scroll back up, and the sidebar text are a bit small. I'll leave adjusting those CSS rules to you as practice for working with ems.

There are currently no FAQs about Typography with CSS in Dreamweaver.

 
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

Congratulations

You have completed Typography with CSS in Dreamweaver.

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


OK

Upgrade to View Courses Offline

login

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

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.

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

Start your FREE 10-day trial

Begin learning software, business, and creative skills—anytime,
anywhere—with video instruction from recognized industry experts.
lynda.com provides
Unlimited access to over 4,000 courses—more than 100,000 video tutorials
Expert-led instruction
On-the-go learning. Watch from your computer, tablet, or mobile device. Switch back and forth as you choose.
Start Your FREE Trial Now
 

A trusted source for knowledge.

 

We provide training to more than 4 million people, and our members tell us that lynda.com helps them stay ahead of software updates, pick up brand-new skills, switch careers, land promotions, and explore new hobbies. What can we help you do?

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.