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

Preparing modular styles

From: Managing CSS in Dreamweaver

Video: Preparing modular styles

Earlier in this title, we discussed the advantage of separating the styles in your style sheets into sections. By creating separate sections for items such as layout, typography, or page regions, you create more organized files and make editing and maintaining them easier. You can take that concept a step further by creating what's known as modular style sheets. The modular style sheets are created by separating the site's CSS into individual style sheets and then reassembling them at run time. Before we discuss how to assemble style sheets at run time, let's focus on preparing our modular stylesheets by separating our styles into separate files.

Preparing modular styles

Earlier in this title, we discussed the advantage of separating the styles in your style sheets into sections. By creating separate sections for items such as layout, typography, or page regions, you create more organized files and make editing and maintaining them easier. You can take that concept a step further by creating what's known as modular style sheets. The modular style sheets are created by separating the site's CSS into individual style sheets and then reassembling them at run time. Before we discuss how to assemble style sheets at run time, let's focus on preparing our modular stylesheets by separating our styles into separate files.

So, I have the main.css open from the 04_03 folder. What we're going to do is we're going to separate out a couple of sections of styles that not every single page is going to need. We have a full set of styles for table design, and we have a full set of styles for forms. But not every page is going to be using tables, and not every page is going to be using forms. So, if that's the case, then really loading up those styles is pretty much wasted content. So, we're going to go ahead and separate that out, and then just let the site call for those styles when it needs them.

So, the first thing I'm going to do is I'm going to go up to File and choose Save As. And I'm going to save this in the 04_03/_css directory. And I'm just going to call this one global.css. So, this is going to contain the majority of our global styles. Now, before we go too far down this road, I want to talk a little bit about strategy. The reason I'm separating out the table styles and the form styles is they are pretty easy to separate. In a lot of cases, when people are creating modular styles, they'll put their layout styles in one file.

They'll put their typography in another file, their color treatment in other file. It's really up to you in terms of how you want to separate these styles out. You can separate them out like content, or you can separate them out by the type of selectors you're dealing with. Okay. So now what I'm going to do is go down and find my table styles. I'm going to scroll down all the way to around 600 -- line 698. All right! So, 683. Here we go. So, there is our data tables. We're going to go ahead and take that. so, I'm going to highlight all the way down to about line 738. There we go - just above this spotlight region. You want to make sure you'll getting that last curly brace there, too.

I'm going to go ahead and cut those. So, Command+X or Ctrl+X, so there we go. I'm going to go ahead and cut that out. Now, create a new file, and we're looking for a new CSS file. Create that. And then go ahead and paste the table styles that you just cut from your previous CSS file. We're going to go ahead and do a save on that. We want to save that in the 04_03/_css. And we're going to save this one as table _styles.css, tables underscore styles.

I am going to close that. Next, I'm going to go back into my global.css. I'm going to strip out some more styles. I'm going to go down to around line 705. I can found my form styling here. I'm just going to go ahead and highlight that all the way down, and there is a lot of form styles. Pass 900 to about 919. You can see right there the sidebar is the next divider that you have to worry about. Make sure, again, you're getting the closing curly brace, and cut that so Ctrl+X. There we go. We'll remove some of the extra space there.

And then we're going to go ahead and create a brand-new file, CSS again. We're going to paste the code that we just cut into that file. And we're going to save this as form_ styles.css and go ahead and save that, as well. Close that. Our global CSS is considerably shorter. Where it was past 1,000 lines of code before, now, it only goes out to 130, so we're saving a little bit of weight there. I do want to go back up, however, and modify table of contents.

I'm just going to go ahead and get rid of data tables, and I'm going to get rid of forms. Now, if we were doing this for real, we'd probably want to update the identifiers too, but as it is, they are fine where they are. Now, obviously we could have chosen from a variety of organizational strategies for these modular styles. By separating forms and tables, we remove hundreds of lines of code. The most were pages we don't even need. Now, we could have just as easily separated layout, typography color, any of those other groups that I was talking about, the exact same way. Well, now that we've our styles separated, we need to make sure each page in our site is getting exactly the styles that needs.

We'll do that in our next movie, as we learned to build modular styles.

Show transcript

This video is part of

Image for Managing CSS in Dreamweaver
Managing CSS in Dreamweaver

41 video lessons · 20855 viewers

James Williamson
Author

 
Expand all | Collapse all
  1. 4m 12s
    1. Welcome
      1m 10s
    2. Who is this course for?
      1m 5s
    3. Using the exercise files
      1m 57s
  2. 1h 21m
    1. Controlling CSS in Dreamweaver
      2m 34s
    2. Style formatting options
      4m 59s
    3. Controlling shorthand notation
      6m 9s
    4. Building a style-focused workspace
      6m 10s
    5. CSS Styles panel overview
      8m 18s
    6. The Properties Inspector
      6m 39s
    7. Creating styles visually
      11m 32s
    8. Hand-coding styles
      8m 15s
    9. Code hinting and code completion
      7m 11s
    10. Modifying styles visually
      5m 24s
    11. Using the Code Navigator
      4m 47s
    12. Using CSS Inspect
      9m 52s
  3. 1h 14m
    1. Structuring style sheets
      4m 52s
    2. Writing a style header
      2m 40s
    3. Building a color guide
      6m 5s
    4. Writing a style sheet table of contents
      8m 46s
    5. Creating sections for styles
      9m 10s
    6. Using the CSS Styles panel to organize styles
      10m 29s
    7. Resolving conflicts
      7m 3s
    8. Organizing style properties
      9m 33s
    9. Writing a CSS reset
      5m 20s
    10. Writing global classes
      3m 57s
    11. Creating a style guide
      6m 6s
  4. 1h 7m
    1. Preparing custom starter pages
      11m 32s
    2. Building custom starter pages
      10m 8s
    3. Working with code snippets
      9m 54s
    4. Writing snippets
      11m 30s
    5. Importing snippets
      6m 3s
    6. Understanding snippets libraries
      8m 11s
    7. Building a CSS framework using snippets libraries
      10m 36s
  5. 52m 15s
    1. Writing a print style sheet
      10m 3s
    2. Creating print-specific styles
      10m 45s
    3. Preparing modular styles
      4m 33s
    4. Creating modular style sheets
      7m 9s
    5. Checking browser compatibility
      6m 25s
    6. Using conditional comments for Internet Explorer
      6m 58s
    7. Optimizing CSS with Dreamweaver
      6m 22s
  6. 38s
    1. Goodbye
      38s

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 Managing CSS in Dreamweaver.

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.