Start learning with our library of video tutorials taught by experts. Get started
Viewers: in countries Watching now:
Learn how to choose fonts for a web site and create beautiful, legible type. Author Laura Franz shares how to create designs that maximize readability (and keep visitors on the page) by paying attention to details in size, line-height, line length, alignment, color, vertical space, and more. Laura also demonstrates how to incorporate web fonts, style type with CSS, and pick fonts that work well together.
In this lesson, we're going to build the two column system of hierarchy for our sans serif bibliography. This will involve defining new divs in the CSS and adding them to our layout in the HTML. You need the files biblio_sans_heirarchy. html and biblio_sans_hierarchy.css from the Exercise folder. You'll also need the biblio_sans_hierarchy.jpg. It's a mockup of the layout which we'll use to find the width of our two new divs. Open up the HTML file in the browser to see what we're working with.
You can see most of the system of hierarchy is in place. I've moved the h1 into its own div and I've already added the new levels of hierarchy and new vertical spacing system. I used the same kind of syntax as we used with the serif version of the bibliography. This way we can focus on using the new divs to control placement of our section heads. You can see our section heads, the h2s, are not in the right place yet. We want them in a separate column. So how are we going to make this work? Let me show you.
So far we've been using a single div. We're going to use a second div, so we'll have two divs side by side. We also need to make sure the h2s in the left div line up properly with the text in the right div. So we're going to use a third div and wrap each section as needed. We're going to call these divs resource_list_container, that's the one we've already been using, section_head_container, and section_container because it'll hold the whole section. Also just a reminder, I prefer to use the word container because it helps me visualize that the divs contain their elements.
If you prefer the word wrap or wrapper, please feel free to use it. Either way, I highly recommend to use a descriptive word so when you add the div into the HTML, the name of the div will tell you something about what its purpose is on the page. Now let's open up our CSS file and get started. You can see I've added two new divs. The IDs here is section_head_ container and section_container, but I haven't described them yet and we'll do that now. So we need to ask ourselves what do we know about these containers.
Well, we know we want them all to float so they'll stay next to each other in a row, so we're going to add float:left. We know we want them to have an auto-height so they open up to hold as much text as necessary. So we'll go ahead and just make them height:auto. And since the section_container will only have floated divs in it and no content of its own, we're going to have to force the div to recognize the floated divs inside of it. Otherwise the auto-height won't work.
And we're going to do this by making sure we add an overflow:hidden. Our heights are taken care of. Now for the widths. We know what the width of the resource_list_container is. here it is its 45 em because we've been using it, but we don't know what the widths of the two new divs are yet. So let's open up that JPEG from the Exercise folder in your imaging software and find the widths of the divs. I'm in Photoshop. You can use your Ruler tool which is found under the Eyedropper tool and you can click and drag to find the width of your section_head_container.
I've already done it here. You can see at the top the width is 150 pixels. And we're using ems and we have a base font size of 10 pixels so we know that this is 15 ems. Let's go back in the CSS and add that. There's our section_head_container, width:15em. We also know that the section_ container contains these two divs. One of them is 15 em.
The other was 45 em, so this one, if we add them together, is 60 em. One last thing, we're going to add a border around our section_container because it will help us to see what's happening as we set up our layout. So we're going to do border:1px solid black. that will work for us. So the divs are described but now we need to put them where they belong in our HTML. I'm going to save this file and go to my HTML file.
Here we have the original div, the resource_list_container, but our h2 doesn't live in that container anymore. So what I'm going to do is highlight that starting tag. I'm going to cut it with either Command+X or Ctrl+X. I'm going to paste it so it's the start of the actual resource list. And then we've been using this div to hold all this content. We don't want that to happen anymore. We will go ahead and cut the end tag. I'm going to scroll all the way back up to the top.
I need to find the end of my resource list, so that's here with the h3, there's my second h3, my third h3. Right here before the next section header is where I need to end that div. So the resource lists are in their own container. I also need to put the h2 in its new container. div id= and I need that section_head_ container and I need to end that as well.
So the section head is in it all by itself. And then I need to wrap these two divs in the section_container. div id="section_container" and the section_container is going to wrap both of these divs, so I'll end it here. I'm going to go ahead and save this and review it in our browser.
And we can see that I have the section_ container and it's wrapping my section head and my resource list. We can see that the other text, it's no longer in a div so it's sort of floating outside that black box. That's okay. That's why I had to put the black box in. So when you saw this sort of wonky thing happening, you know it's okay. Let's go in and do the next section as well. I'm going to do it from the outside in this time. So we have our section container, div id ="section_container", and we're going to end the wrap at the end of the section.
And then I now need to do my section head here and that ends right at the end of my section head. And I also need to make sure my resource list is also wrapped. div id="resource_list_container" and I'm going to end it down here at the end of the resource list for this section.
And the last thing I'm going to do, because I haven't typed that one in a while because I just copied and pasted it, I'm going to go up and make sure I'd named it correctly and I did. Okay, let's save that. I'm going to go back to our browser. I'm going to reload that and I've got two of them. Great! They both worked. Now we're working on a wide monitor here, so you can see that they are coming up next to each other instead of one after the other. And that's okay. That's happening because they're floating and we're going to fix that in a minute. But first what I'd like you to do is go and put in the divs for that last section.
I think I've actually two more sections to go. Do those last two sections on your own and I'll meet you back here. Now that all the sections are wrapped, we're going to do two more things to help make our typography look better. Just double-checking here, everything is wrapped. It looks great. we're going to go into our HTML. We're going to wrap the divs up neatly in a main container. That'll help us move the text away from the left edge and it'll help them be in a column. And then we're also going to remove the borders on the section containers as well. So we'll get started in the HTML by doing a main_container.
So above our h1_container here, because we want that to be in our main container as well, do a div id="main_container". And then all the way down, scroll, scroll, scroll to the very end, right before we're ending our body tag, that's where we're going to end our main_container. So I'll save that and then we'll go into our CSS. All right! In our CSS, let's make a new ID for our div here. We'll call it main_container.
We'll use our curly brackets. We want it to have a width of 60em because we're working in ems. We want it to have a height:auto so that it will hold everything. We're also going to use another overflow:hidden, and that way we'll force it to open up and hold all of the content even though the other content is on floated divs. And let's see. We're also going to do margin. We're going to do a 0px and an auto. I know I said I wouldn't use shorthand but here I am using it.
This will give us no space top to bottom, but it will make the div stay in the center of our browser by using auto right and left margins. That's good. That's all we want for that. We're also going to go down and take that border off of our section_container. Let's delete that. We'll save and let's view this again in our browser. Hit Refresh. All right! Excellent! Let's see. Everything is flowing down in our column.
And we can see that our section head is there, our h2s are in the left column, but we can also see there's a problem. The spacing between the two divs, there's just not enough space in some of them. It's okay here, but on some of them they're not, so we're going to have to fix that. We also need to add our rule lines. We're going to take care both of those things in the next lesson.
Find answers to the most frequently asked questions about Typography for Web Designers.
Here are the FAQs that matched your search "":
Sorry, there are no matches for your search ""—to search again, type in another word or phrase and click search.
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.