Start learning with our library of video tutorials taught by experts. Get started
Viewed by members. in countries. members currently watching.
In Dreamweaver CS5 Essential Training, Adobe Certified Instructor James Williamson explores the tools and techniques of Dreamweaver CS5, Adobe's web design and development software. This course covers both the ins and outs of Dreamweaver, as well as recommended best practices for crafting new web sites and files, the fundamentals of HTML and CSS, and how to ensure clean and accessible code. The course also includes how to use tools in Dreamweaver to create and style web pages, manage multiple sites, and add user interactivity with widgets and scripting. Exercise files are included with the course.
Our final movie in this chapter will focus on putting a little bit of everything we've covered so far together, while focusing on the concept of using the cascade to control styling. When creating the CSS for your sites, your focus should be on writing the cleanest and most efficient styles possible. By utilizing the cascade, you can write generic styles that handle the bulk of your styling work, leaving you to write just a few very specific selectors when styling in one area varies from the global standards that you've set.
This method requires that you spend a good bit of time planning a site-wide strategy for typography for your site. To be honest, that's a really good idea. It helps your site be more consistent, requires less code to achieve the desired results, and saves development time since you won't be constantly overwriting and rewriting your styles. Now, we've got opened an unstyled page here. Yes, it has some layout. Yes, it's got some graphics in it, but the typography of this page is totally unstyled at the moment. So the first thing that we're going to do, and that's what we'll be do in this movie, is to create our global styles.
And then in the next movie, we'll follow that with just a few area-specific styles that are required to finish up our desired formatting. So what we have opened is the resources.htm, and this is found in the 07_10 folder. Now, the first thing we're going to do is I'm going to switch this to a Split screen view. I want my code on the left, and I want my design on the right. Just to give us a little bit more screen real estate, I'm going to take our panels, and I'm going to collapse those panels down. So I can do that in the other upper right-hand corner of the dock. I can collapse those icons and then I can grab the separator and just sort of push them a little further over so I only have icons over there.
Now, why am I doing all that? Because we are going to do a little bit of hand-coding in this movie. Now don't panic. It's not that hard. You've had a lot of experience so far in this chapter by using the CSS Styles panel. You've had a lot of experience go-ahead and opening up the CSS Rules Definition dialog box, and entering in values there, so now it's time to do a little bit of hand coding. I promise we'll go slow. We'll get through it. It's going to be okay, and I guarantee you you're going to think to yourself after you are done with this, "Hey, that's not so bad." All right.
So what I need to do is, up here underneath the name of the file resources, I need to click on my main.css, so I have that open. So we're looking at our CSS on the left-hand side. We're looking at our design on the right-hand side, and we'll be able to kind of focus back and forth between the two in order to do what it is that we need to do. So the first thing we need to do - I'm going to scroll down - is around line 55 I'm going to place my cursor right there, and I'm going to do our limited-scale reset. Now remember, earlier we take a look at this, and that's basically zeroing out all the margins in the paddings, so that instead of the default margins of paddings that the browser might give our elements, we are in-charge of writing those.
So it sort of resets everything so that we're in control of it. So the first line I'm going to type in h1,h2. Now I want to talk about that comma for just a moment. Spaces between selectors mean that you're looking for one selector inside of another one, but the commas are way of grouping selectors together, so that comma is a way of saying, both the h1 and the h2. All right. So we're going to do another comma. We're going to do h3,h4,h5 so it's a pattern, ,h6. There we go ,p,address,blockquote,div,ul,li and if it breaks on you don't worry. It's okay. All right.
So we're good there. Now, I'm going to open up a curly brace. Now, where do I found those? Well, on your keyboard, just at the right of the P key, you have your opening and your closing curly braces, and you have to hold down the Shift key to get them. So I want to open in curly brace. Now as soon as you do that, Dreamweaver is trying to help you out. It's giving you a full list of properties that you can set for this particular selector that we've just created. I'm going to hit Return, so that we go down in the next line, just in keeping with the formatting options that they've already been doing. Here I'm going to type an m. It will jump down to margin, and that's exactly what I want. So this is a process called code- hinting, and it helps you rapidly write code.
By just hitting m, I jumped down this list to margin, and now when I hit Return, Dreamweaver finishes it for me. It not only finishes typing it, but notice that it typed in a colon for me as well, so it's helping me with the syntax too, which is really cool. Now, I'm going to type in 0 and then a semicolon. Semicolons are used to say "Okay, this property is over. Let's move on to the next one." Go down to the next line, and here you want to type in padding, or actually you can just type in p. It's going to jump down the padding. You can hit Return, and once again, I can type in 0 and the semicolon.
Here is the tricky part of handwriting CSS. Usually where people get themselves in trouble they just sort of forget to do something. In this case, we've opened up our curly brace, but we haven't closed it yet. So right after padding, I'm going to hit Return, and then I'm going to close my curly brace. There we go. So every single CSS selector and rule needs to have that opening and closing curly brace. Don't forget those. Okay, so if I save my file, I can just do a Save All, and if I click over in Design view, everything sort of shifts and get closer together. So that's us removing all that default spacing, so there we go.
Now remember, we're writing our global styles here. We're not targeting any one specific area. We're writing the styles that are going to pertain to the entire site globally. So we're going to be writing a lot of element selectors, a lot of really basic selectors that are going to be driving the look and feel of our site. So I'm going to go down on just a little bit further in my code and just below my scale reset that we just did on our blank line there, I'm going to type in p. That is an element selector that targets the paragraph tags. So the first thing we're going to do is we're going to tell our browsers what we want our paragraphs to look like.
Again, I'm going to open my curly brace and hit Return, and now I'm going to start styling my paragraph. The first thing I want to do is change the color of my paragraphs. The default color is black. I want something a little bit different. So I'm going to type in co, and it jumps right down to color. So sometimes you have to type almost the whole word, sometimes a single letter will do it, but I'm going to get right down the color and hit Return. And now I'm going to type in that #333. Notice that even here in Code View the color picker comes up. And if we wanted to, we could have gone right there to find #333, and select it from the Swatch panel that comes up.
So now I'm going to type in a semicolon, hit Return to go down to the next line, and here I'm going to do line-height. I'm letting code hinting finish a lot of this stuff for me, so line-height: 1.8. Now, you'll notice that I'm going to type in a semicolon and not pick any unit of measurement, no percentages here, no ems. Now, the reason for that is because for line-heights we're using a multiple and multiples don't require any type of unit a measurement after it. Remember, the only property that we can do that with is line-height. I'm going to go down to the next line, and here I'm going to type in margin-bottom.
So margin-b, and you should be able to just hit Return and let Dreamweaver finish that for you. Margin-bottom:1 em; Once again, don't forget to close your curly brace and when you see the rule below you turn magenta again, you know you have done the right thing. Now if I click over in Design view, you can see that our paragraphs are formatting. They get their line spacing. They get the color we want - looking pretty good. Okay, we have a few links to write. And this time you're going to be exposed to something that you haven't seen before, and that is what we call a pseudo-selector.
Now CSS can respond to user interactions, so when somebody hovers over a link, when they click on that link, if it's an active link, you can actually style different settings based on that. That's how a lot of people will create rollover effects based on their links, and that's how we're going to do that. So right underneath your paragraph rule, I want you to type in a:, so no space here just a and a colon and then word link. Then a comma, a:visited. Now, what are we doing there? Well, we're making sure that our active links and our visited links look exactly the same.
Normally, with the link if you click on it, and you go back to that page again, instead of an underlined blue text, you see sort of that purple text indicating that you've been there before. Well, for our site we don't want to show anything visually different for visited links, so we're just going to group those two together. Once again, I'm going to open our curly brace, hit Return to go down in the next line, and now we need to go ahead and style these. We're going to change their color, so I'm going to type in color, and here I'm going to type in pound, so I'm going to get my little hash mark here, 952, which is an orange color.
I'm going to hit Return to go down in the next line, and here I'm going to type in text-decoration: none. As soon as you're done with that, you can hit Return and close your curly brace. So this is the only two properties we're setting there. So what is text-decoration: none? Well, watch my links over here, right here, once I click on Design view. You notice what goes away? So that underline that you have under your links is going to go away if you tell it text-decoration: none. Now, most people just assume that I do that because I hate the underline. I don't really. I mean underline text lets you users know, "Hey, click on me. I'm a link." But there are other things that you can do to let people know.
In this case, the color is significantly different from the surrounding text. So it does kind of leave the user to say "Hey. I can probably click on that." We can reinforce that concept by changing the styling if somebody hovers over that link, and let's do that now. Now, I'm going to click back in the Code View right after the last selector I just wrote. I'm going to hit Return, and here I'm going to do a:hover, a:active. So just like our link in visited, hover and active are going to look the same as well. What's an active link? Well, that's one that you're currently clicking on or that you focused on.
So I'm going to open up my curly brace, hit Return, and here we're not going to do a whole lot. I'm going to change the color, so I'm going to do color and here I'm going to do #cb7d20. It's a lighter orange. So cb7d20 and the semicolon, go down in the next line. And I'm going to add an underline, but I'm not going to do it through text-decoration. I'm going to do it through my border property, which gives me a little bit more control over this. So I'm going to type in border-bottom, border-bottom and here we can do some short annotation.
We can tell it 1 pixel and then a space, dashed, for a dashed line instead of a solid line, and then another space, and then we need to give it the color. So here we're going to do #cb7d20, a little semicolon there, close your curly brace. And now we can't see that right now unless we turn on Live View, so I'm going to turn on Live View, and now when I hover one links, I can see that underline text and little dashed line. We get enough of a color change to make a slight difference, but it's nice and subtle.
Okay. I'm going to turn Live View off again, and let's finish up by doing our headings. So I'm going to scroll down in our code a little bit, just underneath all of our accents and things like that to about line 79, and then I'm going to create an empty line here that I can create my first heading. So here I'm going to do h1, so a big global element selector, open up your curly brace, and after that I'm going to choose font-size, so font-size of 2 ems. Hit Return, and I'm going to do color: #193742.
So again, 193742. Type in a semicolon, and then one last little thing. We're going to increase the spacing. We're going to do margin-bottom of .4 ems. Again, I'm going to close my curly brace on the next line, and I can see the styling changed here. We get a little bit more spacing between that margin and the paragraph, color changes. The font-size changes a little bit. There we go. Let's continue on with our headings. Now we're going to do an h2 heading, open our upper curly brace, and here we're going to do font-size, so font-size 1.6 em. Notice there's no space between the unit of measurement and the type of measurement.
So you want to keep that consistent. Do a semicolon there. For color, we're going to do #51341a, so #51341a. Now you might be wondering, "How does he remember all these colors?" I don't have to memorize. I have it written down them, and I am reading them off the sheet, but I'm going to show you guys a way to maybe make those a little bit easier to remember here in just a moment. Let's go down to the next line and here I'm going to type in font-weight: normal. So remember that's going to remove the bold off of that heading, and it's going to make it a little bit more normal.
And then I'm going to do a margin property. And I'm going to do a top-margin of 1.2 ems, and then a space, 0 for right and left, and then another space, and then from our bottom-margin I'm going to do 1 em. So we're doing some shorthand notation there just to make that a little bit easier to write. And if I click in Design view and maybe scroll down a little bit, I should be able to see a heading 2, and I can see it format, so that's looking pretty good. Two more selectors to write, guys. I hope your hands aren't cramping on you. We're moving along right along. We're going to do h3, open up a curly brace, and below that, we're going to do font-size: 1.3 ems;.
For color, we're, again, going to do #51341a. Again, we're going to do font-weight: normal, so font-weight: normal. And then after that we're going to a margin of 1.25 ems for the top-margin, 0 for right and left, and this time .5 ems for bottom, so that's a little different. And then I'm going to click, and we can see our styling. So you might have notice that, hey, h2 and h3 was very similar.
They are using the same color, same font-weight, margins almost the same and font-sizes almost the same. What if they were both exactly the same? Well, if they were exactly the same, we could have grouped them together the same way we did our CSS reset. However, I'm going to show you a grouped selector here that's going to allow us to do something else. We're using floats throughout our layout. Now, we cover floats in the chapter on layout a little bit later on, but what floats really do is they move objects to the left, or to the right of an object. Well, we don't want that to ever happen to one of our headings.
We always want our headings to be on their own line and not have anything aligned to the left or to the right of them. It's sort of allows them to stand apart, if you will. So we do have our property called Clear that allows us to do just that. So I'm going to go down on the next line, and I'm going to write a selector that says, h1,h2,h3. So it's grouping all of those main headings h1, h2 and h3 together. I'm going to open up my curly brace, and then I'm going to type in clear both. That says, "Don't allow anything to float to my left, don't allow anything to float to my right," and again, make sure that you have your opening and your closing curly braces.
You probably won't notice a change if you click into the Design view, because we don't really have anything like that going on in this page. Now, I promised that I would show you one of the tricks I use for making sure I remember what colors I'm using. If I go all the way up to the top of my stylesheet, notice that right up top I have a color guide. So here I tell which colors I'm going to be using for the site, what colors those are, and often I'll just copy and paste those colors wherever I need them. So it's a quick and handy way to do that. So our global styles are now fairly complete.
Now the page's typography is not finished, but the global styles that we've written have completed much of the work for us. Now more importantly, they are going to provide the foundation for the entire site's typography for every single page. In our next movie, we're going to expand on these global styles by writing targeted styles for specific regions.
Find answers to the most frequently asked questions about Dreamweaver CS5 Essential Training.
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.
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.