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

Adjusting paragraph line height


CSS: Core Concepts

with James Williamson

Video: Adjusting paragraph line height

Now on the surface using the Line Height property seems pretty simple. Line Height controls the spacing between lines of multiple lines of text. If you're a graphic designer, you're probably used to calling it leading. It is exactly the same concept. Line Height can get pretty tricky however when you have to consider how the values are calculated and if Line Height is being inherited or not by child elements. So for this exercise, we're going to be using the line-height.htm file, which can be found in the 04_13 directory.
Expand all | Collapse all
  1. 4m 54s
    1. Welcome
    2. Using the exercise files
      4m 2s
  2. 1h 8m
    1. Exploring default styling
      4m 56s
    2. CSS authoring tools
      2m 29s
    3. CSS syntax
      4m 45s
    4. Writing a selector
      4m 10s
    5. Setting properties
      8m 40s
    6. Common units of measurement
      7m 47s
    7. Inline styles
      5m 1s
    8. Embedded styles
      5m 19s
    9. Using external style sheets
      10m 35s
    10. Checking for browser support
      8m 48s
    11. Dealing with browser inconsistencies
      5m 30s
  3. 2h 15m
    1. Structuring HTML correctly
      2m 51s
    2. Element selectors
      4m 52s
    3. Class selectors
      6m 4s
    4. ID selectors
      3m 27s
    5. Using classes and IDs
      10m 7s
    6. Element-specific selectors
      4m 35s
    7. The universal selector
      5m 42s
    8. Grouping selectors
      4m 49s
    9. Descendent selectors
      7m 32s
    10. Child selectors
      5m 7s
    11. Adjacent selectors
      5m 30s
    12. Attribute selectors
      12m 43s
    13. Pseudo-class selectors
      3m 54s
    14. Dynamic pseudo-class selectors
      8m 29s
    15. Structural pseudo-class selectors
      6m 45s
    16. Nth-child selectors
      13m 10s
    17. Pseudo-element selectors
      12m 40s
    18. Targeting page content: Lab
      8m 56s
    19. Targeting page content: Solution
      7m 59s
  4. 44m 54s
    1. What happens when styles conflict?
      4m 0s
    2. Understanding the cascade
      5m 47s
    3. Using inheritance
      8m 26s
    4. Selector specificity
      6m 55s
    5. The !important declaration
      4m 5s
    6. Reducing conflicts through planning
      3m 33s
    7. Resolving conflicts: Lab
      6m 45s
    8. Resolving conflicts: Solution
      5m 23s
  5. 1h 47m
    1. Setting a font family
      7m 10s
    2. Using @font-face
      9m 19s
    3. Setting font size
      7m 35s
    4. Font style and font weight
      6m 52s
    5. Transforming text
      3m 58s
    6. Using text variants
      2m 49s
    7. Text decoration options
      4m 26s
    8. Setting text color
      3m 2s
    9. Writing font shorthand notation
      8m 49s
    10. Controlling text alignment
      6m 33s
    11. Letter and word spacing
      9m 11s
    12. Indenting text
      4m 30s
    13. Adjusting paragraph line height
      10m 30s
    14. Controlling the space between elements
      6m 41s
    15. Basic text formatting: Lab
      8m 45s
    16. Basic text formatting: Solution
      7m 14s
  6. 2h 1m
    1. Understanding the box model
      16m 53s
    2. Controlling element spacing
      14m 29s
    3. Controlling interior spacing
      10m 50s
    4. Margin and padding shorthand notation
      6m 27s
    5. Adding borders
      8m 57s
    6. Defining element size
      10m 7s
    7. Creating rounded corners
      6m 58s
    8. Background properties
      2m 51s
    9. Using background images
      5m 11s
    10. Controlling image positioning
      10m 25s
    11. Using multiple backgrounds
      7m 5s
    12. Background shorthand notation
      5m 25s
    13. Styling container elements: Lab
      7m 56s
    14. Styling container elements: Solution
      8m 17s
  7. 47m 51s
    1. Color keyword definitions
      5m 4s
    2. Understanding hexadecimal notation
      6m 5s
    3. Using RGB values
      4m 58s
    4. Using HSL values
      5m 17s
    5. Working with opacity
      2m 23s
    6. Using RGBa and HSLa
      3m 8s
    7. Styling drop shadows
      5m 38s
    8. CSS gradients
      6m 32s
    9. Working with color: Lab
      4m 26s
    10. Working with color: Solution
      4m 20s
  8. 1m 58s
    1. Additional resources
      1m 58s

please wait ...
Watch the Online Video Course CSS: Core Concepts
8h 52m Beginner Nov 22, 2011

Viewers: in countries Watching now:

In this hands-on course, James Williamson demonstrates the concepts that form the foundation of Cascading Style Sheets (CSS), including styling text, adding margins and padding, and controlling how images display. The course also explores the tools needed to work with CSS, the differences between embedded and external styles, how to use selectors to target elements, and what to do when styles conflict.

Topics include:
  • Exploring default styling
  • Writing a selector
  • Setting properties
  • Working with common units of measurement, including ems and pixels
  • Structuring HTML correctly
  • Understanding the cascade and inheritance
  • Setting a font family, font size, text color, and more
  • Understanding the box model
  • Styling container elements
  • Working with RGB vs. HSL values
  • Styling drop shadows
James Williamson

Adjusting paragraph line height

Now on the surface using the Line Height property seems pretty simple. Line Height controls the spacing between lines of multiple lines of text. If you're a graphic designer, you're probably used to calling it leading. It is exactly the same concept. Line Height can get pretty tricky however when you have to consider how the values are calculated and if Line Height is being inherited or not by child elements. So for this exercise, we're going to be using the line-height.htm file, which can be found in the 04_13 directory.

And I'm just going to Preview this in a browser before we begin working with it to sort of show you what the page structure is going to look like. So we have a couple of headings followed by paragraphs, and we have a span tag right here that has a background color that's going to help us illustrate exactly what Line Height is doing for us. Now, if I go back into my page, you can sort of see that structure within the code. So we just have some headings followed by paragraphs. We're also going to notice that we have, in this h2, a class called center, where we're going to vertically center the text and the element using Line Height as well. Okay.

So I'm going to go right up to my existing selectors and I'm going to find the paragraph selector, and we're going to play around with some of the initial values of what we can do with Line Height. So just below font-size, I'm going to create a new line for another property and here I'm just going to type in line-height, so it's line-height. Now, remember, from earlier when we were talking about the font shorthand notation, this is a property just like font-weight, font-size, font-style, that can be added to the font shorthand notation. All right. So the values that we have here, one of the possible values is normal, so let's just use that as the first value.

So if I say normal, I Save this and I go back into my browser and Refresh it, we're not really going to see any difference. That's sort of the default. Now, every browser is a little bit different, but typically the Line Height is 1 to 1.2 times the size of the font. So we can also use a specific number, a length, or a percentage. Let's take a look at what each one of those does for us. If I come in and do a percentage, let's say I do 140%. So if I Save that and test it, now what it's doing is it's basically taking a look at the size of the text, and then it's giving you a Line Height that is equal to 140% of that.

You can see that it opened up the spacing a little bit, but not a lot. All right. Now, we can also use a length value. If I use a length value, let's say I use something like, I don't know, 1.4ems, all right, so if I Save this and test it. Wow, no movement whatsoever. So 1.4ems is very similar to 140%. Really, a lot of times you're just kind of splitting hairs between one unit and the next. And then we have a third way that we can write this syntax. We can just go ahead and get rid of the unit of measurement altogether.

Now, Line Height is unique in the fact that it is the only property that allows us to do multiples like this and not a unit of measurement after that. Essentially this means 1.4 times the size of the text. If I Save this and test it, you've probably already guessed this, no change whatsoever. 1.4ems and 140% all pretty much render the same. There are really three different ways of writing a very similar value. However, there is a big difference and a big value in terms of how this property is inherited, in terms of how you write that.

So it does matter and we're going to get into that in just a moment. First, I want you to be able to visualize Line Height a little bit better than we're currently visualizing it right now. So here's what I want to do. I want to go down to the span rule, and I'm going to change it's value to display or actually add to its value the display property. Now, the display property is awesome and it's something that you'll learn more about in the CSS Layout course. But the display property allows you to change how an element is displayed within the browser. Most of our elements are either block- level elements, meaning they occupy their own space in the document flow, or they're inline elements, meaning they can appear side-by- side like images and spans.

Well, there's other values that we can use too. And here I'm going to use inline-block; Now, what that does for me is, it means that the span element should still behave as an inline character, but I want it to display its properties like a block-level element. Now what that's going to do for me is it's going to allow it to display its full height. So if I Save this and go back into my page and Refresh it, you can see there's a slight difference there. So let me go ahead and kick up the line- height a little bit more, let me take it up to 1.6. There we go. Now we can really see the difference. So what you're seeing here is you're seeing the exact line-height of this line of text.

You can see it extends down a little bit and extends above it and is based on the ascenders and descenders of the characters. So it just simply uses the baseline as sort of that starting point, and then it goes above and below based on the values that you give it. So the higher that value, obviously the higher that is. And if you could imagine these being boxes stacked on top of each other, the height of that box is controlling the space between the lines. So that helps me sort of visualize exactly what's happening here. You can even take that further, if I went down into my span and I did just that span element.

So if I did a line-height here of say 2 .6, that's really going to make a huge difference, trust me. If I test that, you can see now how different this line is compared to all of the other lines. And if you do have something like this where you have the span tag with one line-height and you have this line that actually has another line-height, the greater value is used. So in this case, the greater value is used for that line. Okay. I'm just going to delete that property. Now, I mentioned earlier that it really mattered in terms of how you write line-height if the value is being inherited, and I want to show you that.

I'm going to remove the line-height from the paragraph and I'm going to go up to our body selector. Now, again, we've been doing this pretty much the whole course, applying properties to the body selector and then sort of letting those be inherited by the elements below it. So if I come up here and I do a line- height and let's say I do a line-height of 1.6ems and I Save this and I test it. So we go back to a consistent line-height all the way through. Now what's happening here is a lot different than using a multiple.

When you use an em, here's what happens. It takes a look at the font-size, which in this case would be about 16 pixels. And then because it's using an em, it goes ahead and multiplies 1.6 times whatever the default would be, in this case 16 pixels, computes that value and then that is the value that's passed down to every single element, every one of them. They all get that computed value. That means that this relative unit of measurement is only relative for the body, everybody else gets a fixed unit. Now, on the other hand, if I take away the em and I just do a multiple, if I Save this, take a look at what happens.

When I Refresh the page, everything changes, everything moves down a little bit, everything gets spacing that's a little bit different. Because now what happens is instead of calculating the value first and having the calculated value pass down, what happens is it passes down a line height of 1.6. So every single one of these guys now gets 1.6 times its own font-size. So that gives you a little bit better spacing in terms of the relationship between those elements. So if you're ever going to pass line- height in as an inherited value, make sure that you use multiples and not ems.

It's very, very important that you do that. So now I'm going to Save this and we're going to move on to doing our last little thing, which is using line- height to force text to be centered vertically in an element. I use this technique a lot in menus, where I have sort of a horizontal menu and I want the text vertically centered. Really, it works if there's a single line of text. If you have multiple lines of text, this is a little bit harder to pull off. So what I'm going to do is I'm going to go down, again, just to remind you of who we're affecting here. We have the heading2 that has a class called center, so that's what we're going to work with.

So I'm going to go right back up here to my styles and I'm just going to create a new selector, .center. And then inside that, I'm going to give it a color of #fff That's white, by the way, that's actually a hexadecimal notation. You could do the exact same thing by just saying white. It doesn't really matter which one you do. For background, we're going to use more hexadecimal notation. Here we're going to do #666, which is not as ominous as it sounds. It's just a gray. And then below that, here's the magic, we're going to do line-height 50 pixels.

And then I'm going to do a padding-left 25 pixels. And all the padding to the left is going to do for me is make sure that the text is not butting up against the left edge of the element, the background. But line-height, here's what this does. If you haven't specified the height of an element, its line-height is going to generate that height for you. If you have a single line of text, that means that the line-height becomes the height of that entire element. The text itself, because it's centered on that baseline, will then be vertically centered in that box, and this is a very elegant way to do this.

If I Save this and go back in the browser and Preview it, now when I scroll down, notice that we have our Other uses headline here, the text is vertically centered in the box. And if I wanted to adjust the height of that, all I would need to do is come in here and adjust the line-height. So I can go to 75 pixels, Refresh it, and you can see it stays vertically centered, and now the height of the box is adjusted. Now, again, this works best when there's a single line of text in there. When you have multiple lines, then you have to really work to keep everything the way you need it to be. Okay.

That's the basics of line-height, and I know it seems like I've probably covered a lot there, but it is an incredibly powerful property. You're going to be using it probably over and over again to adjust the spacing of elements on the page. Now, I want to really encourage you to think carefully about how you're going to plan to use line-height in your overall site-wide typographic strategy. If you place line-height on the body selector, you do determine a starting baseline grid for the entire page. However, you need to think about how you might need to modify that spacing for certain elements or page regions and how those values are going to be calculated, so really sort of how they're going to inherit that property.

And if you do that, you're going to have a consistent vertical rhythm to your text and the spacing is going to look extremely natural. Now, if on the other hand, you simply just go ahead and add line-height values to any element without really considering how it might impact other elements or work with other elements on the page, your content is going to look a little disjointed and ragged. In other words, be extremely deliberate in how you use it.

There are currently no FAQs about CSS: Core Concepts.

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


You have completed CSS: Core Concepts.

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


Upgrade to View Courses Offline


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

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