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

Applying basic styling to structured content

From: Dreamweaver CS3 Beyond the Basics

Video: Applying basic styling to structured content

Now that we've gotten our page structure where we need it, maybe we'll apply some basic formatting to our page to begin our two-column layout. The first thing we are going to do is center the layout and apply a fixed width to it. That is something that's become rather standard today in CSS layout. The reason is monitor width and monitor resolution is so varied today from very small screens to very large screens with wide aspect ratios that having content aligned to the left or the right of a monitor isn't really ideal. So a lot of people are centering their content and from there they might use a fixed width or they might use a flexible layout and then we're going to do a fixed width layout. So the first thing that we're going to do is go ahead and center our content on the page and then we'll position them. So I am going to go to my CSS Styles panel because we need to create a new external style sheet and it's best to store any sort of global styles for a whole site in an external file, so we'll go ahead and do that now. And you can actually do that through the creation of a new rule, and if you don't have a style sheet already defined, Dreamweaver at any time allows you to create one as you define the rule. So, don't feel like you have to create them as a separate page. So we can create a new external style sheet just by defining a new rule. So I am going to go down to my New CSS Rule and click on that and that will bring up our New CSS Rule dialog box. And to review the selector types, class refers to classes and tags refer to any element selectors like paragraph or heading 1s. And the Advanced radio button basically is saying that you can just type in anything that you'd like, so ID selectors, pseudo-class selectors, descendant selectors, that type of thing. So we are going to use the Advanced here and we're going to do a selector that you may not be familiar with. I am going to go ahead and just type in a star or asterisk symbol, and we're going to say New Style Sheet File, so that it creates a new style sheet file. This is a wildcard selector and you can use it in conjunction with other selector. So you could say *h1 for example and you'd say every element outside of an h1 so you can use it as a descendant selector. A lot of people use *html to target Internet Explorer only browsers.

Applying basic styling to structured content

Now that we've gotten our page structure where we need it, maybe we'll apply some basic formatting to our page to begin our two-column layout. The first thing we are going to do is center the layout and apply a fixed width to it. That is something that's become rather standard today in CSS layout. The reason is monitor width and monitor resolution is so varied today from very small screens to very large screens with wide aspect ratios that having content aligned to the left or the right of a monitor isn't really ideal. So a lot of people are centering their content and from there they might use a fixed width or they might use a flexible layout and then we're going to do a fixed width layout. So the first thing that we're going to do is go ahead and center our content on the page and then we'll position them. So I am going to go to my CSS Styles panel because we need to create a new external style sheet and it's best to store any sort of global styles for a whole site in an external file, so we'll go ahead and do that now. And you can actually do that through the creation of a new rule, and if you don't have a style sheet already defined, Dreamweaver at any time allows you to create one as you define the rule. So, don't feel like you have to create them as a separate page. So we can create a new external style sheet just by defining a new rule. So I am going to go down to my New CSS Rule and click on that and that will bring up our New CSS Rule dialog box. And to review the selector types, class refers to classes and tags refer to any element selectors like paragraph or heading 1s. And the Advanced radio button basically is saying that you can just type in anything that you'd like, so ID selectors, pseudo-class selectors, descendant selectors, that type of thing. So we are going to use the Advanced here and we're going to do a selector that you may not be familiar with. I am going to go ahead and just type in a star or asterisk symbol, and we're going to say New Style Sheet File, so that it creates a new style sheet file. This is a wildcard selector and you can use it in conjunction with other selector. So you could say *h1 for example and you'd say every element outside of an h1 so you can use it as a descendant selector. A lot of people use *html to target Internet Explorer only browsers.

We're wanting to target every element on the page, so we're just saying star. I'll go ahead and click OK and we're going to save this in our Unit 3, Starting _css directory and we want to go ahead and name this layout.css. So it not only creates the external style sheet for us but it brings up the CSS Rule Definition dialog box. I am going to go to my Box properties and I am going to set the Padding to 0, Same For All, and Margin to 0, Same For All. Now because we are using a wildcard selector for this, the star selector, that basically means that every element on our page is going to be stripped of its margin and its padding. Now that's a really severe thing to do because our paragraphs are going to lose all their margins, their default margins, our headings are going to lose all that. But what that allows us to do is sort of strip all that bare and then have total control over all the elements on a page as we style them.

So I am going to go ahead and click OK. And the other thing that it does for us is it also makes sure that we are not going to be dealing with the default margins and padding differences that different browsers have. Safari and Firefox, Internet Explorer, Opera, they all have their own default margins and padding. Well. We have just basically told all of them ignore your own settings and use mine from here on out. So I'll go ahead and expand layout.css and the only selector in there right now is that little star, and if you click on that you can see there is our margin and there is our padding. It would be tempting to go ahead and keep creating rules this way, but once you get used to doing it, hand-coding these rules is actually a lot faster because Dreamweaver gives us coding hints for CSS, the same way it does when we are coding our XHTML.

So we're going to take advantage of that and maybe speed up the process of writing some of these selectors. So if you'll notice because we created a new cascading style sheet file, Dreamweaver has automatically opened that for you right beside your index_start file. So I'll click on the layout.css tab and you can see that we just have an encoding character set that Dreamweaver is passing along and we have our star selector. Now one thing that I like to do in any external style sheet is comment out that style sheet and talk about what it is that we are doing. Now remember we can go down to our Coding toolbar and we can just tell it, hey, I need a new comment. For a CSS, you use the /* */ multiline comment, and I'll go ahead and click on that to insert a comment line.

And generally I use comments to separate out areas of content. So I am just going to draw-- click a couple of dashes there and type in basic styling. And that helps identify that area of content. So you also want to write notes to yourself about what this particular selector is doing, if you think you need to remind yourself about later on. Well, I am going to go down to the line below our existing selector and if you want to put multiple lines in between them, you can, that sort of thing. Remember the concept that we learned about earlier, inheritance. I can go ahead and apply a lot of formatting to the body tag and know that everything on the page will inherit the style. So I am just going to type in body for the selector and open up one of my French braces, and I am going to go down the next line and I generally tab over so that I have the same indentation that they have. And I'll type in background and I can just use the coding that comes up to assign a background color. And the background color I am going to assign, I'll use the hash mark here, is going to be 6f5044 and we type in a semicolon after each rule and I'll hit Enter to go down to the next line. And I am going to type in text-align and I am going to set that property to center and type in another semicolon. Now that has everything to do with centering the content on the page and you might think, wow, that's a really bad way to center the content on the page. But we're really making up for a problem that Internet Explorer has and I'll talk more about that as we continue to write these selectors. So let's go down to the next line.

I am going to type in font-family and I notice that I get a pulldown menu of all these sort of preset font-families, and if you've ever wondered why you might define more than one font, well, we're relying on a client machine to show these fonts so if somebody doesn't have Georgia for example, it looks for the next font in the list. And speaking of that I'm just going to type in a G to jump down to Georgia and I'll hit Enter. And then I'll type in another semicolon. I'll hit Return and from here I'll do font-size and I'll type in 85%. I'll hit Return and then end my curly brace. Now by setting your font-size to a percentage you're telling any device whether it's a browser or hand-held device or whatever device it may be, you are telling that I want to display my fonts inside the body tag 85% of what your normal display size is or whatever its display size is currently set to. That allows you to be very flexible with your design and not have to worry so much about is it 16 pixels tall or 18 pixels tall.

I am just saying give me 85% of your normal font-size. The next thing I need to do in order to center my content is to create a Wrapper Selector and I am going to use #wrapper as the selector. So I am using the wrapper and open the curly brace. And on the next line I am going to type in position and I am going to set the value equal to relative. Now the reason we're using position:relative on the wrapper div tag is not so that we can move it over in the center by using relative positioning. It's actually more to control the elements inside of it. Because if you use absolute positioning on a nested element, it's relative to the top parent element that has a positioning attribute. In this case, it will be the wrapper tag. So if I wanted to take say the content area and use absolute positioning to move it around, it would go up and find the wrapper div tag and it would say oh! the wrapper div tag has a positioning element. Now the 00 position of the upper left-hand corner of the wrapper div tag would be used to position instead of the actual web page itself.

So we're just sort of resetting that 00 point if you will to the wrapper div tag. So we'll go down the next line and I am going to go ahead and give it a defined width. I am going to define a width of 900 pixels and since we are doing a fixed layout we definitely want to give it a specific size here; we could have given that a percentage too if we wanted it to be flexible. Now, I'll set my margins and here's where we do our centering. I am actually going to set margin to 0 and then auto. So for the first time here we are doing some shorthand. When you are doing margins and padding, you can pass along shorthand notation. By saying 0, the first value is the top and the left margin.

The second value, which is auto, is left and right. So by saying 0, we are aligning the wrapper up to the top edge of the page and by saying auto we're saying we've got 900 pixels for our wrapper and we want all the remaining pixels left over, no matter what size the monitor is, we want to distribute half of that on the left and half of that on the right because we're just saying automatically determine the margins there. That centers our content. So you might wonder, okay, if that works then why did you have to do text-align on the body and why are we now doing a text-align property left on the wrapper? Well, it deals with Internet Explorer and Internet Explorer doesn't really always calculate those auto margins correctly. So by using text-align center, Internet Explorer will go ahead and center everything in the middle of the page. Then by applying text-align left to the wrapper, everything inside the wrapper gets left aligned again so it sort of fixes that. So we'll go down to the next line and we'll type in a background-color for our wrapper. And our background-color is going to be just white, so #fff. So we're using shorthand notation there for the color.

And we'll close out the curly brace here. And the last thing we want to do for this sort of basic styling is to go ahead and style a clear id and for that we want to choose clear:both. This is a pretty common technique too when you are doing a float-based layout. You just go ahead and create either an id or class and you name it clear and then it's value is clear:both. And now anytime I need to clear an element I can go ahead and apply this id or apply this class or doing it via a class style and it will go ahead and clear my float.

Now that we've finished writing the styles that are going to center our content, we'll go back over to our Index page and we'll preview those. So I am going to click back on the tab for index_start now. I am on a pretty small screen resolution. So because of that I can't really see; it's 900 pixels wide. So I can't really see the edges. So I am going to preview that on my browsers to see them. But for those of you who are on a much higher screen resolution, you're probably seeing the content centered on the page and so the brown background color around it. So I am going to go ahead and preview that in the browser. Notice that Dreamweaver is giving us the message that some of the files necessary to preview this in the browser haven't been saved. So I am going to go ahead and click Yes. I could have prevented that by saving all of our files prior to previewing it. Now we'll preview that in our browser. And when it comes up, notice that we have 900 pixel wide content centered in the middle of the page and we have had that brown background color and let me go ahead and center this out. Now because we went ahead and zeroed out the margins and the padding for everything, notice that all of our content is butting up right against the edge of the container wrapper div tag and all of our content is kind of stacked right on top of each other. So even our paragraphs and our headings are really not pushing apart from each other at all anymore. So we've centered our content.

Now we need to focus on styling the content inside the nested containers.

Show transcript

This video is part of

Image for Dreamweaver CS3 Beyond the Basics
Dreamweaver CS3 Beyond the Basics

102 video lessons · 38681 viewers

James Williamson
Author

 
Expand all | Collapse all
  1. 2m 3s
    1. Welcome
      1m 17s
    2. Using the exercise files
      46s
  2. 1h 23m
    1. Reviewing the Coding toolbar
      8m 42s
    2. Customizing the Coding toolbar
      9m 52s
    3. Taking advantage of Code Hinting
      7m 20s
    4. Using snippets and shortcuts
      11m 10s
    5. Using the Quick Tag Editor
      5m 18s
    6. Using Find and Replace
      9m 50s
    7. Regular expressions
      5m 39s
    8. Using Bridge with Dreamweaver CS3
      8m 28s
    9. Round-trip editing with Photoshop CS3
      3m 40s
    10. Leveraging image variables in Photoshop CS3
      7m 32s
    11. Integrating external variables into your workflow
      6m 16s
  3. 37m 26s
    1. Understanding the CSS Styles panel
      7m 59s
    2. Understanding the Cascade
      5m 50s
    3. Understanding Inheritance
      5m 8s
    4. Understanding Specificity
      7m 5s
    5. Managing CSS styles
      5m 4s
    6. Using Design-Time style sheets
      6m 20s
  4. 2h 19m
    1. Using the new CSS template pages
      5m 59s
    2. Understanding DIV tag structure and layout
      12m 0s
    3. Understanding the CSS box model
      10m 0s
    4. Using absolute and relative positioning
      8m 35s
    5. Understanding floating elements
      7m 9s
    6. Clearing floats
      7m 19s
    7. Using floats to control page layout
      3m 45s
    8. Building structure and assigning IDs
      10m 19s
    9. Applying basic styling to structured content
      11m 14s
    10. Positioning container elements
      11m 4s
    11. Enhancing layouts with background graphics
      11m 48s
    12. Creating faux columns with background graphics
      8m 55s
    13. Creating rounded corners with background graphics
      9m 17s
    14. Building navigation with CSS
      16m 57s
    15. Using Dreamweaver's Browser Check feature
      5m 31s
  5. 53m 22s
    1. Creating properly structured forms
      6m 30s
    2. Creating accessible forms
      6m 41s
    3. Using CSS to lay out form structure
      7m 40s
    4. Creating vertical columns for form elements
      7m 48s
    5. Adding user feedback
      5m 52s
    6. Applying advanced styling to forms
      8m 11s
    7. Client-side form validation
      4m 17s
    8. Validating forms with the Spry Validation tools
      6m 23s
  6. 1h 20m
    1. Understanding the Spry framework
      3m 43s
    2. Defining a data source for use in Spry
      3m 56s
    3. Creating a Spry table
      8m 8s
    4. Using the Spry widgets
      8m 11s
    5. Connecting various data sets
      4m 50s
    6. Understanding Spry widget structures
      7m 1s
    7. Applying custom styles to Spry widgets
      6m 24s
    8. Applying additional custom styles to Spry widgets
      8m 46s
    9. Controlling Spry widget behaviors with JavaScript
      6m 0s
    10. Controlling Spry widget animations with JavaScript
      9m 31s
    11. Creating effects with Spry behaviors
      4m 42s
    12. Hand-coding Spry
      9m 11s
  7. 1h 11m
    1. Creating a base template
      8m 6s
    2. Creating editable attributes
      6m 26s
    3. Creating a new page from a template
      7m 42s
    4. Applying a template to an existing page
      4m 36s
    5. Creating nested templates
      5m 24s
    6. Using repeating regions
      6m 34s
    7. Creating editable and non-editable optional regions
      6m 0s
    8. Using template parameters
      7m 26s
    9. Using template expressions
      9m 59s
    10. Using conditional template expressions
      8m 54s
  8. 54m 40s
    1. Examining XML structure
      2m 44s
    2. Creating an XML document
      9m 9s
    3. Using the CDATA structure
      5m 7s
    4. Creating an XSLT file
      4m 33s
    5. Binding data from an XML to an XSLT document
      5m 6s
    6. Inserting repeating regions into an XSL document
      5m 16s
    7. Creating a client-side XSL transformation
      2m 52s
    8. Styling a remote RSS feed
      7m 29s
    9. Creating a server-side XSL transformation
      5m 31s
    10. Writing XSL expressions
      6m 53s
  9. 1h 2m
    1. Overview of building dynamic websites
      1m 35s
    2. Installing PHP, MySQL, and Apache on Mac
      3m 22s
    3. Installing PHP, MySQL, and Apache on Windows
      3m 54s
    4. Creating a MySQL database
      3m 16s
    5. Defining a testing server and database bindings
      6m 14s
    6. Creating a database recordset
      4m 35s
    7. Adding dynamic content to the page
      5m 14s
    8. Creating repeating regions of dynamic content
      7m 6s
    9. Filtering database records
      7m 39s
    10. Using the Live Preview
      10m 22s
    11. Passing URL parameters
      4m 23s
    12. Dynamically generating links
      5m 18s
  10. 57m 9s
    1. Understanding behaviors
      5m 16s
    2. Installing additional behaviors
      3m 39s
    3. Planning to create a custom behavior
      3m 42s
    4. Examining existing behaviors
      5m 32s
    5. Building a behavior function
      7m 23s
    6. Creating an Action file
      6m 48s
    7. Enabling behavior functions
      9m 1s
    8. Initializing the user interface for a behavior
      3m 9s
    9. Loading behaviors in Dreamweaver
      6m 47s
    10. Testing and debugging behaviors
      5m 52s
  11. 27m 12s
    1. Running reports
      7m 41s
    2. Checking and validating links
      3m 40s
    3. Using cloaking
      5m 42s
    4. Using Check In/Check Out
      4m 3s
    5. Using Design Notes
      6m 6s
  12. 20s
    1. Goodbye
      20s

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 CS3 Beyond the Basics.

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

Are you sure you want to delete this note?

No

Your file was successfully uploaded.

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.