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

Creating a Cascading Style Sheet and applying it to multiple pages

From: Creating a First Web Site with Dreamweaver CS4

Video: Creating a Cascading Style Sheet and applying it to multiple pages

The power of CSS not only lies in the control it gives you over the design but the fact that you have the style separate from the content, and this separation really gives us flexibility to apply the style across multiple pages. So currently as you can see, this index page has a style applied to it, and it's looking pretty good, as opposed to some of these other pages, the about.html, contact, even the portfolio pages. These other pages if you look in the CSS Styles panel, I don't have any sort of styles, any rules applied to them, and what I want to do is I want these other pages to look more like the index page.

Creating a Cascading Style Sheet and applying it to multiple pages

The power of CSS not only lies in the control it gives you over the design but the fact that you have the style separate from the content, and this separation really gives us flexibility to apply the style across multiple pages. So currently as you can see, this index page has a style applied to it, and it's looking pretty good, as opposed to some of these other pages, the about.html, contact, even the portfolio pages. These other pages if you look in the CSS Styles panel, I don't have any sort of styles, any rules applied to them, and what I want to do is I want these other pages to look more like the index page.

So, if you will notice, for this index page, I have all of these various CSS rules, and really I want to take these and I want to separate this into its own file, all of these rules and I want to apply that file to the other pages. So, all I need to do is select all of these rules. So I've just Shift+Selected all of the rules and I'm going to do a right-click or Control-click if you are on a Mac, and I want to move all of these rules.

I'm going to move all of these rules to an external style sheet. I'm going to select a new style sheet. This is what I want to create. I'm going to select OK and I'm going to go ahead and put it in my CSS folder in here. I am going to give it a name of janedoe. So, it's going in the CSS folder. It's called janedoe.css, because it's going to sort of define the style for this entire site. I'm going to click Save, and sure enough this page doesn't look any different, which is exactly what I want to happen.

But if you look in CSS Styles panel, it now says janedoe.css and all of the individual rules are located in this CSS file. In fact, I even have a quick link. Using this File Navigator bar, I can jump to that CSS as well. So again, it's easy to access that CSS file. But it's still connected to my Source Code or to this current page. So, now that that's separated out, it's in that janedoe.css file.

I can take this CSS file and I can apply it to the other pages. So, I'm going to go to the about.html page, and it's really quite easy because all I need to do is go to my CSS Styles panel, and I'm going to link by clicking on this Chain-link icon. I'm going to attach this style sheet that I just had created to this about.html page. So, I can type in a URL, I'm going to actually click Browse instead of typing any URL, but I can go ahead and go in my CSS folder and locate the janedoe.css file I just made.

So, I have it selected, click and Choose, and it's just going to link that CSS and that's what I want to do. I don't want to import all of that content, I want to link to that file. I can also choose the Media type. So, this is just to get you familiar with some of the other options. I could have a CSS layout for print, for a handheld, so you can have a lot of flexibility here and you can have sort of multiple CSS pages associated with sort of one page if you wanted to.

But really I'm building this for the common web browser on sort of a common computer system, so I'm choosing screen. Let's select OK, and let's see what happens. There we are. Sure enough, it applies that style, and it's looking pretty darn good. In fact, if I look in my CSS Styles panel, you can see here is my janedoe.css. I then twirl down and I can see all the CSS styles are in there. One issue you might notice is that this content isn't in a box, like I'd really want it to be, and in general, I don't have to necessarily draw a new absolute position to div.

I need to define it as a division of content and I need to apply this content style to it. So, I have selected all this text, and I'm going to go to my Layout tab and I'm going to make sure I'm in this Classic workspace mode, and I'm going to select this first button. I'm going to insert a div tag. So, this is a division of content that I'm defining. So, I'm going to make sure this div is wrapped around all of this content and I want to give it an ID of content, because that's what is in my CSS Styles panel.

So, I have given an ID of content, I'm going to select OK, and there you are. It defines this page and it gives me that division of all of that content. I want to do that across the board because I want to go to the contact page and really it's the same process. It's attaching a style sheet, browsing to that specific style sheet, again, it's in the CSS folder, click Choose, change my Media type, which technically isn't necessary, but it's a good practice. Select OK.

It applies that style and again the same process of selecting the content and then wrapping it, sort of defining it as its own area and making sure the content CSS rule is applied to that area. So, it's coming along nicely. The last section is the portfolio section. So again, attach my style sheet, browse to it, janedoe.css, click Choose, change my Media type to screen, select OK, and wrap in a content.

And making sure it applies the content CSS rule. Just like that. So, here we have four pages. They all finally look like a complete site and sort of are all associated to this one janedoe.css. In fact, if I come in here and I change the h2 rule, for instance, and what I want to do I want to maybe italicize the text. So, I'm going to click Apply, and it italicized this text.

I just need to change it in this one place and if I go to these other pages, I can see that text is italicized. So not only do you have a lot of control over your design, but you can easily change your design in one location, and it will change all of the pages that are associated with that CSS file.

Show transcript

This video is part of

Image for Creating a First Web Site with Dreamweaver CS4
Creating a First Web Site with Dreamweaver CS4

32 video lessons · 51533 viewers

Paul Trani
Author

 

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 Creating a First Web Site with Dreamweaver CS4.

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.