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

Writing global styles

From: Dreamweaver CS5 Essential Training

Video: Writing global styles

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.

Writing global styles

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.

Show transcript

This video is part of

Image for Dreamweaver CS5 Essential Training
Dreamweaver CS5 Essential Training

135 video lessons · 89501 viewers

James Williamson
Author

 
Expand all | Collapse all
  1. 2m 57s
    1. Welcome
      1m 8s
    2. Using the exercise files
      1m 49s
  2. 7m 50s
    1. What is Dreamweaver?
      3m 16s
    2. Learning web design
      2m 22s
    3. Current web standards
      2m 12s
  3. 43m 9s
    1. The Welcome screen
      4m 5s
    2. Windows and Mac interface differences
      2m 23s
    3. The Application toolbar
      4m 7s
    4. The Document toolbar
      4m 40s
    5. Arranging panels
      8m 19s
    6. Managing workspaces
      7m 32s
    7. The Properties Inspector
      5m 54s
    8. The Insert panel
      6m 9s
  4. 25m 45s
    1. Basic site structure
      3m 11s
    2. File naming conventions
      1m 49s
    3. Defining a new site
      4m 35s
    4. Managing sites
      4m 51s
    5. Managing files and folders
      6m 36s
    6. Working with browsers
      4m 43s
  5. 27m 21s
    1. Creating new documents
      5m 16s
    2. New document preferences
      3m 6s
    3. Setting accessibility preferences
      4m 56s
    4. Working with starter pages
      3m 46s
    5. Managing starter pages
      10m 17s
  6. 30m 2s
    1. Basic tag structure
      2m 15s
    2. Adding structure to text
      8m 20s
    3. Creating lists
      9m 59s
    4. Getting text into Dreamweaver
      5m 59s
    5. Importing Word documents
      3m 29s
  7. 1h 17m
    1. Understanding style sheets
      2m 16s
    2. The anatomy of a CSS rule
      1m 48s
    3. Setting CSS preferences
      6m 36s
    4. The CSS Styles panel
      10m 2s
    5. Controlling CSS through the Properties Inspector
      5m 14s
    6. Using the Code Navigator
      7m 21s
    7. Using CSS Enable
      6m 45s
    8. Understanding element selectors
      8m 11s
    9. Understanding class selectors
      8m 49s
    10. Understanding ID selectors
      5m 59s
    11. Understanding descendant selectors
      6m 51s
    12. Attaching external style sheets
      7m 44s
  8. 1h 47m
    1. Working with units of measurement
      7m 11s
    2. Declaring font families
      9m 39s
    3. Controlling font sizing
      9m 9s
    4. Controlling weight and style
      8m 0s
    5. Controlling line height
      8m 29s
    6. Controlling vertical spacing with margins
      12m 3s
    7. Controlling spacing with padding
      5m 39s
    8. Aligning text
      8m 26s
    9. Transforming text
      5m 36s
    10. Writing global styles
      15m 42s
    11. Writing targeted styles
      17m 37s
  9. 1h 32m
    1. Understanding image types
      5m 3s
    2. Managing assets in Dreamweaver
      12m 51s
    3. Setting image accessibility preferences
      4m 20s
    4. Setting external image editing preferences
      3m 52s
    5. Placing images on the page
      7m 37s
    6. Photoshop integration
      5m 54s
    7. Modifying Smart Objects
      5m 51s
    8. Alternate Photoshop workflows
      8m 8s
    9. Modifying image properties
      11m 14s
    10. Styling images with CSS
      7m 11s
    11. Using background graphics
      9m 3s
    12. Positioning background graphics
      11m 6s
  10. 55m 16s
    1. Link basics
      3m 37s
    2. Setting site linking preferences
      2m 14s
    3. Creating links in Dreamweaver
      11m 1s
    4. Absolute links
      5m 8s
    5. Using named anchors
      11m 19s
    6. Linking to named anchors in external files
      2m 44s
    7. Creating an email link
      5m 24s
    8. Creating CSS-based rollovers
      13m 49s
  11. 1h 34m
    1. CSS structuring basics
      2m 56s
    2. The Box Model
      13m 21s
    3. Understanding floats
      6m 53s
    4. Clearing and containing floats
      8m 56s
    5. Using relative positioning
      4m 8s
    6. Using absolute positioning
      7m 18s
    7. Creating structure with div tags
      12m 7s
    8. Styling basic structure
      10m 34s
    9. Creating a two-column layout
      10m 37s
    10. Using Live View and CSS Inspect
      7m 51s
    11. Using Browser Lab
      9m 39s
  12. 56m 22s
    1. Reviewing table structure
      7m 41s
    2. Importing tabular data
      5m 13s
    3. Creating accessible tables
      9m 56s
    4. Using thead and tbody tags
      4m 0s
    5. Basic table styling
      8m 45s
    6. Styling table headers
      7m 52s
    7. Styling column groups
      4m 22s
    8. Creating custom table borders
      5m 1s
    9. Styling table captions
      3m 32s
  13. 1h 43m
    1. How forms work
      3m 0s
    2. Reviewing form design
      3m 2s
    3. Creating accessible forms
      7m 33s
    4. Setting form properties
      4m 6s
    5. The fieldset and legend tags
      4m 32s
    6. Inserting text fields
      5m 58s
    7. Inserting list menu items
      5m 26s
    8. Inserting checkboxes
      7m 50s
    9. Inserting radio button groups
      6m 22s
    10. Inserting text areas
      4m 12s
    11. Inserting submit buttons
      3m 37s
    12. Basic form styling
      12m 0s
    13. Form element styling
      8m 52s
    14. Styling form layout
      11m 49s
    15. Adding form interactivity
      2m 47s
    16. Using Spry validation widgets
      12m 49s
  14. 1h 23m
    1. Planning for templates
      10m 51s
    2. Creating a new template
      10m 37s
    3. Using editable attributes
      13m 43s
    4. Creating optional regions
      6m 23s
    5. Creating new pages from a template
      9m 17s
    6. Applying templates to existing pages
      6m 9s
    7. Working with nested templates
      7m 56s
    8. Working with repeating regions
      12m 58s
    9. Modifying templates
      5m 41s
  15. 40m 14s
    1. Behaviors overview
      3m 47s
    2. Hiding and showing elements
      9m 18s
    3. Spry overview
      4m 4s
    4. Using Spry widgets
      11m 36s
    5. Adding Spry effects
      3m 6s
    6. Using the Widget Browser
      8m 23s
  16. 28m 18s
    1. Inserting Flash files
      5m 4s
    2. Setting properties for Flash
      6m 27s
    3. Dreamweaver and Flash integration
      6m 6s
    4. Encoding Flash video
      6m 10s
    5. Adding Flash video
      4m 31s
  17. 45m 28s
    1. Running site-wide reports
      6m 33s
    2. Checking for broken links
      5m 41s
    3. Checking for browser compatibility
      8m 3s
    4. Adding remote servers
      8m 0s
    5. Uploading files
      7m 20s
    6. Managing remote sites
      9m 51s
  18. 34s
    1. Goodbye
      34s

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 CS5 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 preferences from 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.

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.

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.