Managing CSS in Dreamweaver

Managing CSS in Dreamweaver

with James Williamson

 


Managing CSS in Dreamweaver with James Williamson shows how to create cascading style sheets that are efficient, reusable, and easy to navigate. In this course, James shares tips on how to find and use panels and tools, and how to deploy style sheets to screen, print, and mobile environments. Course topics include creating customized starter pages, learning to rapidly hand-code CSS through using Snippets, and using Dreamweaver's CSS preferences to deploy lightweight styles. Exercise files are included with the course.
Topics include:
  • Building a CSS-friendly workspace in Dreamweaver
  • Creating style sheets visually
  • Hand-coding styles
  • Working with code hinting
  • Organizing style sheets with color coding and sections
  • Writing global classes
  • Eliminating style conflicts
  • Deploying styles
  • Dealing with browser compatibility issues

show more

author
James Williamson
subject
Web
software
Dreamweaver CS5, CS5.5
level
Intermediate
duration
4h 40m
released
Jun 03, 2010

Share this course

Ready to join? subscribe


Keep up with news, tips, and latest courses.

submit Course details submit clicked more info

Please wait...

Search the closed captioning text for this course by entering the keyword you’d like to search, or browse the closed captioning text by selecting the chapter name below and choosing the video title you’d like to review.



Introduction
Welcome
00:04Hello, and welcome to Dreamweaver CS5 Managing CSS.
00:08My name is James Williamson.
00:09I am a senior author at lynda.com and an Adobe certified instructor.
00:13In this course, I want to dive a little deeper into the creation and management
00:17of CSS within Dreamweaver.
00:19Dreamweaver is one of the most powerful Web design and development programs
00:23on the market, and has some of the most complete and compelling CSS tools available.
00:28In this course, we'll focus on how to build an environment in Dreamweaver more
00:31conducive to creating CSS, how to streamline the process of creating styles, and
00:37explore using powerful tools like Snippets to rapidly build external styles.
00:41We'll also focus on organizing styles, with tips on ways to make your stylesheets
00:45easier to work with, eliminate style conflicts, and building style guides to give
00:50yourself and your clients a quick overview of your site's styles.
00:54Finally, we'll discuss deploying your styles, examine creating print stylesheets
00:58and discuss how we can deal with browser compatibility issues without creating a
01:02mess of your existing styles.
01:04That's a lot to cover,
01:05so let's get started with Dreamweaver CS5
01:08Managing CSS.
Collapse this transcript
Who is this course for?
00:00Before we start exploring Dreamweaver's CSS tools, it's worth taking a moment to
00:05discuss who this course is for.
00:07This course is for Web designers looking to take full advantage of Dreamweaver's
00:11CSS tools, or for Web developers who are used to hand-coding their CSS and are
00:15curious about Dreamweaver's capabilities for managing it.
00:18This is not a basic CSS course ,and should not be the first CSS title that you watch.
00:24The focus of this title is on managing and editing CSS.
00:28If you're new to stylesheets, I recommend any of the basic CSS titles in the
00:33lynda.com Online Training Library, or my Dreamweaver with CSS Essential titles
00:38as a good starting point.
00:39I'll try to give equal time to both the visual CSS tools in Dreamweaver, as well
00:43as its capabilities to code CSS.
00:47If you already have experience with CSS, but are new to hand-coding or haven't
00:51used Dreamweaver's visual CSS tools, then this title is for you.
00:55It is designed to give a complete overview of Dreamweaver's CSS capabilities, as
01:00well as ways that you can effectively manage and organize your site's CSS.
Collapse this transcript
Using the exercise files
00:01If you are a lynda.com premium subscriber, you have access to the exercise files
00:05that accompany this course.
00:07To follow along with the exercises, I recommend setting up a new site for the
00:10course, and then modifying the root directory for each new exercise.
00:15To illustrate this, I'll walk through the process of setting up our first
00:18exercise file and then show you switching to the next exercise.
00:23I recommend moving your exercise files to a central location such as the desktop
00:27or somewhere on your hard drive where they are easy to find.
00:30You can see here, I've copied the Exercise Files folder to the desktop.
00:34Back in Dreamweaver, I'm going to create a new Dreamweaver Site.
00:37I'm going to name the site, Manage CSS, and I'm going to browse for my
00:43local root directory.
00:44I'm just going to go out to the desktop and find my Exercise Files, go in
00:49Chapter_01 and since we're going to start on our first movie, I'll
00:52double-click the 01_01 folder.
00:56Select it, save it, and now we've defined our site.
00:59Now, you can see, in our Files panel, that there is nothing inside the 01_01 folder.
01:04It's empty because no exercise files accompanied that particular movie.
01:08But when I'm done with the 01_01 exercise, I'll move on to the next one.
01:13And to do that, I'll go back up to the Files panel, double-click the Site Manage CSS.
01:18That will open up my Edit Site dialog box, and then I'll just browse to
01:22the local Site folder.
01:23I'll go to the 01_02 folder, select that and save. Click OK.
01:29Now, the site refreshes, and I have my new exercise files.
01:34So, changing the root directory for each exercise is going to allow you to work
01:37on a clean set of files without worrying about modifying the wrong files.
01:42Just be sure that the root directory you choose matches the exercise folder for that movie.
01:47At the beginning of each movie, an overlay on the screen will show you the path
01:51to the proper exercise folder.
01:53Now that we've set our Dreamweaver for our first exercise, let's get started.
Collapse this transcript
1. Using Dreamweaver's Tools and Panels
Controlling CSS in Dreamweaver
00:00Over the years, I've heard a lot of things said about Dreamweaver, both
00:03positive and negative.
00:05I've heard developers say Dreamweaver is for designers who can't code.
00:09I've also heard designers who've said Dreamweaver is too complex.
00:12It's designed for coders, not true designers, and I've always kind of chuckled
00:17at those types of comments because they reflect the biases that we, as
00:20professionals, bring to the tools that we use.
00:23Dreamweaver isn't perfect -
00:24no tool is - but it does an amazing job of providing us with both powerful coding
00:29tools and powerful design tools.
00:31No aspect of Dreamweaver showcases this better than the creation and management of CSS.
00:38Dreamweaver has powerful design focus CSS tools, such as the Properties
00:42Inspector, the CSS Styles panel and CSS Inspect that allow you to create and
00:48modify styles without ever touching the code.
00:51For those that prefer to code their CSS themselves, Dreamweaver has a powerful
00:55Code Editor that offers hinting and code completion, flexible code formatting
01:00and highlighting, and syntax checking.
01:03This wide range of tools allows you to create a working environment that best
01:06suits your own personal preference and skill level.
01:09Regardless of whether you're coming to Dreamweaver from a design or
01:13development background, I recommend taking a blended approach to controlling
01:16styles in Dreamweaver.
01:18Developers should not dismiss, out of hand, powerful editing tools such as the CSS Styles panel.
01:23The Styles panel allows you to make edits to your styles and chase down style
01:27conflicts a lot faster than you can by hand.
01:30Now, designers should not dismiss or be intimidated by Dreamweaver's
01:35powerful code features.
01:36Once you master CSS, there is no faster way to create it than by hand-coding it,
01:41using Dreamweaver's rapid coding tools.
01:44In fact, there are certain CSS properties that aren't even available through the
01:48CSS Rule Definition dialog box.
01:51So sticking solely with Dreamweaver's visual design tools will not only slow you
01:55down in certain situations;
01:57they can also limit your effectiveness in writing certain styles.
02:03In this title, I'm going to approach the topic of managing CSS and Dreamweaver
02:07by using this blended approach.
02:08I will attempt to showcase all of the tools and capabilities that Dreamweaver
02:12provides to help you create and manage your site's CSS.
02:16Along the way, I'm going to suggest workflows that will allow you to work
02:19with CSS in the fastest, most efficient way possible, based on my own personal experience.
02:24Hopefully, you'll find an integrated solution that works for you and makes
02:28the process of planning, creating and managing CSS within Dreamweaver even
02:32easier for you.
Collapse this transcript
Style formatting options
00:00Everyone, as they say, likes to work a little bit differently.
00:04Although the foundation of how Dreamweaver manages CSS is fairly static,
00:08there are some ways that you can customize this process to meet your
00:11individual preferences.
00:13To a degree, Dreamweaver allows you to customize how your styles are created,
00:17presented, and formatted.
00:19Before we get too deep into the multiple ways to create styles in Dreamweaver,
00:23let's take a moment to go over Dreamweaver's CSS Preferences and see how we can
00:27customize them to meet our specific workflows.
00:30I'm just going to scroll around this a little bit to look at the formatting.
00:33You can see that our styles are presented with the selector on one line, and
00:38then each of our properties is displayed on a separate line.
00:41You'll notice that some of the selectors have spaces between them and some don't.
00:47So when these styles were created, and there wasn't a whole of thought given to
00:51exactly the formatting and spacing options that we wanted for these.
00:55And different people have different preferences, in terms of how they would like
00:58their styles formatted.
00:59Well, you can control that.
01:01So what I'm going to do is I'm going to go up to Edit and choose Preferences.
01:05Now if you're on the Mac, you're going to want to go to Dreamweaver and
01:08choose Preferences.
01:09So there aren't very many differences between the two interfaces, but that's
01:12one of the big ones.
01:13So I'm going to open up my Preferences.
01:15Now, the first one I want to take a look at is the Code Coloring category.
01:20You can see behind this that our CSS has certain colors that mean things.
01:24So we have sort of magenta for the selectors, a dark blue for the properties and
01:29a lighter blue for the values.
01:30Notice that we can edit that scheme.
01:32So I'm going to come right over here to Code Coloring.
01:34For Document type, I'm going to go down and choose CSS, and I'm going to click
01:38Edit Coloring Scheme.
01:40Now, in the bottom of this dialog box, I get a preview of what the
01:44coloring scheme is.
01:45Now, you're free to go ahead and change this to whatever you want;
01:48for example, if I didn't like the magenta color for the selectors, I could
01:52select that and then choose something else entirely.
01:55The problem with that though, if you're in a team environment, you're more than
01:58likely going to get used to looking at your styles a certain way.
02:01When you get on somebody else's machine, and they have their Code Coloring
02:04changed, it can be kind of abrupt.
02:06So you might want to be kind of careful about changing any of these things.
02:09One of the things that I've always found to be a little confusing is the fact
02:12that my properties are sort of a dark blue, and my values are a lighter blue, but
02:18there's not a whole lot of difference between the two of them.
02:20So I could grab that, if I wanted to, and maybe make them just a tad bit lighter.
02:24Now, there is a really nice visual difference between the two of them.
02:28There's a nice contrast there and even though I can still read it, I'm not going
02:31to mistake one for the other.
02:33So I'm going to go ahead and click OK.
02:35Now you can come back and change those preferences at any time.
02:37So if you decide after a while looking at it, you don't like it that way, it's
02:40easy enough to go back and change.
02:42Now the next thing I want to do is go down to my Code Hinting.
02:45So in my Categories, I'm going to choose Code Hinting, and I'm just going to
02:48make sure that the check box is set here for CSS property names.
02:53You can see all of the different languages and elements that Code Hinting is available for.
02:57Now, the default is that CSS property names is going to be turned on.
03:01So the only time that's not going to be available is if somebody purposely came
03:05in here and turned it off.
03:06So if you're working in Dreamweaver, but if you don't see them, you can come
03:09right back here into Preferences, and turn them right back on.
03:12Let's do one last set of preferences here.
03:13I'm going to go to my Code Formatting category, right there, and although the
03:18majority of these preferences are talking about HTML, I do have a CSS button
03:22here that I can select.
03:23So I'm going to go ahead and click that.
03:24Now this changes how Dreamweaver's going to format your CSS source code.
03:28So one of the things that I'm going to do is I'm going to turn off each property
03:32on a separate line, and then I'm going to turn on Blank lines between rules.
03:37You get a nice preview here of what this would actually like.
03:40Now, that would be a little bit harder for me to read, so I'm going to turn that
03:43back on and keep my Blank line between rules.
03:46I'm going to go ahead and click OK.
03:48Click OK again, and you see nothing changed.
03:52Well, that's OK because nothing is going to change in your Code Formatting until
03:55you actually apply the source formatting to your code.
03:58Now, any new code that we create would have those properties, but if you want
04:01code that you've already created to look that way, here's all you have to do.
04:04I'm going to over to my Coding toolbar, right over here, and since I don't have
04:08enough stream real estate to show this, I have to click the Show More icon.
04:12If you've got a very high screen resolution, you can probably see this icon
04:16without having to do that.
04:17But I'm looking for this little paint bucket with the tags. That is Format Source Code.
04:22I'm going to go ahead and click that, choose Apply Source Formatting, and now
04:26even though it jumped me all the way down to the bottom of the page, I can
04:28scroll back up, and we can see that now, for example, all of these properties
04:34are on the same line, but I've got nice spacing between all of those guys, and
04:39that is extremely readable for when I'm working in, and editing my CSS code.
04:44Now I know that not everyone likes to work with CSS the same way. That's okay.
04:48I think it's great that you can change how Dreamweaver displays your CSS to
04:51match your personal preferences, and as we'll see a little bit later, these
04:55properties can greatly assist you in deploying more efficient styles as well.
Collapse this transcript
Controlling shorthand notation
00:00One of the most efficient practices in CSS is the use of shorthand notation
00:05for certain properties.
00:06Rather than writing four separate properties for top, right, bottom, and left
00:11margin, for example, you can write a single margin property and cut down the
00:15code required throughout your CSS, considerably.
00:18If you hand-code, you're likely to handle the creation of shorthand notation yourself;
00:23however, if you use Dreamweaver's Visual CSS tools, you can control how
00:27Dreamweaver handles shorthand notation by setting some quick CSS preferences.
00:32And you can see that we have a rule on our style sheet, a list item selector.
00:36It's written incredibly and efficiently, as you can see as I scroll through this.
00:41So, we have padding all the way around.
00:43We have margin all the way around, and we have font-family and font-size, and we
00:49have a lot of borders going on here.
00:50We have borders top, right, bottom, and left, background color, image, position, repeat.
00:56Okay, so anybody that would create code by hand understands that this is
01:00incredibly inefficient.
01:01This is not the way that you would probably want to write this code.
01:04Well, if you're creating your CSS through Dreamweaver visually, you'll likely
01:09use shorthand notation, so that instead of say five separate properties, you're
01:13really only writing one.
01:14Well, if you're going to create styles through Dreamweaver's Visual tools, you
01:18can control how the shorthand notation is written and when it's written.
01:21All you really have to do is set one simple property.
01:23So, what I'm going to do is go up again to Edit and choose Preferences.
01:29Again, if you're on the Mac, you're going to go to Dreamweaver > Preferences,
01:32and I'm going to click on the CSS Styles Category.
01:36Now you can see the main focus of the CSS Styles Preferences is on
01:40shorthand notation.
01:41I can see here that I don't have any of these items selected.
01:44Now if you're opening up this dialog box for the first time, chances are you'd
01:48probably see a few of those checked, because Dreamweaver, by default, will go
01:51ahead and try to write the most efficient styles possible for you, but you are
01:55able to go in here and control this yourself.
01:57Now what I'm going to do is I'm going to go ahead and choose using shorthand
02:01notation for Background, Margin and padding, Border and border width, and
02:06List-Style, but I'm going to leave Font off.
02:08Now the reason I'm going to that is because if you use the shorthand notation
02:11for the Font selector, you generally have to pass a lot of information into it:
02:15font-weight, font-style, font-size, the font-family that you're looking for.
02:21You're free to leave all that off.
02:22In fact, for a font shorthand notation, you really only need to pass in size and
02:26the font-family itself, but all the things that you leave off it goes ahead and
02:30defaults to the default value.
02:32Now if you have a style in the cascade above this that has a font-weight bold on
02:38a paragraph, and then later on you write another style for paragraph where you
02:42just pass in size and font family, well, your paragraph is going to reset from
02:46bold, because it will overwrite the earlier style.
02:48So I really don't like Dreamweaver controlling that.
02:51If I use shorthand property for the font notation, I'll go ahead and do that myself.
02:55So I've got those four selected, and you'll notice it has a choice here for
02:59when editing CSS rules.
03:00So after the rule has been written, if you edit it, you know when
03:04should shorthand be used?
03:05Notice that I'm going to go ahead and leave the default according to
03:08the settings above.
03:09That means that whenever a rule is edited, regardless of its current state, it's
03:13going to look at these rules above to determine whether it should convert it to
03:16shorthand notation or not.
03:18We also have an Open CSS files when modified.
03:20That means if you modify a rule, and the CSS file itself was not already opened,
03:24it would go ahead and open that up.
03:26Now, since we have related files in Dreamweaver, that's not as important as it
03:29used to be, but it's still nice to leave that checked.
03:32Now, in the CSS Styles panel, which we're going to be using in just a moment,
03:35when you double-click a style to edit it, it's going to do one of three things.
03:39It's either going to edit it using the Visual CSS dialog box which is the
03:43default, it's either going to edit it through the Properties pane which the
03:46Properties Inspector would change to reflect that particular selector, or edit
03:50using Code View which would switch you over to Code View, jump to that style
03:53and let you edit it.
03:54So, you could sort of choose your own personal preference for that ,as well.
03:57For the moment, I'm just going to leave it as Edit using CSS dialog. All right.
04:01I'm going to go ahead and click OK, and now we've reset our Preferences.
04:04Now, speaking of the CSS Styles panel, I'm going to go over to that and then click on All.
04:08So even though we are looking at our CSS in Code View, I can still access and
04:13control things through the CSS Styles panel.
04:16I'm just going to come right over here to my shorthand.css, double-click the li
04:20and notice that based on our preferences, it goes ahead and opens up the CSS
04:24Rule definition dialog box.
04:26Okay, so we're going to make a couple of changes here.
04:28I'm going to click on the Background Category, and I'm just going to go ahead
04:31and change my Background repeat to no-repeat.
04:34I'm going to go to my Box Category, and I'm going to change Padding, Same
04:39for all to 20 pixels.
04:42I'm going to do Margin.
04:43I'll leave everybody the same, except for, let's see, the Left Padding.
04:48We're going to take the Left Padding, and we're going to change it to 15 pixels as well.
04:52Then finally, I'm going to go to my Border Category, and I'm going to
04:55change that to 2 pixels.
04:56Now, we do have some font information here, too.
04:59So let's make sure that it's not going to rewrite the font selector as
05:02shorthand notation.
05:03I'm going to go ahead and change the Font -size to 0.9 ems, and I'm just going to
05:08go ahead and click OK.
05:09Now as soon as I do that, look at how Dreamweaver changed the code.
05:13It listened exactly to my Preferences, and it left the font alone.
05:17So I still have a font- family and a font-size selector.
05:20It did not go ahead and convert that to shorthand notation.
05:24Background, Margin, Padding and Border, on the other hand, now I have shorthand
05:28notation for those, and look how many fewer lines of code we have here.
05:32We went from 20 something lines of code, I think, to around 7 lines of code for the same selector.
05:38So, that's really, really impressive.
05:40Now, one of the main objections that I've heard from those that prefer to
05:43hand-code over letting Dreamweaver automate some of that process is they feared
05:47giving up control of exactly how the code is written.
05:50They just preferred to do it the way that they want to do it.
05:52However, if you access the CSS Style Preferences, like we just did, you can
05:56control when and how Dreamweaver handles the creation of shorthand notation.
06:00Now, that alone can go a long way towards making sure your styles remain
06:04consistent, whether you or Dreamweaver is writing them.
Collapse this transcript
Building a style-focused workspace
00:00Dreamweaver's flexible interface allows us to create custom workspaces that are
00:04tailored specifically for the task at hand.
00:07By taking advantage of the preset workspaces, or in the case of this
00:10exercise building your own, you can make it a lot easier to switch from one task to another.
00:15So in this movie, we're going to build a custom workspace that is focused on
00:18working with styles.
00:20So you can see I'm currently working without a document open.
00:23One of the things you want to do when you're customizing the interface with
00:26Dreamweaver is make sure you're seeing everything.
00:29So I'm just going to go ahead and use the Welcome screen here to create a new HTML file.
00:33We don't need to save it.
00:34We don't need to do really anything with it.
00:35It's just there so that we can see the remainder of our workspace.
00:39Okay, one of the first things I want to make sure we're doing is all starting
00:42more or less in the same place.
00:43So you can see that I currently have the Designer Workspace.
00:47If I grab the pulldown menu, I can see that there are a lot of preset workspaces.
00:51I'm going to start with the Classic Workspace.
00:53Now the reason I like starting with the Classic Workspace, in sort of using that
00:57as a starting point, is it takes the Insert panel, and it docks it up here above
01:02the document itself.
01:03I just like it there.
01:04It fits there a little bit better.
01:06It gives me a nice horizontal menu to work with, rather than having another
01:09panel to worry about.
01:11In the case of higher screen resolutions, it actually saves a little bit
01:13of screen real estate.
01:14So, I kind of like it being up there.
01:16Now at this point, we're really going to need to do a good bit of modification.
01:20The first thing I'm going to do is start over here in the doc.
01:22I'm going to close everything that's not directly related to working with your site's CSS.
01:27Now the browserlab panel, which is new in CS5, is related to working with CSS;
01:32however, if I want to preview using Adobe's browserlab, I can do that directly
01:37here through my Preview icon.
01:39You can see there is the option right there.
01:41So, devoting an entire panel to that, if I'm not going to be using the panel,
01:44really doesn't make much sense.
01:46So I'm going to go ahead and go right over here to the Panel menu, and I'm just
01:49going to close that tab group.
01:51That's going to leave the CSS Styles, AP Element, and Tag Inspector panels together.
01:55Now, I don't use the AP Elements panel that often, but it does allow me to see
02:00certain elements on the page, if I'm using absolute positioning.
02:02So I think I'll leave it alone.
02:04The Tag Inspector really isn't hurting anybody by being there either.
02:07So I'll just leave the CSS Styles panel.
02:09It's kind of the default panel from that group.
02:11Well, there is another panel group directly underneath this, Databases,
02:15Bindings, and Server Behaviors.
02:16Since I'm focusing on styles and not dynamic development, I'll go ahead and
02:21close that tab group as well. Cool!
02:23Now that leaves me with Files, Assets, and Snippets.
02:26Now if you don't see the Snippets panel, and the reason that we're seeing it is
02:29because we're starting with the Classic space,
02:31if you don't see that, you're going to want to open that.
02:33You can do that by going up to Window and choosing Snippets.
02:36Ours doesn't have a checkmark beside it, but it is part of that group.
02:39So I don't need to select that, but if I do, notice that it just focuses on the
02:42panel within the group.
02:43It doesn't really close anybody else out.
02:45So I want to make sure the Files and the Snippets panel are docked right over there.
02:50Now I'm not going to include anything else in the dock.
02:52If you have a high screen resolution and you have a lot of screen real estate,
02:55and you want to put some more panels over there, nothing wrong with that.
02:58This is just going to be our CSS- focused workspace, so we don't really need any
03:01of those other items.
03:02Now, one toolbar that I want that isn't opened, by default, is the
03:06Style Rendering toolbar.
03:07So, I'm going to go right over here to my Document toolbar, I'm going to
03:10right-click on that, and I'm going to choose Style Rendering from the menu that comes up.
03:14You could Ctrl+click on the Mac if you'd like, if you don't have a two-button mouse.
03:19Now, that's going to bring up the Style Rendering panel.
03:21So I'm just going to undock this and float it for just a minute, so you guys can see this.
03:25Now, that's another big difference between the Mac and the
03:28Dreamweaver interface.
03:29For those of you on the Mac, if you just try to undock the Style Rendering
03:32toolbar, you are unsuccessful.
03:34It docks in the Document toolbar, and it just sort of stays there.
03:37But on the PC, we're free to kind of put this anywhere that we want.
03:40So, I'm just going to go ahead and move this to another location.
03:43I'll place him me on right here in the same little line with the Document toolbar.
03:48Now you may have noticed that we can't see the whole thing. Well, that's okay
03:51because if I really need to, I can collapse my panels down the icons, and I'll
03:55have full access to that.
03:56So I can just sort of toggle those back and forth when I need to get to
03:59these pseudo-selectors.
04:00Now, what the Style Rendering toolbar does for us is it allows us to look at our
04:04print styles, or screen styles in sort of isolation, or turn our Style Rendering
04:09on and off within Dreamweaver's Design View.
04:11So it's a very, very handy toolbar to have around when you're working with your styles.
04:15Now, there is one last thing I want to do here, and I'm going to go up to the Windows menu.
04:18I'm going to go down to Results, and I could really choose any of these.
04:22It doesn't really matter.
04:22So I'll just choose Search, which is the first one.
04:24That's going to bring up a much larger panel group.
04:27This has the Search, Reference, Validation, and what we're really interested in
04:31here is in Browser Compatibility panel.
04:33If we do a Browser Compatibility check on our CSS, the results are going to show up there,
04:38so it's a good idea to go ahead and have this opened.
04:40Now obviously, this is not a very efficient workspace.
04:43So, what I'm going to do is take the Properties tab right here, drag that down
04:47so that it groups with these guys, and then I could even take the Properties tab
04:51and move it all the way over here to the left.
04:53So, it's the first panel in the group.
04:55I just kind of like it having that sort of default location. So there we go!
04:58We've got a workspace now that is going to work for us while we're working with our CSS.
05:02We have our CSS Styles panel.
05:04We have Snippets where we can save snippets and code, if we're working with
05:07certain styles that we want to reuse later.
05:09We have our Style Rendering toolbar, and our Results panel group is docked with
05:14our Properties Inspector.
05:15So, that's perfect!
05:16Well, you don't want to have to keep doing this every single time you work on your styles.
05:20So, I'm going to go right up here to the workspace switcher, and I'm just going
05:23to choose New Workspace.
05:24I'm going to call this workspace CSS.
05:27I'll go ahead and click OK.
05:29That's part of my menu structure now.
05:31I can switch back to CSS at any time.
05:33So, if I go back to Designer, for example, or if I go to the Coder environment,
05:37it's really easy for me to just come right back up here, choose CSS, and it
05:41takes me right back to where we were. Cool!
05:43So, we now have a workspace that gives us quick access to all the tools we need
05:47in Dreamweaver when working on our styles.
05:48Now, this workspace is going to allow us to focus on our styles and save us a
05:52good bit of time that we would normally spend opening, closing, and arranging
05:55panels for each new task.
05:57So, regardless of what you're doing in Dreamweaver, whether you're working on
05:59styles or working in a coding environment, I'd recommend considering creating a
06:03custom workspace for that particular task, so you don't spend so much time
06:07opening and closing panels.
Collapse this transcript
CSS Styles panel overview
00:00The central location for controlling styles visually in Dreamweaver is the CSS Styles panel.
00:06It's not an exaggeration to say that almost anything you can or need to do with
00:11CSS can be done through this panel.
00:13It provides an overview of all external and embedded styles, and allows you to
00:17create and modify and manage styles, and also allows you to focus on the styling
00:21of individual elements.
00:23You'll find the CSS Styles panel in the CSS panel group, usually located at
00:27the top of the Panel dock, although you're free to reposition it anywhere you'd like.
00:30Now, at the top of the panel, you'll find buttons for two different views: All and Current.
00:36The All view gives you an overview of all of the CSS styles applied to the
00:40current document, while the Current view gives you a detailed view of the rules
00:44applied to any selected element. All right.
00:46Well, let's take a deeper look at the CSS Styles panel.
00:49In order to do that, I'm going to go to my Files panel, and I'm simply going to
00:53double-click the tab, which is going to collapse that group.
00:56That's going to give me much more screen real estate to work with, and I get to
00:59see the entire CSS Styles panel and not sort of a little cramped view of it.
01:04Notice that you can grab any of these dividers and move them up or down.
01:07So, if you need to see more of one area of the panel versus another, you can
01:11always sort of customize that to seeing exactly what you need.
01:14Now, let's take a look at the All view, and I want to first turn our
01:17attention to the top pane.
01:20This is where all of our CSS styles are listed.
01:22So, here is our main.css.
01:25We know it's an external style sheet that's attached to our page because it
01:28has the .CSS extension.
01:30I can also see it's been assigned the screen and projection media types.
01:34Then I have a listing of all the styles that are inside this CSS file.
01:39Now, I can collapse that.
01:40Now, on Mac you'll see a little arrow there, but on the PC I'm just going to
01:43click on the little minus symbol.
01:44I can also see that I have some embedded styles in this page, one to be
01:47specific, and I know it's an embedded style, because I see this style tag. All right.
01:51I'm going to go ahead and open my main.css back up again, and I'm just going to
01:56scroll down and sort of randomly select a rule.
01:59Well, #mainContent is already highlighted, so we'll just go ahead and leave that highlighted.
02:03Now, if you don't have #mainContent highlighted, simply scroll down, and any
02:07rule that you click on you're going to see just below it, in the Properties
02:10pane, you're going to see properties for that rule.
02:12So if you select the one that's on there, you'll see the properties for that rule.
02:15Now, you can display these properties in one of three ways.
02:18The first is the Category view, and you can see these little icons right down
02:21here on the bottom left-hand side of this panel.
02:24The Category view is going to show you different categories, such as controlling
02:28Font properties, Background properties, Block, Border, Box.
02:33You can see most of the properties of the #mainContent selector deal with
02:36Box model properties.
02:37So, we have width, float, margin-bottom.
02:39There, you can quickly go through your categories and find properties you want
02:43to apply to it, or look at the properties that have already been applied to it.
02:46We also have a List view.
02:47Now the List view is going to show you all of your applied properties in order.
02:51They're going to appear at the top.
02:52Then after that, you have a listing of every single CSS property that you can set.
02:58Now, it doesn't mean that you can set it for that particular element.
03:00It's really giving a list of everything.
03:03So, it's a nice way to sort of quickly find any properties that you want to apply to it.
03:07Now, the third view is my favorite, and it's also the default.
03:10That is going to show you only the set properties.
03:13What I like about that is it sort of clears out the clutter.
03:16All you get are the properties that are assigned to this element.
03:18If you want to modify it by adding properties, you can do that by clicking
03:21the Add Property link.
03:23Now, we're going to take a look at that in just a moment.
03:24I'm going to scroll down over here on my Index page, and I'm just going to click
03:28right here into this paragraph of text.
03:30Now, as soon as I do that, I don't really see any change in my CSS Styles panel,
03:34because I'm still looking at all of the styles.
03:36But if I click on Current, notice that now it's focusing on this text, not so
03:42much any individual rules.
03:43In fact, now I get three panes, and the top pane is giving me a summary of this
03:48rule, meaning all of the properties from all of the different rules in style
03:51sheet that would apply to this element.
03:53Then the middle pane here is giving me a cascade.
03:56It's showing me which rules are applied to this.
03:59If I click through them, I can even see which values are being applied, and
04:03which are inherited, which are not inherited, which are being overwritten.
04:06This is a really useful view
04:08we're going to take a closer look at a little bit later on.
04:11Well, just as in my All view, if I want to add another property to a rule, I could do that.
04:15So, I could click right here to add a property, and if I wanted to, I could just
04:19type in say margin-bottom.
04:22Now, if you're not that comfortable with typing in a value, you're worried about
04:25misspelling it or something, you can also grab the pulldown menu, and you can
04:28choose Properties that way, which is pretty cool.
04:30Now, just to the right of that, you're going to be typing in a value.
04:32I'm just going to type in 1 em.
04:33Now, notice that I can type in the em value right after it.
04:36I don't have to grab it from the pulldown menu.
04:38If I hit Return, it would go ahead and add a 1 em margin-bottom to my
04:42paragraph selector.
04:43Now, another cool thing that we can do here is that we can enable and disable
04:47specific properties.
04:48Let's say we're troubleshooting, and we're wondering if this spacing is what we
04:52really want between these lines.
04:53Well, I could come right over here to my Properties and disable that line-height
04:57property to see what it would look like without the line property applied.
05:01I could peruse the whole page and kind of see if it affected my page
05:05negatively in other areas.
05:07Then I could enable it again simply by clicking.
05:09Now, this is called Enable, Disable CSS Property, and you can do this just about anywhere.
05:14Notice that the icon is right down here in the lower right-hand corner.
05:17Notice that the icon also is showing up here in your Summary for Selection, and
05:22you can go ahead and enable and disable here.
05:24Even if you're working in the All view, you can still enable and disable
05:27properties right there.
05:28So, it's a really powerful little tool to use.
05:31Now, just sort of going over some of the other options, and I'm going to turn
05:34it back on, because often it's horrible, but some of our other options that we
05:37have down here. We can delete properties and rules. As we've seen, we can enable and disable them.
05:41We can edit rules.
05:42We can create new ones.
05:43These are all things that we're going to be doing a little bit later on.
05:46But I'm interested in one in particular here, which is to attach a style sheet.
05:49I'm going to go over here to All again.
05:51I notice that I have one external style sheet, which is main.css.
05:55Well, I'm going to go ahead and click the Attach Style Sheet icon right here,
05:59and now I can attach an entirely new style sheet to this page.
06:03So, I'm just going to hit Browse.
06:04I'm going to browse into the 01_05 folder/ _css, going to that folder, and I'll
06:10choose our print style sheet, and also I'll go ahead and click OK.
06:12Now, since this is a print style sheet, you can choose whether to add that
06:15through the use of a Link tag or add Import.
06:17I'm going to use a Link tag, and I'm also able to go ahead and assign a
06:20Media type to this.
06:21So, I can go to the pulldown menu and choose print, or I could just type it in if I wanted to.
06:25I'm going to go ahead and click OK.
06:26Notice that we now have a brand-new style sheet attached.
06:29Now, one of the things I'm trying to show here is how cool some of the Visual
06:32tools are in Dreamweaver.
06:33But just because they're cool, doesn't mean that they're going to do everything right.
06:37Now the CSS Styles panel does almost everything right.
06:39But this is one of the things that it gets a little wrong which is really kind
06:42of why I wanted to point it out to you, so that you'll be aware of it.
06:45I'm going to switch over to Code view, and I'm going to make sure I'm looking at my source code.
06:49I'm going to scroll up towards the head of the document.
06:51So here, we can see the Link tag for our main style sheet.
06:55Here we see our embedded styles, and then, right here on line 13, we could see
06:59our print style sheets.
07:00So, what Dreamweaver does, the order that you create your styles is the order
07:04it's going to assign these.
07:05Well, even though it's a print style sheet, it's still a bad idea to have it
07:09below in the embedded styles.
07:10So, I'm going to grab that, cut it, so Ctrl+X or Command+X, and then paste it on
07:16the line below our main.css.
07:18I'm just going to sort of reorder those guys.
07:21Save that. Switch back to Design view.
07:23Now, if I look at my CSS Styles panel, I can see that it's changed order here too.
07:28Now, I would love to tell you that you could drag them out here, but it doesn't
07:30quite work that way.
07:31But it's nice, because it gives you a nice visual clue as to whether your styles
07:35are out of order or not.
07:36So you can see the order that they're being applied to the page, which is pretty cool.
07:39So, I think it's pretty clear that the CSS Styles panel puts an amazing amount of
07:43information at your fingertips.
07:44Now, it's often going to give you the fastest and most efficient way to create
07:47and modify rules, and it gives you a really cool central location to control all
07:51of your styles throughout your entire site.
07:53Now, I want you to pay attention, because as we delve a bit deeper into
07:56Dreamweaver's ability to control and manage your styles, we're going to be
07:59exploring this panel in a lot more detail.
08:01Keep in mind that just like everything else, you must fully understand how the
08:04panel works in order to use it effectively. Knowing its nuances and quirks, like
08:09adding style sheet links to the bottom of the head tag, as well as the strengths
08:12are important for making sure the panel is used properly throughout the
08:16development process.
Collapse this transcript
The Properties Inspector
00:00The Properties Inspector is the contextually-sensitive nerve center of Dreamweaver.
00:04It allows you to control the HTML and CSS based properties of any element that
00:09you have selected, or that you're currently focused on.
00:11From the CSS point of view, there is a lot you can do through the
00:14Properties Inspector.
00:15It can, however, lead to some pretty unexpected results when editing your CSS,
00:19so it's really important to know exactly how it works, before using it to assist
00:22you in managing your CSS.
00:25The Properties Inspector is going to be located at the very bottom of your interface.
00:29Now if you don't see it, you can go up to Window and choose Properties, and that
00:32will open it up, and probably open it up in that location.
00:35Now you can see that the Properties Inspector has two tabs.
00:37It has an HTML tab and a CSS tab.
00:41The HTML tab controls structural properties,
00:43so heading tags, paragraph tag, strong tags, things like that.
00:47The CSS tab controls your style properties.
00:50The information that displays is based on the element you currently have selected.
00:54Now we do have this button right down here in the bottom that says Page Properties.
00:57If I click on that, I get a summary of some of the Appearance settings and some
01:01of the data that we can set for our pages.
01:03Notice that we have an Appearance for both CSS and HTML.
01:06Now this actually can allow you to do some things that really isn't done much anymore;
01:11for example, setting a Background image on the body tag as an attribute - we
01:15generally control those through style.
01:16So you want to be really careful about setting certain properties here.
01:20Now if you do choose to use this, and you can see that right now mine is
01:23populated with a font, some sizing information, background colors, background
01:27images, things like that.
01:28It's picking that information up from my external style sheet.
01:31So it can examine your style sheet, and then let you know exactly what type of
01:35general properties you've applied to your page.
01:37So it's a nice way to see a summary of that.
01:39If I made a change here, it would actually change my external style sheet.
01:42But if I was starting from scratch, it would write those styles for me.
01:45Now you want to be very careful about doing that, because if you're used to
01:48writing your CSS a certain way, there is no guarantee that Dreamweaver is going
01:51to write the styles the same way that you would write them.
01:53So you might want to experiment with it, and see if it works the same way that you want it.
01:57But typically, I use it just a sort of get an overview of how things are looking.
02:00I am going to make Cancel there.
02:01Let's take a look at using the Properties Inspector to actually modify our CSS.
02:06I'm going to scroll down a little bit to Customer notifications, this heading
02:09right down here, and click inside of that.
02:11Now I can see that this is an h3 tag.
02:13I can see that by looking at the tag selector, but if I look over at my
02:16Properties Inspector, it also tells me that the Targeted Rule is the h3, because
02:20I'm inside of an h3 tag.
02:21You can also see that if I hover that, it tells me where that rule is found.
02:25It's found in my external style sheet, main.css.
02:27Well, there aren't too many properties within the Properties Inspector.
02:30We have Font, Size, Color and a few other ones.
02:33Notice that if I hover over Color, it tells me that it's inherited from the rule h3.
02:38If I hover over Size, it tells me it's inherited from the rule h3.
02:40If I hover over Font, it tells me that font-family is actually inherited from
02:45the rule h1, h2, h3.
02:47So you don't want to infer from these properties that
02:49they're all coming from the same rule.
02:50What we're seeing here is an aggregate of all of our CSS styles.
02:53So if a Font is actually inherited from a tag or a selector above that, you're
02:56going to see that here.
02:57Now that might make you a little nervous about changing that.
03:00So let me show you what happens.
03:01I'm going to grab the Font pulldown menu, and I'm going to change that to Arial.
03:04Now you'll notice that even though we were inheriting the Font property from the
03:08h1, h2, h3 selector, you'll notice that my other headings did not change.
03:12The reason for that is because the Targeted Rule over here, it's at h3.
03:16So if I hover over Font now, notice that it's inheriting it from the rule h3.
03:20So what Dreamweaver did, it goes ahead and targets the closest selector to
03:24that particular element,
03:25by closest selector, I mean the closest in the cascade.
03:27It applies it to that particular selector.
03:29So from that standpoint, it's kind of worry free.
03:32You're not going to be changing a selector that is inheriting the properties from.
03:35It's going to go to the very closest selector within the cascade and apply it there.
03:39If I hold the Alt key down, and that'll be Command+Option key on the Mac, and
03:43click on the headline, you can kind of see the cascade.
03:46You can see all the different selectors that are applying to the h3.
03:48The h3 one is the absolute closest to it, and that's the one where the
03:52font-family was applied to.
03:54Now, had I wanted to make that change to all the headings in my site, I could
03:57have easily done that by grabbing the Targeted Rule pulldown menu, scrolling up
04:01and finding that h1, h2, h3 selector.
04:03So if I select that, and target it specifically and then tell it Arial, notice
04:08that all of my headings changed now.
04:10So you can be very specific about which rule you want to affect, or you can let
04:14Dreamweaver go ahead and affect the rule that's closest to the element that you
04:17have selected within the cascade.
04:19So it's a very intelligent interface, from that standpoint.
04:22Now we are also free to edit rules.
04:23So if you target a rule and hit Edit Rule, you can bring up the visual dialog box.
04:27I'm just going to hit Cancel.
04:28You can also target the CSS panel, and make sure it focuses on that particular
04:32rule by clicking that.
04:33But the Targeted Rule pulldown menu also has a couple of other things that are pretty neat.
04:36If I grab that pulldown menu, notice that I have the ability to create a brand New Rule.
04:41I also have the ability to create a New Inline Style.
04:43What's neat about that is that's the only place in Dreamweaver's interface where
04:47you can create an inline rule without actually having to hand code it yourself.
04:51You might be saying, who is going to use inline rules?
04:53Well, if you're creating HTML newsletters, for example, that's a really nice way
04:57of ensuring the proper styling.
04:59So they're still valid in that instance.
05:01It's nice to know that we have a place in Dreamweaver where we can go ahead and
05:04create those visually.
05:05So that's pretty cool.
05:05Now there are some distinct differences between the HTML and CSS tabs.
05:10I want to showcase those for just one minute.
05:12So if we scroll down a little bit further, we can see that in the first
05:14sentence here, it says when you book a tour with Explore California, you
05:17should receive two notifications.
05:19I'm going to highlight the notification tour confirmation right there.
05:23If I'm on my CSS properties, and I go and hit the Bold icon right here, it's
05:27going to attempt to create a new Class selector around that.
05:30That's not what I want.
05:31I want a strong tag there.
05:32So notice that if I click on the HTML tab and click Bold, I get a brand-new
05:37strong tag around this.
05:38So even though it's the same icon, very different results based upon which
05:42tab you've selected.
05:44So if I go back to CSS and highlight Explore California, and choose Bold, now
05:48it's asking me do I want to create a class, and maybe in this case I do.
05:51Maybe I want to create the company class.
05:54Notice that I've created a brand-new class, applied it, applied a span tag
05:58around it with that.
05:59I can even go ahead and change things like Color, for example.
06:03So I can go ahead and sample that color from my navigation.
06:06Now it's applied that to company, as well.
06:08So now I have a class that I can use any place that I find Explore
06:11California, for example.
06:13I can simply highlight, grab the Targeted Rule pulldown menu and apply
06:18that company class.
06:20So the Properties Inspector is actually an incredibly efficient way to manage
06:23certain aspects of your site's CSS.
06:26You just need to be sure you know where you're focused, and whether the CSS
06:30or HTML tab is active.
06:31Also, make sure you understand how that Targeted Rule feature works.
06:35That's going to help you determine which rule is going to be edited.
Collapse this transcript
Creating styles visually
00:00Regardless of the method that you choose to create new rules in Dreamweaver,
00:04when creating a new CSS rule visually, you'll use the New Rule dialog to specify
00:10the selector, and the CSS Rule Definition dialog to set the rule's properties.
00:15While this process is fairly straightforward,
00:17knowing the ins and outs of it can really help speed up the creation of
00:20CSS in Dreamweaver.
00:22As you can see, our page currently has no styling whatsoever.
00:25To get structure on the page, notice we have a body tag, a div with an id of
00:29mainContent, but past that, really nothing going on, style-wise.
00:34So the first thing I'm going to do is go over to my Files panel and collapse it.
00:37Again, that gives me a nice, larger view of my CSS Styles panel, and I want
00:40to create a New Rule.
00:42So I'm just going to go right down to the bottom of CSS Styles panel, and I can
00:45see there is an icon right down here.
00:47That looks like a page with the Plus symbol on it.
00:49I'm going to go ahead and click that to create a New Rule.
00:51Now this brings up the New CSS Rule dialog box.
00:55This is where you're going to tell Dreamweaver which elements on the page you
00:58want to target, so what Selector you want.
01:00Notice that we have several different types of selectors that we can choose
01:03from: classes, ID selectors, Tag, which is also referred to as element
01:08selectors, and Compound selectors.
01:10The Compound Selectors pretty much are anything you want.
01:13Usually they're descendent selectors, but that means you can just type in
01:15anything you'd like into the dialog box.
01:18I'm going to choose Tag.
01:19I can go ahead and grab from the pulldown menu in the Selector Name whichever
01:23tag I want, or if I'd like, I can also highlight it and just type it in.
01:27So let's go ahead and do the body tag.
01:29So either I grab that to the pulldown menu or just type in body.
01:33Now spelling counts here, so if you're going to type into this dialog box, make
01:37sure you type everything correctly.
01:39Now after you tell it which type of selector you want, and then after you define
01:43the selector, the next thing in this dialog box is to choose where that rule is
01:47going to be located.
01:48Now in this case, we're going to say, This document only, but notice we can also
01:52attach it within a New Style Sheet File.
01:55If our current page had a style sheet already attached to it, we could
01:58also place it in there.
01:59So for this one, I just want to say, This document only.
02:01So I'm going to go ahead and click OK, and now we're presented with a
02:04brand-new dialog box.
02:06This is the CSS Rule Definition dialog.
02:09Now notice that on the left- hand side we have categories.
02:12So we can look at the properties regarding Type, Background properties, Box
02:17model properties, Positioning properties, all sorts of categories over here.
02:21I'm going to stick with Type for the moment, and what I'm going to do is go to
02:24Font, grab the pulldown menu and choose Georgia, Times New Roman, Times, serif.
02:29So you can see that within this dialog box, there are already a lot of
02:33predefined font stacks in here.
02:35If you're coding by hand, you'd have to type in those font stacks yourself, but
02:38Dreamweaver has a lot of those already in.
02:41You're free to create your own, if you want to use one that Dreamweaver doesn't have by default.
02:45For font size, I'm just going to choose 100, and I'm going to type in percent.
02:49Now there are plenty of units of measurement that you can use.
02:52You're free to grab the pulldown menu here and use whatever you'd like.
02:55But if you know the unit of measurement you want to use, you don't have to do that.
02:59You can just go ahead and add it directly after the number itself, as I did
03:03here with percentage.
03:04If you hit Tab, notice that it will go ahead and populate that there.
03:07So that works perfectly.
03:08Now I'm going to go to the Box Category.
03:10In the Box Category, I'm going to choose 0 for Padding, 0 for Margin.
03:15I'm just going to leave Same for all selected.
03:17So I'm going to go ahead and click OK.
03:20Notice that our font changed, font size may have shifted on you just a little
03:23bit, but also our content is now budding up right at the edge of the page,
03:27because our default margins and padding are now gone.
03:30Notice in the CSS Styles panel it now shows you that selector, and we get a
03:35nice overview of the selector, as well.
03:37Let's go ahead and create another rule, but we're going to have Dreamweaver sort
03:39of shorten that process.
03:41I'm going to click right here in the headline, Got questions.
03:44You'll notice its right there inside of an h1 tag.
03:47So I'm going to go ahead and choose New CSS Rule.
03:49When I do that, at first it's going to try to do a Compound Selector because
03:53there is some structure involved here.
03:54But I'm going to switch that to Tag, and notice that it automatically puts h1 in
03:58there, because that was the element that we were focused on.
04:01Once again, I'm going to say, This document only, and click OK.
04:03For that one, I'm going to choose a Font-size of 2em.
04:07Notice again, all I have to do is type em directly after that.
04:11For Color, now when you choose a Color using any of Dreamweaver's visual tools,
04:15you do get a Swatch panel.
04:16Now at first, people get really excited about that, but the reality of it is
04:20you're not going to be able to save your Custom Colors to this.
04:22So this is just the Web safe color palette.
04:24You do have a Color Picker, so you could mix a color together if you'd like.
04:28That would work out just fine.
04:29You could also type in the hexadecimal value directly right here.
04:33Now there is also another feature here that I really like about this Color Picker.
04:36Notice that if I click the color chip, I can go right over here to the image and
04:39really anywhere within your document window, and I can just pick a color
04:43directly out of that.
04:44So if I want to get that particular blue, I can click that.
04:47If I hit Apply, I can preview those changes.
04:50You can see I can preview the color here.
04:51Now I'm actually going to type in the hexadecimal value.
04:53So I'm going to leave the pound or octothorpe character there, and right after
04:57that I'm going to type in 193742.
05:01So unfortunately, it's not going to remember those colors for you, or store them,
05:05so if you have Custom Colors that you're going to be using, you're probably
05:08going to type this in manually each time.
05:09Now, I'm going to go to my Box Category.
05:11I'm going to deselect Same for all for Margin.
05:14I'm going to give it a Top margin of 0, a Right margin of 0, Bottom margin of
05:180.4 ems and a Left margin of 0.
05:22I certainly could have just gone right down to the Bottom margin and chosen that, as well.
05:26We can go and click OK.
05:27Now I can see all of my summary of my properties there.
05:30Now I'm going to scroll down a little bit.
05:31So far, we've done two element selectors.
05:33Let's take a look at writing a different type of Selector.
05:36So if I scroll down to the Customer notifications paragraph, I can see in the
05:40first line we have right here, When you book a tour with Explore California.
05:44So I'm just going to highlight the words Explore California. Maybe I want those
05:47styled a little bit differently than the rest of my page.
05:50So with that text highlighted, I'm going to click New CSS Rule.
05:53Now interestingly enough, you'll notice that Dreamweaver went ahead and
05:57automatically chose Class for Selector Type.
05:59It did that because I had a range of text selected and not in one specific tag.
06:04So I'm just going to go ahead and choose a Selector Name for this.
06:06I'm just going to type in .company.
06:09Now the dot is important.
06:11It precedes any Class Selector.
06:12So I want to make sure it's typed in, and then the word company right behind it.
06:16If you leave that off, Dreamweaver will place a dot in there for you, but it's a
06:19bad practice to get in the habit of doing.
06:21So make sure you remember to place a dot before any class name.
06:24Now so far, we've placed these rules in the current document, but what if you
06:28wanted to create a brand-new style sheet?
06:30Well, creating a new rule and a new style sheet all at the same time is a pretty
06:33efficient operation, if you're creating a new style sheet for your site.
06:37So I'm just going to choose New Style Sheet File. Click OK.
06:41Now I'm prompted by an entirely new dialog box to go ahead and name this
06:45particular style sheet.
06:46I'll go inside the _css folder, and I'm going to save it as main.css.
06:51I'm going to go ahead and Save that.
06:53So you'll notice it went ahead and created the style sheet and attached to the
06:56page in one operation, as we're creating the style.
06:59That's pretty efficient.
07:01So I'm going to go ahead and change my Font-weight to bold.
07:04I'm going to go ahead and apply that same Color.
07:06Now again, it would be really helpful if you can remember it for us, but it can't.
07:09So I'm just going to type in #193742, and go ahead and click OK.
07:16Now you'll notice that nothing changed on the page.
07:18Well, it created the class, but it's not going to automatically apply it for you.
07:21So I can go ahead and go down to my Properties Inspector, and through the use of
07:26this Targeted Rule, I can grab that pulldown menu and just apply the company
07:29class to that range of text. Here we go.
07:32Now we have our new styling.
07:33Before we finish, let's do one more selector.
07:35I'm going to go right up here to my image, and I'm going to click on that
07:38to image to select it.
07:39I'm going to go back over to my CSS Styles panel, and click New CSS Rule.
07:44Now as soon as I do that, and notice again, it keeps trying to do Compound Selector.
07:48Compound selectors by and large will be descendent selectors, meaning you're
07:51targeting a specific element inside of another element.
07:55You're really free to type in any Selector that you want.
07:57I do want to point something out though.
07:58Let's say that for whatever reason, you just chose Tag, ID, or Class.
08:03And then you decide, well, I just want to type in a Selector.
08:05So, maybe I might type in #mainContent img.articleImage.
08:14So this is a pretty complex Selector.
08:16I'm targeting a Class-specific element selector, img.articleImage, and I'm doing
08:22that inside of the mainContent element.
08:24Now if I go and click OK, Dreamweaver says no, you can't do that.
08:28Class names must start with an alphabetical character.
08:31To be honest with you, if there is one thing that annoys me about the New CSS
08:34Rule dialog box, it's this.
08:36If you're not paying attention to which Selector Type you're trying, you might
08:39just go ahead and start typing.
08:41Well, when you click OK, you're going to start typing all over again, because
08:44the really bad thing about this is that now when I go down to Compound, I
08:48lose what I was typing.
08:50So you want to always double-check this first, and make sure you have the
08:54Selector Type that you need.
08:56Now another nice thing this does is it tries to write the selector for you.
08:59So you can see that we have an image selected inside here, which is inside of a
09:02paragraph, which is inside main content.
09:04So that's the descendent selector that it gives us.
09:06I can also tell it to be Less Specific or More Specific based on its location.
09:10Most of the time that can really help you and can speed up the creation of your
09:13selectors, but in this case, it's not really going to help us.
09:15So I'm going to remove the paragraph.
09:17I'm going to make sure the space is still there, and I'm going to add the
09:20.articleImage Class Selector to the image element.
09:27So what we have here again is #mainContent img.articleImage, all one word, okay?
09:34So I'm going to make sure Compound Selector is up here, so I don't have to type that again.
09:38Make sure it's doing it in This document only.
09:41I'm going to go ahead and click OK.
09:42I'm just going to do a couple of choices here.
09:44I'm going to go to my Box Category and Float it to the right.
09:50I'm going to go to my Block Category and change the Display of this to a
09:54block-level element.
09:55Then finally, to keep the text away from it, I'm going to go to the Box
09:58Category, and set some Padding.
10:00So I'm going to turn Padding off.
10:02Do 1 em for the Padding for the Top, 0 for the Right, 1 em for the Bottom, I
10:08type in 1 em and 1 em for the Left.
10:11So if you're used to hand-coding your styles, one of the things you have to get
10:15used to in this dialog box is where is everything?
10:17So you'll notice that I just clicked, and said, okay, let's go to Box and get my floating.
10:21Let's go to Block, and get the Display properties.
10:24So it's going to take a little while before you're totally comfortable with
10:26where all your properties are.
10:28Now, you're also not going to find all of your properties.
10:31Notice, for example, if I go to Border, I don't have the Border Collapse property.
10:35It's not here.
10:36The CSS3 properties aren't here.
10:39So don't expect to find everything in this dialog box.
10:41So if you're used to hand-coding, there are some properties that you're still
10:44going to need to hand-code.
10:46If you're not used to hand-coding, and kind of hoping that you don't have to do that.
10:49Notice this dialog box is pretty thorough, but it doesn't have everything.
10:52So I'm going to go ahead and click OK.
10:53I will apply that class of the image by selecting it, and then
10:57choosing articleImage.
10:59Notice that our text is now floating around the image.
11:01I'm going to click on Live View just to make sure yeah, okay, so that is doing
11:05exactly what I wanted it to do. Cool!
11:07So creating styles visually in Dreamweaver is pretty fast.
11:10But it is a process that can be a little frustrating, if you don't understand
11:13why certain things are happening the way they are.
11:16If you prefer to hand-code, I doubt this process is going to totally replace
11:19that method of writing styles for you full time.
11:21I would encourage you, however, to try it and become familiar with it.
11:25There are many instances where adding new rules through the visual dialogs can
11:30actually speed up your workflow.
Collapse this transcript
Hand-coding styles
00:00If you only use the visual tools in Dreamweaver, you're really only using half the program.
00:04Now, I know that some designers are a bit hesitant to start coding on their own,
00:08but in reality CSS is incredibly easy to learn, and Dreamweaver's coding tools
00:13make it the fastest way to create your styles.
00:15In this movie, we'll take a brief tour of Dreamweaver's coding environment and
00:18start coding by writing a simple CSS Rule.
00:21If you're familiar with coding CSS, and just want to see how Dreamweaver's
00:24coding environment works, stick around.
00:26We'll be covering some of that as well.
00:28I'm just going to go ahead and create a brand-new CSS file because we really
00:31don't have one attached to the page yet.
00:33So I'm just going to go to File and choose New.
00:36From the New Document dialog box, I'm going to go down to Blank Page and choose
00:39CSS, and go ahead and create it.
00:41So here we just have an empty CSS file.
00:44I'll go ahead and save it, and I'm going to save it in the 01_08 CSS directory,
00:50and I'll just save it as main.css.
00:53Now, I could go ahead and start coding here, but I kind of like working with my
00:58HTML and my CSS files sort of side-by-side.
01:01So I'm going to close this document and go back to Resources.
01:04I'll go over to my CSS Styles panel.
01:06The CSS Styles panel is sort of the central nervous system of working with
01:09styles in our sites.
01:11I'm just going to go right down here to the bottom and choose Attach Style Sheet.
01:14I'm going to go ahead and browse, and I'm going to browse to 01_08/_css and find
01:20the style sheet that we just created, click OK and for Media, I'm going to go
01:24ahead and type in screen,projection.
01:29So you can grab from the pulldown menu, or you can go ahead and type in comma
01:32separated Media types if you want to apply more than one.
01:35We're just going to do Link. Click OK.
01:37Now, our main.css is attached, even though the style sheet is still empty.
01:42So why didn't I'd want to just start hand-coding directly in the CSS Style Sheet?
01:46Why did I go through the process of attaching it to the sheet?
01:48Well, inside Dreamweaver we have what's known as Related Files, and you can see
01:53that now that we've attached the CSS Styles Sheet to this page, I'm just going
01:56to go ahead and save my page,
01:58you see right below the tab, there is main.css, and all I have to do to view
02:02that is click on that, and it goes in and opens that up.
02:04Now, I'm going to switch to the Code environment, so that I can see nothing but
02:08my CSS, even though I'm still working on resources.htm.
02:11So this allows me to switch back-and- forth between Design and Code, and I can
02:15visualize those changes that I'm making.
02:17I can also do a Split Screen view where I see the Design view on this side and
02:21the Code view on this side.
02:21It's a very efficient way of working with both your code and your page. You can
02:25sort of see those changes you're making all at once. Okay.
02:28Well, let's take a brief tour of the coding environment.
02:31Now, over here on the left-hand side, we have a brand-new toolbar.
02:34This is a Coding toolbar, and this has some really interesting things.
02:37It allows us to collapse Tags and expand those Tags, select Parent Tags,
02:42and that's all well and good for working with HTML, but it doesn't do a whole
02:45lot of good for us with CSS.
02:47Now, we do have Line Numbers that we can turn on and off, so all these icons
02:51refer to something within your code.
02:52You can highlight invalid code.
02:54You can do word wrap, in case you have long strings of code.
02:57You can wrap your code in a comment, or you can delete a comment.
03:01Notice that I don't have quite enough screen real estate to show everything,
03:03so I click this little Show More section, and I can do things like Move or Convert CSS.
03:09So I can convert inline CSS to an external rule.
03:11I can move CSS Rules from one sheet or one page to another.
03:14I can indent code, and I can apply other formatting which we'll take a look
03:17at in just a moment.
03:18I'm going to place my cursor right below the character set encoding option and
03:23the comment for CSS Document.
03:25By the way, these are all optional.
03:27You don't have to use them.
03:28You can use your own comments.
03:30You don't have to add the encoding characters here, but that's just something
03:33that Dreamweaver puts in by default.
03:34So we're going to write our first selector, and the first thing we want to do is
03:37just to control the body tag.
03:38Go ahead and set some defaults for our page.
03:41So I'm going to type in "body" for the selector.
03:43Now, Dreamweaver is not going to help you write your selectors.
03:45You're going to have to know what selector it is you're writing.
03:48In this case, we're writing an element selector, and we're controlling the body tag.
03:52Then I'm going to open up a curly brace.
03:53Now, notice that the moment I open up curly braces, we get something that's
03:56known as Code Hinting and Code Completion.
03:58We're going to take a closer look at that a little bit later on.
04:01Now, if I hit Enter or Return, it will return me to the next line, but notice
04:05that it indents for me.
04:06It's basically following the rules that I've set up for in my code formatting,
04:10and we set that earlier in the movie on Preferences.
04:13I'm going to type in an m and notice that it jumps right down to Margin.
04:16So if that's what I want and in this case it is what I want, I can just hit
04:19Return, and it finishes typing it for me.
04:22I'm going to type in a 0 for no margin and a semicolon, and that property
04:25and value are done.
04:26You can see how fast that is.
04:27Now, I'm going to hit Return to go down to the next line, and I'm going to type in padding.
04:31I want to type in the whole thing because this is a better way to learn the syntax.
04:34So I'm going to type in padding, then type in a colon.
04:37So your properties and your values are separated by a colon.
04:41I'll type in a 0 again and then a semicolon padding:
04:43The semicolon basically ends the line.
04:45It says, okay I'm done with this one, and I want to move on to the next one.
04:50Watch what happens when you leave it off.
04:51I'm going to remove the semicolon, hit Return to go down to the next line.
04:53Now, in the next line, notice that we're not getting our code hinting anymore;
04:57we're getting values for the previous property, because we haven't closed it yet.
05:00Then I can type in the word font, but watch what happens.
05:03You notice that font has not changed color.
05:05It's still that sort of light blue that I set earlier.
05:08Now here, if I type in font:,
05:10I'm not getting any code hinting whatsoever.
05:12So Dreamweaver is giving us all sorts of clues that our syntax is currently wrong.
05:16I'm going to type in 100% and then a space, then type in Georgia, "Times New
05:25Roman" three words, Times, serif.
05:30Now here, I'm going to go ahead and type in a semicolon, hit Return and finish
05:35by closing my curly brace.
05:36Now, you might say well, you know, is this going to work?
05:39Actually, a lot of browsers will render that correctly, but it's a really good
05:42idea to go ahead and put the semicolon back in.
05:44Notice as soon as I do that, Dreamweaver tells me okay, yes, that's
05:47okay, because it gives me the code coloring to let me know that that syntax is correct.
05:52Now, that's not the only way that you can write your CSS styles.
05:54I have each property on a separate line because it really helps me read that.
05:58But there is nothing saying you have to do that.
06:00If I go down to the next line and type in h1 and open up a curly brace, notice
06:04that I could say font-size: 2em for 2 ems, and I could type in a semicolon, and
06:13on the very same line I can just type in color and then do #193742, another semicolon.
06:22So 193742, and I can do margin-bottom: .4em and then a semicolon.
06:32And on that very same line, I can close my curly brace,
06:35so this syntax is exactly the same as this syntax.
06:39It all has to do with readability.
06:41The machine doesn't care whether it's on the same line or whether it's on a separate line.
06:45So this is a little bit easier for us to read, but this rule will work just fine.
06:48In fact, it would save you a little bit of space when you go to deploy your
06:50styles, and we'll talk more about that a little later on in the title.
06:53Now, what happens if you get a mixture?
06:55Maybe you've written it; maybe someone else has written it.
06:57You have some rules are formatted one way. Some rules are formatted another way.
07:00Well, that's where our Code Format Preferences come into play.
07:04Just to review those really quickly, if I go up to Edit and choose Preferences,
07:07that would be Dreamweaver Preferences on the Mac,
07:10I can go to my Code Formatting, click on the CSS button, and I get all these
07:14different properties that I can set and a preview of how my styles are going to
07:18be written, and that, of course, is if Dreamweaver writes them for me.
07:21But what's nice about that is Dreamweaver remembers those preferences.
07:24So if I come down here to my Coding toolbar, click on Show More, and I go right
07:28here to this little paint bucket where it says Format Source Code,
07:30I can say Apply Source Formatting and notice it goes ahead and converts the
07:34rule that we just created to being from one line to multiple line.
07:37So at any point, if you're coding and you want to go ahead and change all of
07:41your rule formatting all at once, rather than having to do that all by hand and
07:44going there and hit Return or move everything to one line,
07:47you can just change your Preferences, hit that, and it's going to go ahead and
07:50switch it for you, which is really cool.
07:52So hand-coding your styles does require you to understand how to write
07:55the desired selector.
07:57You have to know which properties you can set for that particular selector and
08:00which values are accepted by those properties.
08:03So in short, if you want to hand-code, you need to know CSS;
08:06however, as we'll see in our next movie, code hinting and code completion make
08:09this process much easier and can assist designers that are new to writing CSS
08:14by hand.
Collapse this transcript
Code hinting and code completion
00:00To some, hand-coding can seem like a real chore.
00:03And I could certainly understand that, especially when you constantly have to
00:06make sure you're following proper syntax and writing your selectors properly.
00:10That's why I want to take a moment to explore Code Hinting and Code Completion
00:14for CSS in Dreamweaver.
00:15Both can make writing your styles faster and help ensure your styles are
00:18being written correctly.
00:20So I have the resources, and we have our main.css attached to this page.
00:25I'm just going to go to Split view so that I can see the code on one side and
00:28the design on the other.
00:29Now, if you have a limited amount of screen real estate, like I do, when you're
00:33working in this environment, one of the things I like to do is collapse these
00:36panels down to icons.
00:37So I'm just going to go ahead and do that, and you can expand those panels at
00:40anytime if you want to see the labels on them and if you want to use one, you
00:44can simply click on the panel, and it shows up, or you can expand the whole dock back again.
00:48So that's really kind of nice.
00:49It gives you enough room so that you can see what you're doing in both panes. Okay.
00:52So now what I'm going to do is I'm going to scroll down a little bit, and I'm
00:55going to write a new rule beneath these two existing rules.
00:58So I'm just going to hit Return to go down on line below the last rule.
01:02Now, we're going to write a selector for the h2 tag.
01:04So I'm just going to type in h2, and then open up a curly brace.
01:08Now again, we see this list comes up.
01:09So where is this list coming from?
01:11Well, this is called Code Hinting and since we're working with the CSS Document,
01:15Dreamweaver is giving us our Cascading Style Sheet Code Hints.
01:18So where to get those from?
01:20Well, if we go up to our Preferences, if we go to Edit and choose Preferences,
01:23that will be Dreamweaver Preferences on the Mac,
01:25I can go to Code Hints, and I can see which items I can turn Code Hinting on and off for.
01:31Notice that CSS Property Names is on, and I want to leave that on.
01:34I don't want to change that.
01:36But if, for whatever reason, you go in to Dreamweaver and start typing, and you
01:40don't see these lists come up, this is where you would go to make sure that
01:43check box has been selected. All right!
01:44I'm going to go ahead and click OK.
01:45Now, notice my code hinting has gone away.
01:48If I return to go down to the next line, it comes back again.
01:50But if you lose focus on that for whatever reason, if you go to a line, and you
01:54want code hinting to come up, there is a couple of different ways that you can
01:57force that to happen.
01:58Number one, you can right-click, Ctrl+ Click on the Mac, and you can say Code
02:01Hinting tools, and there are couple of things here like the Color Picker, the
02:05URL browser, and the Font List that will bring those particular items up.
02:09But if you want all of the list back like we had a second ago, the way to force
02:12that is to do Ctrl+Spacebar.
02:15Now, that's the same shortcut key on the PC and the Mac: Ctrl+Spacebar.
02:18So it's not Command+Spacebar on the Mac.
02:20It's Ctrl+Spacebar.
02:21So that list comes right back up, and we can just begin typing.
02:24Now, if I type in F, notice that it goes right down the list into the Fs.
02:29I'm also free to scroll through the scroll- bar if I want, or I can just continue to type.
02:32It will start narrowing down the properties that are available to me.
02:36I'm actually going to go down and choose font-family from the list.
02:38So rather than continuing to type, I can just use my arrow keys to go up and
02:41down to the list, and at this place, I want to go to the font-family.
02:43I'm going to hit Return or Enter.
02:46What's going to happen is it not only types out the property for me, but notice
02:49that it adds the colon at the end of the property.
02:51So I get proper syntax out of that as well, and I don't have to remember that colon.
02:56Now, here's another really nice thing that Dreamweaver does for me, and this is
02:59one of the reasons why I really like this Code Hinting tools.
03:02Because I chose font-family, it's not bringing up a list of available font stacks.
03:06Now, these font-stacks are customizable.
03:08You can make your own.
03:09Notice if you scroll down through the list, you can see right down at the
03:12bottom, it says Edit Font List.
03:13So if you don't see a font stack that you want to use, you can just go ahead
03:17and create your own.
03:18So in this case, I could say Arial, Helvetica, sans-serif, hit Return or Enter.
03:22It's going to finish typing all that for me.
03:24So I don't have to worry about remembering the font-stack, spelling all of the
03:27fonts correctly, which I am really bad at, that sort of thing.
03:29I'll type in a semicolon and go down to the next line, and here I'm going to do color.
03:32So I'm going to type in co. Let Color show up.
03:35I always take just a moment to make sure that the property that I want is indeed
03:38the property that's selecting, and then I'm going to hit Enter or Return.
03:41Now, as soon as I do that, notice that it finishes that for me, and it brings up
03:46this menu of properties.
03:48One of those properties is Color.
03:49It's this nice little color palette.
03:51If I double-click that, it's going to bring up the Color Picker.
03:54Notice that it brings me a Swatch panel with all of the Web safe colors on it.
03:57It also brings me a RGB Color Picker, so I could click on that and just mix
04:02together any RGB color that I want.
04:04Again, anytime this stuff goes away, remember I can right-click or
04:07Ctrl+click, go to my Code Hint tools, and say I want the Color Picker back and bring it back.
04:11That's really nice.
04:13But what if one of these colors is not the one you want to use?
04:16Well, that's fine too.
04:17You're free to just go ahead and type in any hexadecimal value that you want.
04:20So I'll type in the hex value here, and then I'm going to type in 51341a, and
04:27then type in a semicolon color.
04:28Now, I'm going to go down to the next line, and I'm going to type font-weight.
04:33As soon as I do that, notice that I get a brand-new list that comes up, and here
04:37I have all of the different settings that I can choose for font-weight.
04:40If I type in n, it goes down to normal.
04:42I can hit Return and have that finish for me.
04:44So not only does it help you with the properties, it helps you with the values
04:47for those properties, as well.
04:48Let's do margin-top. Again, I can scroll through that list if I'd like.
04:53Here I'll do 1.2ems. Then I'm going to do margin-bottom.
04:58Notice that I don't have to type out the whole thing.
05:00I can just go right to margin-b.
05:02It will isolate it, and I hit Return and finish it.
05:05So a lot of times I'll type just to a certain point where I know everything else
05:08is isolated, and then I'll finish that.
05:10We'll do 1em, and we'll finish that up. Cool!
05:13So there is our h2 rule.
05:14We've used almost all of our Code Hinting tools.
05:16There is one more property I want to show you.
05:18So to do that, I'm going to scroll up, and modify our body selector.
05:22So just after the font I'm going to hit Return to create a brand-new line, and
05:25I'm going to type in b, for background.
05:27Now, notice what happens when I hit Return or Enter if I'm isolated on background.
05:31A couple of things come up.
05:33The background property can have colors applied to it.
05:35It can have background images, all sorts of things.
05:38So the first thing I'm going to do is a color.
05:39Now, I could choose the Color Picker like we've just seen, or I can just type in a hex value.
05:43So I'm just going to do that.
05:44So I'm going to type in #e1d8b9, then I'll hit Space.
05:49Now, Dreamweaver again is very intelligent.
05:51It says, okay, I know what you can do next.
05:53You could put a URL or whatever you want.
05:55If I type in u, notice that it goes right to URL, and it allows me to choose
06:00a background image.
06:01Now, what I really like about this is if I hit Return right now, or Enter, or
06:04click on this, it's going to allow me to browse for my background image.
06:08So I'm not going to have to type out the path for it.
06:10I'm not going to have to remember all of that.
06:12So I'm just going to go in the 01_09 folder/Images directory.
06:16I'm going to switch to Details view, so I can see this a little bit better, and
06:20I'm just going to move this up a little bit.
06:21I'm going to scroll down and find my page background right there.
06:26I will click OK, and notice it goes ahead and finishes typing out that for me.
06:30So that URL, all that stuff, I did not have to type that.
06:33I did not have to know the path to that.
06:35I can just let Dreamweaver finish that for me.
06:37Then I'm going to type in repeat-x, so it will repeat along the x axis.
06:41And I'll do a Save All, and I'm going to switch over to Design view now.
06:45Now, I can see that background image showing up behind my page. Cool!
06:50Now, hand-coding can be a little tedious at times.
06:52But if you take advantage of Code Hinting, Code Completion and many of the
06:56shortcuts that we have available to us, it can really dramatically speed up that
07:00code writing process.
07:01Once you're familiar with those techniques and begin to use them like they are
07:04just second nature to you, you're going to find that hand-coding is the quickest
07:07and easiest way to create styles within Dreamweaver.
Collapse this transcript
Modifying styles visually
00:00When working with CSS, you're likely to spend a good deal of time modifying the
00:04styles that you've already written.
00:06In this movie, we are going to explore some of the many techniques available in
00:09Dreamweaver to edit your styles visually using the CSS Styles panel.
00:13Just so I can see a little bit more of my CSS Styles panel, number one, I am
00:17going to make sure I can see it, and I am focused on it.
00:18Then I am going to go to the Files panel, and I am going to double-click the tab
00:21of the Files panel which will collapse it, and that gives me a lot more room for
00:25my CSS Styles panel.
00:27Now, one of the things I notice, right off the bat, is that we are supposed
00:30to have a little bit of separation between our page content and the top of the page.
00:34So I should be seeing a little bit of blue up here, and I am not.
00:36So I am going to go right over to my CSS Styles panel, I am going to find the
00:39body tag, and I am going to go ahead and double-click that.
00:42Now, when I double-click the body tag, notice that the CSS Rule Definition
00:46dialog box comes up.
00:47This is the default, but you can change it through the Preferences so that that
00:51might open up in Code view, or it might focus down on the Properties Inspector.
00:56So I am just going to go to my Box properties here, deselect Same for all for
01:00Margin, and I am just going to give it a Top Margin of 25 pixels.
01:03When I click OK, notice that that is added right here to my list of properties,
01:07and now I see the proper spacing at the top.
01:09So that's a very quick and easy way to make an edit.
01:12The next thing I am going to do is in my CSS Styles panel, I am going to find
01:15the h1 tag, which is right here.
01:17I am going to click on the h1 tag and when I select that, it shows me the
01:21properties for that in this pane below it.
01:23Now, notice that we are in All View right now.
01:25So if you don't see this, make sure you are not in Current View.
01:27You want to be in All View.
01:28Again, you just want to click once on the h1 tag to select that.
01:31Now, this is my favorite way of editing styles,
01:34the way I am about to show you.
01:34This is just so quick and so easy, and it's a lot like hand-coding.
01:38If I select, and highlight h1, I can come right down here to this little link
01:42that says, Add Property.
01:43Now, if I click that, I can go ahead and choose from the pulldown menu any
01:47property I want to add, or if you know what you want to do, you can just type in
01:50something like color, for example.
01:52Then if you hit Tab, you get the Color Picker that you can choose from, or you
01:57can just go ahead and type in a value yourself.
01:59So in this case, I want to do #193742, although that green is pretty nice.
02:07Now, as soon as I type that in and hit Return, it goes ahead and changes it.
02:09So you can see the Adding Properties to existing rules is amazingly simple using this.
02:13You just click Add Property, type in what you want to do.
02:16It goes in, adds it to your code, and you are good to go.
02:19Now, I am going to click right here inside the body copy.
02:21So I am inside our paragraph here.
02:24Instead of looking at the All view, I am going to switch it over to the Current view.
02:27Now, when I do that, I get three sections for my Styles panel.
02:32One is a Summary, and it's giving me all of the properties that are applying to
02:35this particular element, in this case the paragraph.
02:38Then I get all the Rules that are applying, and these rules are applying
02:41within the cascade.
02:42There are two views here.
02:43There is the cascade of rules, and then there is information about a selected property.
02:47So here, if I selected a property, it would tell me where that property could be found.
02:50But if I hit Cascade, it just shows me all of the different rules that are
02:54applying to this one, the bottom rule being the closest one to it.
02:57Now, if I look in the Cascade section here and scroll down and choose this P
03:01selector, now the properties for the Paragraph Selector are coming up.
03:05Notice that every time I click on one of these, I get a different set of properties.
03:08So that allows you to highlight an element and then sort of go up or down the
03:12cascade as you need to to find the property that you want to modify or change.
03:15I am going to select the Paragraph Selector, and I'll add another property right
03:19down here using the same method that we just did a minute ago.
03:21I am going to do line-height.
03:23So again, you can just type that in if you like typing it in, or if you can't
03:27type like me, you want to grab the pulldown menu.
03:28I'll hit tab to move over, and I am just going to do 1.8.
03:31I am not going to set it again to measurement. I will let it default
03:33to Multiple, and now we have a line height that is what we wanted for
03:38that particular element.
03:39There are also some things that you can do with the CSS Styles panel that you
03:42pretty much can't do any other way except for hand-coding.
03:45I am going to switch back to All, for example, and I am going to click right
03:48up here in this headline Tours, because it does not look the way it's supposed to look.
03:51It's supposed to have a border underneath it. It's supposed to be a little bit smaller.
03:54Well, if I look at this, I can see using the Tag Selector that this is an h1
03:58with an ID of pageID, in lowercase p, uppercase ID.
04:03If I look over at my styles, and I scroll down little bit, I can see that within
04:07my Styles, and you know I have to scroll a little bit to get down here, there it is,
04:11that's what I am looking for,
04:12you'll notice that right here we have a selector that says
04:14#mainContent h1#pageid.
04:18But notice that the id is lowercase, but the actual ID itself is uppercase.
04:22So the selector is wrong.
04:24Instead of just being able to edit properties, one of the things that the CSS
04:27Styles panel allows us to do is edit the rules themselves.
04:29So if I click on that rule once to select it and then click one more time,
04:33notice that it highlights the rule, and I can change the selector right here
04:36without having to go into the code.
04:38That is a really powerful feature so I am going to change that to ID, hit
04:41Return, and now notice the styling is correct.
04:44So if you write a selector, and it's not giving you the correct styling, you
04:47can check it, make sure it's the selector that you need and if you need to
04:50rename it, you can go ahead and rename it right here without having to go back in your code.
04:54That's pretty cool.
04:55So I think even if you're like me, and you rely on hand coding for the creation
04:58of most of your styles, Dreamweaver has some truly impressive methods for making
05:02quick edits to your CSS without having to go back into the code.
05:05Keep in mind you can also edit your styles through the Properties Inspector, as well.
05:09By giving you so many different ways to work with your CSS, Dreamweaver allows
05:12you to find the methods that suit your own personal preferences.
05:16My advice is to become comfortable with all the editing methods so that you can
05:19use the one that best suits the current situation and your personal preferences.
Collapse this transcript
Using the Code Navigator
00:00Although we've explored editing styles through the CSS Styles panel and the
00:04Properties Inspector, we haven't talked about the Code Navigator yet.
00:07The Code Navigator is an invaluable tool that gives you an easy way to access
00:11and modify your styles from anywhere in your document, even if you're not 100%
00:16sure which rule contains the styling that you need to change.
00:19So let's take a closer look at using the Code Navigator.
00:22I am going to scroll down a little bit, and looking at my tour descriptions down here,
00:26this formatting is not exactly the way that I want it.
00:29I want the text wrapping this image.
00:31I mean, I like a little bit better spacing here for our rating text.
00:34So the first thing I am going to do is just click on this Big Sur image.
00:37I want to click on that.
00:38If I pause for a couple of seconds or so, this icon shows up, and it looks like
00:42a little steering wheel, or paddle wheel.
00:44That is the Code Navigator.
00:46If I hover over that and click it, it will bring up the Code Navigator itself.
00:50Now, that's one of the main reasons that a lot of people don't like the Code Navigator.
00:54Every time they click somewhere, a couple of seconds later up comes this little
00:57icon, and it can get to be a bit annoying.
01:00So if you click on that icon to bring up the Code Navigator, one of the things
01:03that you can do is disable it.
01:04So by clicking that check box, you are turning that off, and you're not going to
01:08be bothered by that icon every single time that you click somewhere.
01:11You'll see that now when I click somewhere and just sort of hang out for a second.
01:13It doesn't come back up.
01:15So now that you have sort of gotten rid of the annoying factor of the Code
01:18Navigator, what happens if you need it?
01:19How you get it to come back up again?
01:21Go ahead and select your image.
01:23On the PC, you want to hold down the Alt key;
01:25on the Mac, you are going to hold down the Command+Option key, and then with
01:28those keys being held down, just simply click on the element that you want to
01:31bring up the Code Navigator for.
01:33So all I have to do is click, up comes the Code Navigator, and there we go.
01:36So what is the Code Navigator actually showing us?
01:38Well, it's showing us the cascade of rules, showing us all of the rules that are
01:43applying formatting to this element or this particular item, in this case the
01:46image that we just clicked on.
01:48You can see that the selector on the bottom is the one closest to the rule.
01:52Then the selectors above it are sort of receding in the order of importance
01:55through the cascade.
01:56So by hovering over these, we get to see the actual properties being set and
02:00their values, which is really cool.
02:02It's a nice way to sort of get a summary as to what's happening here.
02:04So we can see that right now, this #mainContent .tourDescription img rule really
02:08is just applying some padding.
02:10So if I want to change that, all I have to do is click that particular rule, and
02:14it's going to focus on that.
02:15It's going to focus on it in two places;
02:17one is within the code.
02:18You'll notice that it switches right to a split screen view, goes right to the
02:21CSS file, and jumps right down to the rule that I need.
02:24That is amazingly efficient. Rather than having to switch over to the code
02:28myself and scroll through all the rules and try to figure out which one's
02:31applying the formatting,
02:32I can do a single click, use the Code Navigator and go right to that rule.
02:36So that's really nice.
02:36So what I am going to do here is I am going to go to the last property which
02:40is padding, hit Return, or Enter, and I am going to type in Float, and I am
02:44going to float that to the left, once again, using code hinting to help me
02:47finish my coding here. So float:left;.
02:50I am going to do a Save All, and if I switch back to Design View, I can see now
02:55the text is wrapping that. Perfect!
02:57Now, I mentioned that it was going to focus on that selector in two places.
03:01We just saw how it focused on it in the Code view, but it also focuses on it in
03:05the CSS Styles panel as well.
03:07Let me show you that.
03:08So I am going to go over to CSS Styles panel, double-click that tab to sort of
03:11expand that, and I might double- click the Files tab to collapse it.
03:15So I just want to focus on the CSS Styles panel.
03:17So you can see this text right here: Optional 4 day tour available Rating: Medium.
03:20That's sort of still in this paragraph, and I'd like it to be on its own line
03:24and have proper spacing here.
03:25So what I am going to do is, once again, click inside that, and remember, if I am
03:29on the PC, I am going to hold my Alt key down;
03:30if I am on the Mac, I am going to hold Command+Option.
03:33I'll click to bring up the Code Navigator and again, notice here I am getting an
03:36entirely different list of rules based on the element that I have selected.
03:39So the #mainContent .tourDescription span.option is the selector that I want to choose.
03:45Now, I could go above this.
03:46If I wanted to affect all paragraphs, I could click here.
03:49So I want to affect just the selected text, so I am going to click right there.
03:52Now, it still goes into Code view, but notice that also in the CSS Styles panel,
03:56it scrolls down, finds that particular selector and highlights it.
04:00So now, I am able to go ahead and set properties here, as well.
04:03So I am going to go ahead and add another property here, and I am going to add
04:05the Display property.
04:06I will hit Tab, and I'll do a display of block.
04:09As soon as I hit Return, I can once again go back to Design view.
04:12Now, we can see that it is indeed on its own line.
04:15It's displaying as a block-level element, and that is exactly what we want it to do.
04:19So if you're working with really complex code, and especially if you have
04:22elements that are being formatted through various rules, the Code Navigator can
04:26help you really cut through that clutter, showing you exactly which rule you
04:29need to edit and making finding that rule in your Styles, or your CSS Styles
04:33panel as simple as just a single click.
04:36Now, if you've never used the Code Navigator, or if you've just been annoyed by
04:39the icon that keeps coming up, my advice is to take control over this really
04:44powerful feature and go ahead and add it to your workflow.
Collapse this transcript
Using CSS Inspect
00:00If you've ever used Firebug or WebKit's Web Inspector, you're probably used to
00:05visually inspecting your page to check your layout.
00:07In Dreamweaver, you can use CSS Inspect to examine the Margin, Padding and other
00:13Box model Properties of elements on your page.
00:15CSS Inspect is part of Dreamweaver's WebKit Integration, and as we'll see, it
00:20gives you the ability to accurately preview and troubleshoot your designs
00:23from within Dreamweaver.
00:24And one of the things I want to do is fix some spacing issues that I've got, so
00:28I'm going to turn Live View on.
00:29Now Live View shows us the page as it's rendered in the WebKit space, not Design
00:35View, and gives us a more accurate preview.
00:37So I'm going to scroll down a little bit, and in my Tour Descriptions, I can see
00:40that I have some spacing issues here that I want to fix.
00:42Number one, I have had too much above these headlines, and I really would
00:46like the spacing to be a little but more equal between this area and the
00:49headlines themselves.
00:50Also this Rating area, I would like that to float a little bit more in the
00:54middle and not be as close to the top paragraph as it currently is.
00:59Okay, so those are some spacing options I want to change.
01:02So I'm going to use CSS Inspect to show me which elements I need to modify to
01:06get the proper spacing.
01:07So to turn Inspect on, I just go right up here beside Live View and turn Inspect mode on.
01:11And as soon as I do that, Dreamweaver says, hey Inspect mode is most useful
01:15with certain workspace setting.
01:16I'm like, oh really. Tell me more.
01:18So I click on More Info, and it tells me that, hey your CSS Styles panel should
01:22be open in Current mode. Mine's currently in all, so that's not right.
01:25And you should be viewing your screen is Split Code View so that you have Code
01:28View on one side, Live View on the other, and you can also enable Live Code.
01:31What Live Code will do for you is show you, if you're interacting with any JavaScript
01:35base elements, for example, it will show you the code that gets generated.
01:37And now I can automatically switch these settings if I like, or I can
01:40choose them myself.
01:41I'm just going to have Dreamweaver do it for me.
01:43So I am like, yeah sure, go ahead and Switch to that. That's fine.
01:44Now I like turning Live Code off because unless I am working with some type of an AJAX Widget,
01:50I don't really need that on.
01:52It is helpful to have my CSS Styles panel Open to current and have at Code View open.
01:56It's going to help me out.
01:56But I'm going to change over to my main.css, so that I can change my code really easily.
02:01Now I'm also going to double-click on the Files panel tab to collapse that, so
02:04that I can see my CSS Styles Properties.
02:07Okay, one last thing to do.
02:09I'm going to bring this a little bit over so that I have a little bit more room
02:13in looking at my elements on the page.
02:15Now you might have noticed if I start hovering over elements, I get to see some
02:20highlight colors, so what's going on there?
02:21Well essentially, I'm looking at the Box model properties for those elements.
02:24The sort of a translucent blue color that we're seeing, that's the width and the
02:28height of the element.
02:29Any yellow is a margin, and any time you see that sort of magenta color, those are padding.
02:33So you can see padding, margins, your content regions.
02:37You can really kind of see what's going on there.
02:38You'll also notice that that right down here, on the Tag Selector, as we hover
02:42over an element, we get to see which element we're selecting.
02:45If we were in Code View, it would be highlighting code as well, and over here
02:47in the CSS Styles panel as I move through this, you'll notice that the CSS
02:52Styles panel in the current section is showing me the selector that I'm
02:55working on as well.
02:56Okay, well let's start using this to tackle the spacing issues that we're having.
02:59One of the things that I'm most interested in finding out is how much space I
03:03need above my headings and then going ahead and setting that.
03:06Well if I hover over the Div Tour Description right here,
03:09I can see looking over at my CSS Styles panel that the margin on the bottom is
03:1315 pixels and my padding 10 pixels.
03:17So I've got 10 pixels worth of padding on the top and the bottom, but I have 15
03:20pixels worth of margin between them, as well.
03:22So if I hover over at my heading here, I get to see a really large margin above that.
03:25But if I look over at my properties, I don't see any margin top so what's the deal there?
03:29Well, just because it's showing you that property, doesn't mean that it's being set
03:33with that particular selector.
03:33Let me show you what I mean.
03:35If I click on the heading, Big Sur Retreat, it actually turns Inspect mode off.
03:39It sort of freezes it in that location.
03:41So if I go up through my list, h1, h2, h3, I don't see any top margin.
03:44At h2, however, I see a margin top of 1.2 ems.
03:49Okay, well that's setting now for every single heading in my site.
03:53This particular one needs to be a little different, so I'm actually going to
03:55use this bottom selector, which is # mainContent, and I've got another divider
04:00here that I can change.
04:01You know, you really start to run out of screen real estate pretty fast, so let
04:04me explain that a little bit so I can see this selector a little bit better.
04:08So #mainContent.tourDiscription h2, cool.
04:11So if I change the top margin on that one, that should adjust the spacing, so
04:15I'm going to say, Add Property > margin-top and since we know that our
04:19tourDiscription div tag has that 15 pixels worth of margin on the bottom, and
04:23we want to equal that,
04:24we're just going to say 15 pixels worth for margin-top.
04:27As soon as I do that, notice that we get lot more equal spacing between these
04:31elements on the page.
04:32Now anytime you select a specific element to work on it, Inspect mode is just
04:36sort of going to turn itself off. Notice that I can turn it right back on and
04:40start inspecting again.
04:41Now you don't really need to be in the Split Screen View if you're not going to
04:44be doing hand coding.
04:45So if you're going to continually work with CSS Styles panel, you can just
04:48switch back to Design View and kind of see everything without having to worry about that.
04:51Dreamweaver keeps giving you this little message that says, are you sure about
04:54that? But you can just ignore that if you like.
04:56Okay now, what we need to do next is focus on the spacing of this span text
05:01right here, Span.option.
05:03Now its set to display as a block-level element, but we're not getting spacing above it.
05:07We'd really like to add an equal amount of spacing above and below it.
05:10Now in order to do that, we have got to navigate some pretty complicated waters.
05:14This text is filed in this Span tag with a class or option applied to it, but
05:17it's inside of a parent paragraph.
05:19It's being told to display as a block-level element.
05:22Below the parent paragraph, we have another paragraph that contains these two items.
05:26These are links, one with A with a class of book, another link with a class of more.
05:32Now as we hover over those elements, we can see that some of those elements have
05:35margins applied to them, and some of them don't.
05:37Notice that the book has a top margin applied to it.
05:40More has a top margin applied to it.
05:42The parent paragraph has a bottom margin applied to it.
05:45But our span text doesn't have a margin applied to it.
05:48Okay, well there's a little bit of a mystery here, too.
05:50Notice that what CSS Inspect can show me.
05:52If I hover over of the parent paragraph, take a look at where the bottom of that
05:56margin ends, that yellow border that you're seeing there.
05:59The very bottom of that is the bottom of that margin.
06:01Okay, kind of stare at that space for a moment.
06:03Now if I hover over this link, notice that its top margin goes up to that spot and ends.
06:08So those two margins, the top margin and the bottom margin of this paragraph are
06:12touching each other.
06:13Well that's kind of weird, because in CSS vertical margins are supposed to collapse.
06:19So if you think about it, if those two elements are touching each other,
06:23they really should be collapsing down into one singular margin, but they're
06:26not, and why is that?
06:28Well let's use CSS Inspect to find out.
06:30Notice that if I hover over one of these links, book now!,
06:33I actually have another way of going through elements on the page.
06:36Certain elements, due to say collapsing elements or things like that, you may not
06:40be able to hover over them.
06:41But if I hit the left arrow key on my keyboard, notice that it goes right
06:45through the Tag Selector, in the Tag Selector right down here, this area, and
06:49watch right down here while I do this.
06:51Notice it just goes back up to the paragraph that's inside of that, then to the
06:54div tourDescriptions. I can just keep going up.
06:57The right arrow will move me back down.
06:58So you can actually click to the left and to the right on your arrows to sort of
07:01browse through those areas.
07:03So you can look at some pretty detailed structure that way.
07:05Now what we've learned is that the parent paragraph, it's holding those two
07:08links, has collapsed because they're floated outside of it, but the top margin is
07:13still being applied.
07:14So what's happening is the bottom two's top margin is collapsing with
07:17that one, but because of that parent paragraph, the paragraph just above that one
07:22isn't collapsing with those guys, so essentially that paragraph that they're
07:25inside of it is acting as a buffer so that we don't get margin collapse there.
07:28So we need to make a few changes to make sure that all works.
07:31Number one, we know now that we really don't need the top margin only, so I'm
07:34going to get rid of them.
07:35So with CSS Inspect turned on , I'm going to click on the book now!
07:38link, and I can see that just above that here's, this #mainContent a.book.
07:42I'm going to click on that, and I'm going to get rid of that top-margin.
07:45So I'm going to click on the margin section right here. Type in zero. Here we go.
07:50And now I'm going to do the same thing to learn more.
07:52I'll click on that.
07:54Click on its particular selector, which is just above it.
07:56If you're wondering what the bottom selector is,
07:58that's the hover selector, so that's the roll-over.
08:00So let's click on #mainContent. tourDescription a.more, and I'll change that one,
08:04as well, to 0 pixels.
08:06So now we're not getting that extra margin.
08:08We're getting the collapse occurring.
08:10I can turn Inspect back on, and you can see that as we hover over those we
08:13don't get that margin, and the parent paragraph still has that margin, but it's collapsing now.
08:18So now those guys are looking the way that I want them to.
08:21I still would like to push my Optional 4 day tour available down a little bit so
08:25that sort hovers in between those.
08:27And if I look at its parent paragraph, I can see this particular margin on the bottom is 1em.
08:32So I've got 1em's worth of margin on the bottom.
08:34So I'm just going to split the difference there, turn Inspect back on, find
08:38the Span tag and click, and then on its selector I'm just going to add a property there.
08:43I'm going to add margin-top, and we'll do .5em, so we'll do half of that, and there we go.
08:49That's going to push it down by about half of its available margin, and now the
08:53spacing is nice and equal.
08:56That was exactly what we wanted.
08:57And again, you can turn Inspect on and off any time you want. Anytime you focus
09:01on an element, Inspect is going to turn itself off.
09:03So you just have to remember to turn it back on.
09:05So it's going to take you a little practice getting used to using it.
09:08Make sure, for example, that if you're over an element, and you're not looking
09:11at exactly what you think you should be looking at, use your arrows to either go
09:15to the left to go up through the source code, or you can use your right arrow to
09:19go down through the source code.
09:20Now it might take a little practice to get used to it, but the CSS Inspect gives
09:24you an incredibly powerful way to preview and refine your design.
09:27Keep in mind that CSS Inspect uses WebKit, so you'll still need to test it in other browsers.
09:33So the spacing you're getting here is the WebKit rendering with CSS Inspect
09:36might not be exactly what you see in other browsers.
09:38So you definitely want to just keep testing it.
09:40However, it is a great way to visualize how elements are affecting each other
09:44and for tracking down the correct rule to edit, if you need to make changes to
09:47especially where spacing and different box model properties are involved.
Collapse this transcript
2. Organizing Style Sheets
Structuring style sheets
00:00In this chapter, we will talk about best practices for structuring your styles
00:04and how Dreamweaver can assist you in making sure your styles are organized
00:08properly and are well-commented.
00:10Having a strategy for structuring the styles in your site is crucial to ensuring
00:14that your styles work properly, and are easy to maintain and update.
00:17In this movie, we're going to examine the Explore California style sheet and
00:21discuss the theory behind its organizational structure.
00:24So I have the main.css file open.
00:27This is our finished style sheet, all organized and structured, and I just
00:31wanted to take a moment before we start working on the style sheet and
00:34structuring it to explain this strategy behind the structure that we've got here.
00:37At the very top of the style sheet, we have a header,
00:40where basically we explain what this style sheet is.
00:42We explain the copyright data, if you want to put that in there, that sort of thing.
00:46If you're working in a team environment, you know, within this header, you might
00:48put a version number, when it was last modified, things like that.
00:52Now the thing I like doing in all my style sheets, just below that,
00:54we have a Color Guide.
00:55This Color Guide is telling myself and other people what colors are used and
01:00what those colors are typically used for.
01:02So now when I want to write that, if I forget exactly the hexadecimal value
01:06for that, I can come up and copy and paste it, and I can also say, okay I'm
01:10doing a heading. What colors should I use? And I can read through this to help me with that.
01:13Just below, that we have a table of contents and in the table of contents, it
01:17gives me an overview of how my styles have been structured.
01:20I have some constants which are global to the entire site.
01:23I have a CSS Reset, which sort of is in the middle of those.
01:26I have Global Classes that work throughout the entire site.
01:30And then from there, I have some styles that are specific to the Index Page or Home page.
01:34I have a Top Level Layout Styles which are sort of Global Layout Styles, and
01:38then I get into the individual regions themselves: Headers, Navigation, Main
01:42Content. all the way through.
01:44Now, that's the way that I like to organize a style sheet. That doesn't mean that
01:47it's the way that you're going to organize it.
01:49I know a lot of people that will organize the layout in one section, typography
01:52in another, color in another.
01:54It's really what works for you.
01:55The thing is you want to be consistent with it, and you want to make sure you're
01:58following that structure so that if you write new navigation selectors, for
02:02example, they go in the proper section.
02:04Now you'll notice I've done something here to the table of contents.
02:07I have sort of these special characters, sort of the ^4, ^5.
02:10Well, that actually helps me jump to that section.
02:13You'll notice that I've even added a little comment here that says, hey if you
02:17want to jump to that section, you can highlight it, hit a specific keyboard
02:19combination or do a Find/Replace, and you'll jump right down to that section.
02:23Now if we scroll down into the styles themselves, we can see that I have a nice
02:27little comment here, identifying the section.
02:29There is that ^ again that will allow me to jump down to that, and then the
02:32selectors themselves are written in a very human, readable way.
02:36Each selector is on its separate line, even when they are grouped together.
02:39Each property is on a separate line, and then I have a space between each selector.
02:43So very open. Very readable. Its not necessarily the most efficient way to deploy
02:48this particular style sheet, and we'll talk about that in the last chapter in
02:51our movie about maybe optimizing this code a little bit more.
02:54Now I want you to notice something about these properties, too.
02:56Notice that every time I go to a selector, the properties are in
02:59alphabetical order.
03:00So color, font-size, margin-top, every time we go to one they are in
03:04nice alphabetical order.
03:05The reason behind that is if you go some place and you know, I need to adjust
03:09wrapper, for example, and I want to adjust the width,
03:12I don't have to worry about where to find it.
03:13Its really easy to find because it starts with the W, so it's the very last property.
03:18Now that could be a little overkill for lot of people, and you might not want to
03:22go to that little bit in detail, but you can add that amount of organization to
03:26your style sheets if you want to.
03:27It's not hurting anything, and it might help you find and replace values a
03:31little bit quicker if you're going to be doing a lot of hand-coding.
03:34Notice that the selectors themselves are grouped by content.
03:38So, for example, if I go down to the mainContent section, and we're still on
03:41our layout right now.
03:42Let's go into our actual selectors.
03:45So here's the Headers section, notice they're all grouped together.
03:48All those selectors inside the header and the same thing with our navigation;
03:52they're all grouped together. And I get more and more specific as I go through.
03:55When I get to the top of the section, let me find mainContent area,
03:59I have some pretty global styles, but as I get deeper into it,
04:02it gets more and more specific and I go from one element to the next.
04:06So if I'm working on images, I'll work on images for a while.
04:10If I'm working on headings, I'll work on headings for a while, that sort of thing.
04:12And so as I need to get more specific with selectors, I do that as I go
04:16through this section.
04:17So that's a quick overview of the structure and organization of the style sheet
04:22for the Explore California Web site.
04:23Now every project is unique, and as a designer, you're sure to have your own
04:27personal preferences for how you want to organize your site CSS.
04:30I'm not saying your style sheet has to be organized like this one.
04:33The most important things is to have a strategy for your organization that's
04:36going to serve your site over its entire lifespan.
04:38You want to be sure to plan for how the site might grow, or change and evolve
04:42over time and whether or not a team will be involved in the site's development.
04:45That's really important.
04:46All these factors play a huge role in how your styles can be organized and how
04:50they're going to be structured.
Collapse this transcript
Writing a style header
00:00Style sheets can be incredibly complex documents, featuring thousands of lines of code.
00:05One of the first things you can do to your style sheets to assist you in giving
00:09it structure and organization is to write a good style header.
00:12Style headers can be as robust as you need them to be, and usually contain
00:16information such as copyright data, style reference information and version
00:20numbers for team members.
00:22We're going to start the organization of the Explore California styles by
00:25writing our own style header.
00:27So I'm just going to go ahead and create a brand-new CSS document.
00:30Now, I've defined the 02_02 as my root directory,
00:35but I'm just going to go ahead and create a CSS file from scratch.
00:38And I'll use the starter screen to do.
00:39So create new CSS file. There we go.
00:42I'm just going to save this in the 02_02_css folder, and I'm going to save it as main.css.
00:50Here we go. So the first thing I'm going to do is just up here I'm just going to write:
00:53style sheet for Explore California.
00:57Now on the next line, I'm going to type in version 1.2, modified on 04/05/10.
01:10Now that level of organization you don't need, but if you're working in a team
01:12environment, that's really handy, because if a team member comes in and makes a
01:16change to the site, they can change that one line and everybody knows, okay,
01:20this has been modified last week or this hasn't been modified in the month,
01:22that sort of thing.
01:23I'm going to go down and on the next line,
01:26I'm just going to type in copyright 2010 lynda.com for personal
01:33educational use only.
01:35So if you want to put some restrictions on how your style should be used if
01:39people want to repurpose them, that's a good place to put it, as well.
01:41Now this needs to be inside of a comment.
01:43This would really mess my CSS up if I didn't have it that way.
01:46So let me go ahead and highlight all of this text and when the text is
01:49highlighted, I'm just going to come right here to my Code toolbar, click on
01:52the Apply Comment, and I'm going to apply the second comment here, which is the /**/Comment.
01:57That is a multiline comment in CSS, and I want to choose that.
02:00Now you can see that it's grayed, and you can put those comment indicators on either side.
02:03You can leave them inline.
02:04It's really up to your personal preferences.
02:06You can put them wherever you would like.
02:07And I'm going to go ahead and save that file again, and there we go.
02:11There is our style header.
02:11Now these things can be as robust as you need them to be.
02:14Remember, they're entirely optional.
02:16You don't even really have to have them.
02:17They are a great way to communicate with yourself. If you're like
02:21me and you forget why you are doing a certain thing, they are a great way to
02:23sort of add a little note to yourself, as well as any team members, what's going
02:27on with your styles.
02:28And they are also a great way to pass on information to people who might be
02:31visiting your site, opening your styles to take a look at them.
02:34If you do plan on using them, keep in mind that they should convey information
02:37inside of them very clearly and very concisely.
Collapse this transcript
Building a color guide
00:00The style header can be useful for many things, not the least of which is to
00:05explain your site's color and typographic strategy.
00:08In this movie, we'll explore adding a style color guide to our header, and
00:12discuss how this can be extremely useful when creating your styles.
00:16So, I have the main.css.
00:19As you can see, currently, it just has our sort of generic style header that we
00:23created in the previous movie.
00:24Well, right down below that, I'm going to add our color guide.
00:28So, I want to put my cursor on the line just below the existing header.
00:32I'm just going to type a few hyphens intact as a separator, and then type in
00:37color guide, and then finish out those hyphens, just so it's really easy to
00:42break that up in a section. And this is a structure that we're going to follow
00:46really for the rest of our CSS file. Okay!
00:48On the line below that, I'm going to type in my first color.
00:51I'm going type in #193742, and then just after that, I'm going type in a space
01:00and a colon, just to act as another separator.
01:03Then after that, I'm going to type in dark blue.
01:07Right after dark blue, I'm going to type in a pipe character, and you could find
01:10that just to the right of your bracket keys.
01:13Then I'm going to type in a little bit of a description here, a little brief description.
01:15I'm going to type in use for main headers and most paragraph level headings. Okay!
01:26Now, let's take a moment to review the structure that we're setting up for
01:30our color guide here.
01:31So, we start, obviously, with a hexadecimal notation, and after that, we have
01:36sort of a name for the color.
01:37Here, it's dark blue.
01:38Really, it could be anything that you want it to be, anything that's going to
01:41sort of identify who this color is: dark blue, light blue, steel.
01:45After that, we have a brief description of the color itself.
01:50That again, is to sort of trigger your own memory as to when you're going to
01:53be using this color.
01:54Now, you are free to really structure this anyway that you want.
01:57When you're working in a team environment, it's a really good idea to put sort
02:00of a description about this color, when it should be used and any sort of rules
02:05you have around governing usage of that color.
02:08If you're just making yourself a color guide, so that you could go back and
02:11remind yourself what a hexadecimal value is for a specific color,
02:15you probably don't need this.
02:16Anytime that you're working in a team environment, or if you just want to remind
02:20yourself of the rules in your site, this is a really good practice to do.
02:24Now, above and beyond just giving us something to remember, the really cool
02:28thing about this is that if I'm creating a rule, I can come in, simply
02:32highlight the hexadecimal value, copy it, and then paste it into the rule
02:36further down the page.
02:37So, it becomes sort of a way of me almost having my own little set of swatches
02:41right here when I'm going to be hand-coding. All right!
02:43I'm going to go down the next line, and we just have a few more colors that we
02:47want to go ahead and throw in here.
02:49Keep in mind we're going to follow this structure every single time, so
02:52that we're consistent.
02:53So, down below that is #e1d8b9.
03:00So we type in a colon, and after that we're going to type in sand accent, and
03:06then another pipe character, and we're going to say use for most area background colors.
03:14On the line after that, we're going to type in #cb7d20, again, a space and a colon.
03:23Limit the space there, so that if you're highlighting this text to copy and
03:27paste it, you don't have to worry about selecting a colon, also by mistake,
03:30which would be a problem in most rules.
03:32Then we're going to do orange accent. Again, we're going to do another separator
03:38here, which is reusing our pipe, use for links & rollovers.
03:44Right after that, we're going to type in #51341a.
03:52We'll type in our colon.
03:53After that, we're going to type in brown, a little pipe character there, and then
03:57we're going to say use for secondary headers.
04:01Then after that, we're going to type in #952.
04:04So, again, here, we're using a little bit of shorthand notation - more on that in just a moment.
04:09We're going to type in a colon there and say dark orange.
04:13Then we're going to type in use for links or high contrast accents.
04:21Create another line, and two more colors to go.
04:23So, #3c6b92. That's going to be a main blue, and again, type in your pipe
04:33separator, use for page background, footer background.
04:41Then finally, our last color, #333, our colon separator and neutral gray, and
04:47then finally, use for body copy. All right!
04:53Now, I need to go ahead and make sure that this is commented out.
04:56So, what I'm going to do is highlight all of the text that we just typed in,
04:59go to my Coding toolbar here and choose to apply the CSS multiline comment, right there.
05:05When I click off of it,
05:06I can see that it's gray, so that lets me know that, indeed, it is now commented out.
05:11Browsers will ignore this code when we render it. Okay!
05:13So, did we use all the colors on our site?
05:15Well, yeah, for the most part, we did.
05:17But how many colors you put in your color guide,
05:20How they're structured and what order they come into is entirely up to you.
05:24You just want to make sure that you're passing along information clearly to
05:28yourself for a later date, and any team members, and perhaps freelancers in the
05:32future that might be working on this site, as well.
05:35So, a color guide is going to be extremely useful for us.
05:37It's going to allow us to quickly, say, copy and paste hex values when we create new styles.
05:42It's serving as a basic color usage guide for other team members, and
05:46that's very important.
05:47Now, as with any information you add to your styles, you are free to add as much
05:51or as little information as you want.
05:54Think about ways you can use creatively use a color guide within your style sheets.
05:58I think you'll find it speeds up the creation of your styles, and serves as a
06:01handy reference within your code.
Collapse this transcript
Writing a style sheet table of contents
00:01For smaller style sheets, finding the style you need, or the section you need,
00:04isn't that much of a problem.
00:06As your sites get larger, and your style sheets grow, finding your way around
00:10begins to become a bit of a problem.
00:12Creating a Table of Contents for your style sheets gives you a quick and easy
00:16way to review your sheet's structure, and allows others to quickly locate
00:20sections they need to work on. What's more,
00:23as we'll see, they can be used to give yourself quick access to specific regions.
00:28So, here I have the main.css from the 02_04 _css folder opened.
00:35What I'm going to do is just scroll down below the color guide that we've created.
00:40I'm just going to hit Enter to go down to create a brand-new line.
00:43Now, I'm going to keep that separator structure consistent,
00:45so I'm just going to type in a few hyphens here, and type in a space.
00:49Then I'm going to type in Style sheet TOC to let people know what we've got here.
00:55Again, I'm just going to finish that with a few other hyphens.
00:58Now, I'm going to go down the next line, and I'm going to type in Global
01:02constants, because that is the first item, Global constants, in our style sheet.
01:08Now, I'm going to hit Enter to go down the next line, and then type in CSS
01:11reset, because that comes next.
01:13Now, if you remember from earlier, when we looked at our finished style sheet
01:17guide, we saw the sections that we were creating our styles in.
01:21So, what you're really doing here is just sort of listing the style sections in
01:25the order that they come.
01:27Some people prefer to do this at the very beginning of their style sheets.
01:30If you're that organized, and you know exactly how you're going to write your
01:33styles, exactly where each of your sections are going to go, and you have
01:36that really well planned out, then you can go ahead and create your TOC at the beginning.
01:40Now, if you're like me, you might want to do it at the end.
01:43I usually do mine at the end, because, invariably, I'll have something come up,
01:47and I'll say, okay, well, I guess, these little groupings of styles should
01:50really be in their own section.
01:51And I might change my mind.
01:52So, rather than having to redo the TOC, just because I reorganized my style
01:56sheet, I prefer to wait until the very, very end and go ahead and put it in at that point.
02:00That saves me a little bit of work that I would normally require to update that.
02:05Now, let me give myself a little bit room.
02:07We'll go down the next line.
02:08I'm going to type in Global classes; on the next line, Home page layout.
02:14On line below that, we're going to do Top-level layout. On a line below that,
02:22Region detail styles. All right!
02:25Now, here, after Region detail styles, we're going to have a few subsections of Region detail.
02:30So, each of the regions, like header and footer and sidebar, they're going to
02:33have their own styles sectioned off as well.
02:36So, we're going to indicate that through the use of indentation.
02:39So, what I'm going to do is go down the next line, and I'm going to hit
02:41Tab about three times.
02:42I'd like to have a really nice indent here to let me know that these are subsections.
02:47We'll start with Header. On the next line, Navigation, as those styles, of
02:51course, come next, and then Main Content.
02:54On the next line from there, I'm going to hit Tab twice, because Main Content
02:58has its own subsections.
03:00Here, I'm going to do Data tables, Spotlight region, and then Forms.
03:07Now, next I'm going to sort of go back to those Region subsections.
03:11So, I need to outdent my CSS. How do I do that?
03:15Well, if you look in your Coding toolbar, right here on the left-hand side -- I
03:20don't have enough room to display all these icons, so I'm going to click on this
03:23Show More button here.
03:24If you have a higher screen resolution than me, you probably see all these already.
03:28I'm going to go right here to the, either Indent or Outdent Code.
03:32I'm going to choose Outdent.
03:33That's going to take me right back out to the next tab stop.
03:37So, here, I'm going to type in Sidebar, and then finally Footer. There we go.
03:42I'm going to highlight all of this code, and go ahead and wrap that in a CSS
03:47comment, a multiline comment.
03:49Again, you can do that by using this icon right there.
03:52Now, of course, you could type in those yourself.
03:54They are just /**/.
03:58But the beauty of this is that you can just sort of type away and highlight all
04:02of it when you're done and apply a comment to it.
04:05So, it's really, really simple and easy to do.
04:07You just want to make sure that everything changes color, that you don't leave
04:10anything off at very end of that.
04:12Now, we could be finished with our TOC, but as I mentioned earlier, you can also
04:15use the TOC as a means of sort of finding those styles very quickly.
04:19That's especially helpful if you have hundreds of lines of CSS, or even
04:22thousands of lines of CSS.
04:24So, just above the Style sheet TOC area, I'm going to type in another comment.
04:28I'm going to type in some instructions on how to use this.
04:31I'm going to type in: to jump to a specific section, search for the unique
04:40character pair at the front of each TOC section.
04:49I'm even going to pass in a little tip on how to this in Dreamweaver:
04:53highlight the special character and use the shortcut for Find Selection, which
05:03is Command+Shift+G (Mac).
05:09Then I'm just going to do a little / there and then do Shift+F3 (PC), just so
05:17people know different keyboard shortcuts they can use.
05:20Again, how much information you give when you're are doing this type of a
05:23comment is totally up to you.
05:24But that will be pretty easy for anyone visiting our site, or working on a site,
05:29to know how to jump down to a specific section.
05:31Once again, I'm going to apply the comment here.
05:32Okay, now what does this all mean?
05:33What do I mean by special characters?
05:35So, what we're going to do is we're going to put a character pair in front of
05:39each one of these sections.
05:40It's going to be a character pair that you would find in no other place in your CSS.
05:44So, you're going to use unique characters and sort of a sequential numbering
05:48system to let people know that this is the unique character you're going to put
05:51at the front end of the section, when you comment out your CSS later on.
05:55So, right before the Header section, for example, you'll do the little
05:59section separator that we have here, but in front of the name, you'll put the
06:03special characters.
06:04Let me show you what I mean.
06:05So, click in front of Global constants, and here I'm going to type in ^1.
06:10So, the ^ is that sort of up-arrow- looking character right above the 6, if
06:14you hold the Shift key.
06:15So, ^1. Now, I'm probably not going to have ^1, ^2, ^3 anywhere in my CSS.
06:21Some people like to use the tilde character; some people like to use other
06:24characters like the pipe.
06:25It's totally up to you.
06:27Then we're just going to keep going, and we'll do ^2 right in front of CSS
06:31reset. Notice that I'm being very careful to put a space in between those.
06:35^3 for Global classes, ^4 for Home page layout, ^5 for Top-level layout, ^6 for
06:44Region detail styles.
06:46Then in front of the subsections, I'm just going to start subsectioning these off as well:
06:50so ^6a for Header, ^6b for Navigation, ^6c for Main Content.
06:58I suppose I could keep going with that, but sometimes you can go a little too far.
07:02So, I'll just use ^6d for Data tables, ^6e for Spotlight region, ^6f for Forms,
07:11^6g for Sidebar, and then finally ^6h for Footer.
07:17Now, how does this work?
07:18Well, later on, if we were going to do our first section for Global constants,
07:22for example, I could come down here, type in a separator, and then do ^1 Global
07:31constants, just like that, okay.
07:35So, that might be our separator. A little later on,
07:37I could go ahead and comment that out, that sort of thing.
07:40So, to jump down to that section, all I would need to do is highlight
07:44that special character.
07:45Then in Dreamweaver, I can go up to Edit, and we can use the Find and Replace feature.
07:50So, Find and Replace, what that can do for you is, as a Find Next, that will
07:53just cycle through all of the elements.
07:56We don't have to bring up the Find and Replace dialog box to do that.
07:59As I mention in the keyboard shortcut, we can do Find Selection.
08:04So, I'm going to highlight that again, and I'm going to go up to Edit > Find Selection.
08:12Again, the keyboard shortcut for me on the PC would be Shift+F3.
08:15So, if I hit that, notice it jumps right down to that section.
08:18Now, that's not that impressive, because that wouldn't be a hard scroll, but
08:21imagine you have thousands of lines of code, and you can instantly jump down to
08:25that section and start working.
08:26So, that's a really, really handy feature.
08:27Now, again, for smaller, simpler sites, you probably won't need anything as
08:31complex as a TOC, especially this particular TOC;
08:34however, for larger sites, or more complex style sheets, having a TOC gives you
08:40a nice resource for exploring the organization of your styles, and a way to
08:44quickly navigate through the code.
Collapse this transcript
Creating sections for styles
00:00One of most important things you can do for organizing your styles is to
00:04create sections within your style sheets that group specific content, regions
00:09or even types of styles.
00:10In this movie, we'll continue to organize our style sheet by creating
00:14sections for our styles.
00:15So I'm going to over to my Files panel,
00:18open up the _css folder,
00:20and I'm going to open up the main. css file that we've been working on.
00:23I'll scroll down a little bit beneath the TOC that we've created a little bit
00:27earlier, and just hit Enter to give myself a little bit space.
00:31Now here I'm going to start using that sort of consistent structure that we
00:34have for separators.
00:36I'm going to start our first one by doing ^1.
00:39Remember, we're using these special characters that we created in our TOC to
00:44allow us to easily jump down to that section by using the Find Selection
00:48feature inside Dreamweaver.
00:49It allows us to jump right down to that.
00:51Now after that I'm going to type in a few hyphens.
00:53Now how many you type in is up to you.
00:55I just held the Hyphen key down until I was like that's far enough.
00:58What you're looking to do is when you scroll through your styles, you want to be
01:02able to find these separators really easy by having them sort of stand out.
01:07So after that I'm going to type in global constants, and then we'll finish that up.
01:14And at this point, it's a lot faster, when doing some of these, to go ahead and add
01:18the comments as you type.
01:20Notice that now I have to highlight this, go over to my Coding toolbar and apply
01:24the CSS multiline comment.
01:26Now that was okay, and it wasn't that difficult, but frankly it's easier for me
01:30to do it myself, and I don't have to worry about whether or not I have any type
01:34of separation between any special characters.
01:37Okay, now what I'm going to do is from here on out, I'm going to go down and hit
01:40Enter twice and start typing on a new line.
01:43Now I could go ahead and type all of this out again, and go ahead and type in the
01:47number of hyphens that I need, or I could just go ahead and copy and paste.
01:51Copy and paste is pretty nice, but as we're going to see, it's not always going to work.
01:54So our next separator, I'm going to type in the comment first, so /* and then
01:59space, and I'm going to do ^2, and then again, I'm just going to start doing
02:03those hyphens in, and then I'm going to type in limited scale reset.
02:09Again, type in my hyphens and then end in about same spot */.
02:16Now how organized you get this is up to you, but notice that I'm using pretty
02:19much the same width for each one of these guys. Because some of the titles are
02:23longer or shorter than others, some of them need more hyphens or less hyphens.
02:27It's really a personal call, how you want to do this.
02:30There's no set way to do this.
02:32So you could certainly copy and paste.
02:34You could just do one from scratch.
02:35Now later on in this title, we'll just talk about something called a code
02:39snippet. And so if you're going to always structure your CSS in this manner, it
02:43would make sense to create sort of the sectional marker like this as a snippet
02:46so that you don't have to keep typing it.
02:47Now let's go down to the next line, and I'm going to do /* again and ^3.
02:53Let me go ahead and type in my hyphens here, and then I'm going to type in global classes.
02:59Finish that out by mimicking the structure again, hyphens and the */.
03:04Now, if you're going to be typing in these comments by hand, /* */, make sure that
03:10you see the color change to gray as you finish it up.
03:14You don't want to leave this open because notice that I could go down to the
03:16next line and start typing, and I could do /* ^4 and just keep going.
03:22Everything remains gray. It's no big deal.
03:24But eventually I have to close this.
03:26If I don't, the CSS underneath this would still be considered commented out. Let me show you.
03:32If I go down here and I type in an h1 selector, notice that it's grayed out.
03:35That would not be rendered.
03:37So if you're going to type those by hand, make sure you close them properly, */.
03:43After global classes, we're going to do home page specific layout styles, and
03:50then we'll finish that up.
03:52So I think you can see what I mean here.
03:54Obviously, there were too many hyphens on the front end and not enough on the backend.
03:58So you can sort of adjust those if you would like.
04:00And again, how strict you are with this is up to you.
04:04Remember, these sectional markers are going to be separated by dozens of lines of code.
04:08You will very rarely see them on one screen at same time.
04:11They're really for your benefit as you're scrolling to sort of catch your eye.
04:14Again, hit Return twice, */ and here we're going to do ^5, and this section is
04:22going to be the top level region layout styles.
04:28I'll finish that up by doing some hyphens and then */.
04:33Notice that I'm giving two lines of space between these guys, as well.
04:37I want enough space in there to make it really easier for me to go in and start
04:40typing within that section without having to hit Return or Enter all the time.
04:44Next up, we're going to do region detail styles.
04:48Again, I'm going to finish that up, as well.
04:50Now you can put additional comments here if you'd like, to sort of identify things.
04:54For example, let's go back here to the top level region layout styles.
04:58Maybe you want somebody to know what you're referring to there, and you could
05:02really do this for any of these sectional headers.
05:03I'm going to go down to the next line here, and below that I'm just going to type
05:06in: /* top level regions are header, mainNav, mainContent, sidebar and footer.
05:20Then I'm going to finish that with */.
05:23So these are the actual ids of the div tags that are going to be used for
05:28sectional content in our site.
05:30So we're basically just letting people know what we consider to be a top level region:
05:34any div within the id of mainNav, mainContent, sidebar, footer.
05:38Those are the top level regions in our file.
05:41You can be as instructive with these sections as you want, or you could just
05:45not type them in at all.
05:46That's either for your benefit or the benefit of anybody on your team.
05:50All right, now I want to go ahead and finish this off by doing all of our
05:54region detail styles.
05:56Remember, our TOC is indicating that these guys are subsections.
05:59Instead of using a main section indicator like we have here, we'll do a smaller
06:03version of that, sort of to denote its level of importance within the code.
06:07In fact, that it is a subsection.
06:09So I'm going to hit Return to go down to the next line a little bit.
06:11And here, I'm going to do /* and then no hyphens.
06:16I'm just going to immediately type in the word "header."
06:18After that, I'm going to do ^6a.
06:22So here we're putting the indicator on the back end and not in front of it.
06:26That's really a personal choice.
06:28If I don't have sort of long dividing line, I like to have the name of the
06:32section at the very first so that people can read it very clearly. So */.
06:37And we're just going to follow that from here on out.
06:39So after that we're going to do navigation, and we're following the following
06:43the exact same order that our TOC is in.
06:45That's going to be ^6b and finally */ and on the next line /* mainContent
06:56region, and that, again, is going to be ^6c, and that's going to be */.
07:04Next, we're going to start a comment agai,n and underneath that it's going to be
07:07the mainContent specific regions.
07:13We're actually not going to put an indicator here.
07:15Now the reason for that is we're just sort letting people know that okay within
07:19the mainContent there are further regions that need to be identified.
07:23So if you'd like, you can go just on the next line to let yourself know that
07:26these are grouped, not even give any spacing here, and then we're going to do
07:30/* data tables, and we'll pick back up with our indicators, so ^6d */ below
07:42that, and I'm just going to go back to having that sort of double-spacing
07:45between those areas.
07:46Here, we're going to do spotlight region.
07:50Now again that's going to be ^6e */.
07:56And then again go ahead and do multiline comment here, and I'm going to type in
07:59form styling. That's going to be ^6f */, and we're almost done, */ sidebar, which
08:11is going to be ^6g */, and then our last one.
08:17So write your comment, and we're going to do footer region, which is ^6h */. Well, there we go.
08:25Now we have all of our sections ready to go, and we can just put as much CSS
08:29between these guys as we need.
08:31So the structure of our CSS is built.
08:34Now honestly, the strategies for grouping styles and these sections is
08:38entirely up to you.
08:39I recommend taking some time to think about how your site is structured, whether
08:43you want to separate properties such as layout typography and color, so you
08:47can sort of do that -
08:47we've got some layout styles I have put in here, but we don't have typography
08:50and color pulled out -
08:51and then equally important, what the needs of your site will be in the future.
08:55The proper organization of your styles will create a much more manageable
08:59site, and it's going to make updating and scaling it easier for you and any of your team members.
09:04If planned properly, that organization should start right here as your styles
09:08are being created.
Collapse this transcript
Using the CSS Styles panel to organize styles
00:00While properly planning and organizing your styles before you begin
00:03creating them is essential,
00:05it is inevitable that you'll have to do some reorganization as your site
00:09changes, or even during the development process.
00:12The CSS Styles panel features some pretty powerful organizational capabilities,
00:17and in this movie we are going to explore using them to restore order to your styles.
00:21Now we are going to focus on our CSS Styles panel in this movie, so I am going to
00:25go over to my Files panel.
00:27Double-click that tab to collapse that so that I get more room for my CSS styles.
00:31Now you may have noticed our style sheet now has styles in it.
00:34So if I flip over to main.css here in my resources and look at the Code View,
00:39we can see that all those sections and everything that we created earlier now are
00:43populated with Styles.
00:44So this is a little further in the development process after I created all those
00:48sections, and now the styles have been added.
00:50But the styles aren't exactly the way they are supposed to be.
00:53So we could go ahead and go back into our code, start copying and pasting and
00:59renaming things, and doing things like that.
01:01Or we can take advantage of the CSS Styles panel, which is going to allow us to
01:05organize our styles in a much faster and more efficient manner.
01:09Now let me show you what I mean.
01:10Over here in you CSS Styles panel, make sure you're looking at the All view, so
01:15click the all button.
01:16And then if I collapse the main.css and collapse the print.css, so here is my
01:21external main and my external print style sheet, I can see that I have a style
01:25tag here, which indicates embedded styles for this page,
01:29and I have a rule for the h2 and h3 selector.
01:32Now sometimes you might just test out a style locally -
01:35see how it looks on this page before you commit it to your entire site.
01:38Or you might create a couple of rules thinking, well I only going to really need them for this page.
01:43And then as you keep working on your site you realize, oh, well I really did
01:46need that for everybody,
01:47so I probably should have put it in my external style sheet rather than just
01:50trying to have it here locally.
01:52Now to fix that by hand you'd have to do a lot of copying and pasting and moving
01:55back and forth between one document and another.
01:57By using the CSS Styles panel, we can just move them in one efficient operation.
02:01So what I am going to do is highlight the h2, hold down the Shift key and
02:04click on the h3 selector.
02:06I want both of those guys selected.
02:08Now after that, I'm going to right -click, or on the Mac Ctrl+click.
02:11And you'll notice that we have a command listed as Move CSSRules.
02:17Now you can also find that in the CSS Styles panel menu.
02:20So if I go to CSS Styles, right over here, top right-hand icon is the menu.
02:25I can also find it there.
02:26So really either any of those places you can right-click or you can do that.
02:29So I am going to choose a Move CSSRules and take a look at our options.
02:33We can move them to any existing style sheet that is attached to the page,
02:37or we can even move them to a new style sheet.
02:39So if you had a page where you had tons of embedded styles that were
02:42driving just that page,
02:44and you are like you know what, those could drive my entire site,
02:46you can go ahead and export them out to an external style sheet, which will be
02:49automatically attached to this page.
02:51That's pretty cool.
02:52Well we just need this placed in the existing main.css style sheet.
02:57So we are going to go ahead and make sure that's selected.
02:58We are going to go ahead and click OK.
03:00And if I scroll down to our style tag down here, you can see that that is now empty.
03:05I also notice that in my main.css, which has been expanded for me again.
03:09The h1 and h2 selector are added at the very bottom.
03:13Well it was cool that it moved them for me, but it really totally destroyed my
03:17organization because they are not supposed to be down there.
03:20Well let's get rid of our embedded style tag first.
03:22We don't need that anymore.
03:23It's cluttering up our codes.
03:24So I am going to highlight that embedded style tag right there.
03:27Then go down to the Trashcan icon and click.
03:30Now be very careful. Anytime you click that Trashcan icon you only want to do it one time,
03:34and you want to be very, very certain of what you have highlighted before you click it.
03:38Now I'll close the prints style sheet just to avoid confusion with any of
03:41those types of styles.
03:42And again, on the Mac that's going to be a little arrow; on the PC here, it's a minus symbol.
03:46That'll go ahead and collapse that down.
03:47Now I need this h2 and h3 these are global constants, so they need to be up in
03:52this area where their grouping of styles are.
03:55And again, with the CSS Styles panel that's pretty easy, as well.
03:58I am going to go ahead and highlight both of those again.
04:00With them highlighted, I am going to click and hold the mouse down.
04:02And I am going to keep the mouse held down the whole time.
04:05And I am just going to move up.
04:06And you can see I get a little dividing line.
04:08And if I keep up, it'll scroll for me.
04:10And I am just going to keep scrolling up and up and up and up and up.
04:13And it's kind of a slow scroll, but that's a good thing because that allows you
04:17to precisely place them where you want.
04:19And where I need these guys is right here, just below the h1, h2, h3 group
04:25selector, just below that.
04:27So I'm going to see a blue dividing line between those.
04:29Let go, and it's moved those back.
04:32Now I want to switch over to Code View in main.css for just a moment because I
04:36want to point something out about this.
04:38You want to be pretty careful about these guys, and if you have a section marker,
04:43like right here we have our global classes,
04:45if you are moving your styles to a location that's at the very end or the very
04:48beginning of one of those sections.
04:50you want to go over to Code View real quick and just make sure that it hasn't
04:53placed them in the wrong section.
04:55Coming back to Design View, I am going to do a Save All.
04:58So we see now we can move styles from one style sheet to another, from
05:02embedded to external.
05:03We can drag styles around, that sort of thing.
05:05Well that Move Styles command was helpful, but the problem with it is that we
05:10don't control where in the style sheet it placed our files.
05:12We had to do that by simply clicking them and dragging them and rearranging them
05:15within the style sheet.
05:16Well we can use the drag and drop method to actually move styles from one sheet
05:20to the other, as well.
05:21In your main.css, scroll down a little bit until you get to these classes.
05:25And I have a .pb before and a .pb after.
05:29Okay, well that actually refers to page breaks, which means that those classes
05:33belong in the print style sheet, not in our main screen style sheet here.
05:38So I'm to highlight both of those guys: pb before pb after.
05:42And with those highlighted, again I am just going to click and hold the mouse
05:45down on them and drag down this time.
05:47Again, we are going to get our scrolling down.
05:49And notice that of course we can reorganize them within this style sheet,
05:54but as we get down into our print style sheet one of things that you are going
05:58to find is that we can move them for one style sheet into the other.
06:01So just hovering over the print style sheet will cause it to open up.
06:04And I want to place this at the very, very top of the print style sheet.
06:08I am going to let go the mouse.
06:10And it just moved them right there.
06:13I can actually verify that by going into my print.css, scrolling up, and there
06:17they are at the very top.
06:18I am going to go ahead and do a Save All and switch back to Design View.
06:22So reorganizing our style sheet is pretty easy.
06:25We can use the Move Styles command, or we can just take matters into her own
06:28hands and drag and drop them.
06:30But there are other things that the CSS Styles panel can do to help us
06:33reorganize our styles, as well.
06:35I'm going to scroll back up into this main content section here.
06:39And there is one thing I want to revisit.
06:41When we were naming our classes, there was a class named artImg.
06:46And actually, if you highlight the picture that's on the page, you can see that
06:50it has class applied to it, artimg, and that stands for article image, but
06:54that's kind of misleading.
06:56Art might mean something to one person and something to somebody else, so you
07:00wouldn't naturally denote article from that.
07:02You might draw another meaning from it.
07:04So we really need to rename that class.
07:07And now if you've ever done that by hand, you know how much of a pain that can be.
07:10You rename the class in the CSS, and then you got to go into the HTML, find
07:14every single element that has a class applied to it, and rename it there, as well.
07:19And if you don't, then your styling is messed up.
07:21So that can be a real hassle.
07:23Using the CSS Styles panel, we can do that in one single operation.
07:27Let me show you what I mean.
07:28I am going to come right over here to the #mainContentimg.artImg.
07:32So go ahead and highlight the rule, right- click it, and you want to choose Rename Class.
07:36Now if you don't see this let me show you something.
07:38If you click on your selector and then you just sort of hover there for a
07:41moment, or click once and then click again really briefly after that, it'll
07:44highlight the text.
07:45If the text is highlighted like this, it allows you to rename that,
07:49but if you right-click you don't get the same menu.
07:51So instead of highlighting the text that we've got here, make sure you just click
07:55once on the selector very briefly.
07:57Then I am going to right- click and choose Rename Class.
08:00It's going to say okay you want to rename which class?
08:02So you can actually grab from the pulldown menu choose any class you want.
08:05So you don't even really have to make sure you are focused on that
08:08particular selector.
08:09Here we are going to do art image, and then we are going to rename this articleImage,
08:14all one word, lowercase a uppercase I, and we don't have to put a period in the front of it.
08:19You don't have to do that for this.
08:20I am going to go ahead and click OK.
08:23What's really cool about this is now look in our CSS.
08:25ArticleImage is the class name on that selector.
08:29And then if we click on the image itself, we can see that it had also
08:32changed that as well.
08:33That is really cool.
08:34It's going to find everything in this page and go ahead and rename that class for me.
08:38So that's a really neat future.
08:39One brief little problem with that:
08:42It doesn't help the rest of the pages in my site.
08:44It only helps the page that I have opened.
08:46So of course, that's going to cause us a lot of tedious work, right? Well, not really.
08:51Take a look down here in the Search panel.
08:53In the Search panel, I can see that it just did a Find and Replace in the Current document.
08:57So really, what Dreamweaver is doing is it's running a Find and Replace command
09:01to find anything with the old name and replace it with the new name.
09:04Well that'll be really helpful if we can do that site-wide, wouldn't it?
09:07Well if you go right over here to the Search panel and you click the Play button,
09:11the Find and Replace dialog box is going to open up.
09:14What's really cool about this is it remembers what you just did.
09:18So the Find and Replace dialog box, every single time you open it up, for the most
09:22part, it's going to show you the previous Find and Replace.
09:24And in case, it was Dreamweaver running that own command.
09:27So now I can change it from Current document,
09:30I will grab the pulldown menu here,
09:32and I am going to choose Entire Current Local Site.
09:35So now I'm saying hey go ahead and make this change site-wide.
09:39Anywhere in my manage.css, anytime you find any tag with a class of art image,
09:45go ahead and set it.
09:45Set the class attribute to article image.
09:47Now you may notice these weird special characters in front of that.
09:51Those are what we call regular expressions.
09:52And they sort of help protect some of any of the other classes that you
09:55might have going on.
09:56And I'm just going to go ahead and make that change is done cleanly
09:59throughout the site.
10:00We already know this works.
10:02I am just going to hit Replace All.
10:03It's going to warn me that hey this can't be undone in files that aren't open.
10:07Are you sure? Hit Yes.
10:08And now look at all the change that got made site-wide that we didn't have to go
10:12in, open up and replace that by hand - really, really cool.
10:16Now, you know it's always best to try to plan ahead, but realistically,
10:19you are going to have to make changes, both large and small, to your styles as you work.
10:23Understanding the CSS Styles panel can make those changes a lot easier and a
10:27lot more efficient.
Collapse this transcript
Resolving conflicts
00:00As your CSS becomes more complex, it's inevitable that you write a style, look
00:05at your design and say, why is that happening?
00:08Now, this usually happens after you write a style and just don't see what you
00:13expect. The formatting just isn't there.
00:15The culprit is typically a style conflict,
00:17a situation where either the cascade or the specificity of the rules involved
00:22thwarts your desired formatting.
00:24Searching through hundreds of lines of code to find these conflicts and resolve
00:28them can be time-consuming, and is really frustrating.
00:32Well, that's where the CSS Styles panel comes to our rescue once again.
00:35As we'll see in this exercise, it can help us quickly and easily resolve any
00:39style conflicts we come up against.
00:41Now if I scroll down a little bit, I can see that we have this area down
00:45here where we have our current monthly Tour Spotlight, highlighting the
00:48Explorer's Podcast, which is a nice little Flash video, and a little section
00:50on Have questions.
00:52So all those headlines are fairly related, but this one, and we want make it
00:56stand out a little bit.
00:57It's the Tour Spotlight. We really want people to take a look at that because
01:00we're highlighting that particular tour for the month.
01:02So I think we want to change the color of that headline.
01:04I want to make it red.
01:05It is sort of that nice bright accent color that we have.
01:08Now I could do that in number of different ways, but writing a class seems to be
01:12one of the most efficient ways to do that.
01:14That also allows me to reuse that on other pages for pretty much any headline I
01:19want. I just apply the class, and I will have it work.
01:21So let's go ahead and do that.
01:22So what I'm going to do is just select my main.css.
01:25Make sure I am working with the external style sheet, right up here.
01:28Create a brand-new CSS Rule.
01:30I am going to go ahead and choose Class as the Selector Type, and I am just
01:33going to type in .spotlight.
01:36That seems to be pretty self-explanatory.
01:38So .spotlight, and I want to define it in main.css.
01:42So if you didn't highlight the style sheet earlier, you can just choose from here.
01:45I am going to go ahead and click OK, and this is going to be a really easy style to write.
01:50I am just going to go right over here to Color, and I am going to type in
01:52#cb202a, and if you hit Tab, you'll see that sort of bright red color that
02:00this is going to be.
02:01I will go ahead and click OK, and of course, writing a style is only half of it.
02:06We have to apply the style, as well.
02:09So I am going to click inside the headline for Tour Spotlight, and if you really
02:12want to make sure you have the heading, remember you can use the tag
02:15selector right here to click on the h2 tag, and that's going to select the
02:18entire heading, not just the text inside of it.
02:21So now what we're going to do is we are going to go ahead and apply our class.
02:24So I am going to click on my HTML properties right here, and you can see the
02:28Class pulldown menu. Right now, no class is associated with that.
02:31And I want to find this one right here, spotlight, the one we just created.
02:34I am going to go ahead and click on that, and now our headline is not red.
02:39So we were expecting it to be red, but it's not.
02:42So obviously one of our other styles is conflicting with this, and so we have a
02:46style conflict that we need to resolve.
02:48Now, if we had to do this by hand, we would have to flip back over, find any of
02:52these styles that were related to this, try to figure out exactly which selector
02:56is overwriting this and why.
02:58Is it a problem with the cascade?
02:59Is it a problem with inheritance?
03:00Is it problem with the specificity?
03:01There is all manner of issues that really could be here.
03:04So I think what I want to do is let the CSS Styles panel let me know what's going on.
03:08It can help me with this.
03:09So I am going to go over to my Files panel again.
03:11I am going to double-click the tab of the Files panel.
03:13I'm just going to collapse it, just give me a little more room, because I am
03:16working with probably less screen real estate than a lot of you guys.
03:19Now currently I'm looking at my styles in the All view, and that's not
03:22really helping me here.
03:23I want to click on the Current view, and in the Current view, I have got two
03:27options, and they are indicated by these two little icons right here.
03:31They look like little stairs.
03:32The first icon is just going to basically show us, in this middle section,
03:37information about any property.
03:38So if I click text-align, for example, it will tell me where it's defined, what
03:42selector -- in this case, the wrapper rule is driving this.
03:44So it sort of gives you an overview of where all the issues are.
03:48Now if I select Color, notice that when I select Color, it says hey color is
03:51defined in a rule #spotlight h2.
03:54And you are like, hey, that's actually supposed to be coming from the Spotlight
03:57class selector that I've created, so what's the deal?
04:00Well the icon just to the right of that is an icon that will show us the entire cascade.
04:05So if I click on that, this middle section gets a lot larger.
04:08As a matter of fact, you may need to rearrange these panel sections, maybe like
04:12leave less room for the summary and more room for Cascade, so you can see that
04:15there is quite a lot going on here.
04:17So what we are looking at right now is a list of rules, a list of rules is showing
04:21up from the closest rule, which is right down here on the bottom, the one that
04:24takes precedence over any of the other rules, and it just goes up.
04:28This is going to show you any conflicts that might be happening due to specificity.
04:31It's going to show you any conflicts that might be happening due to cascade,
04:34or due to inheritance.
04:35It's going to show these selectors in the order that they're applying to the element.
04:39And one at the very bottom is the last one applied, and of course the last rule applied wins.
04:44In this case, we have this #spotlight h2, and if I hover over that, it tells me
04:50it's defined in main.css, and has a specificity of 101. Okay.
04:55But if I look at spotlight and click that, I can see color has a strike-through,
04:59and that tells me that color is not being applied and if I hover it, it does not
05:03apply to your selection because it's been overridden by the rule #spotlight h2.
05:07So it tells you the exact rule that's causing you grief.
05:11Now it's interesting.
05:12If I hover over spotlight over here, it tells me that this has a specificity of 10.
05:16So I am dealing with one selector that has a specificity of 101.
05:19I am dealing with another selector that has a specificity of 10.
05:22So it's pretty clear what's happening here.
05:25Specificity of the #spotlight h2 rule,
05:28that descendent selector, is overriding just a single class selector here.
05:32It's not specific enough to override that bottom selector.
05:35So all we have to do now is change the specificity of this selector, and we are in good shape.
05:39So I am going to go back to my All CSS styles.
05:41I am going to find that spotlight class selector that we wrote earlier.
05:44It's probably at the very bottom of your styles.
05:46I am going to go ahead and click on it once and then click one more time.
05:49And when I do that, it highlights.
05:51So I am free to go ahead and change the name here in the CSS Styles panel.
05:55I don't have to switch over the code to do that.
05:57So I am going to click right in front of the period, for spotlight there.
06:00I am going to type in #spotlight and spelling counts, so I got to be
06:05very careful there.
06:06So #spotlight h2 and then no space .spotlight.
06:12So what this is, this is an element-specific class selector.
06:14So you're saying an h2, with a class of spotlight found inside the spotlight region.
06:20I am going to hit Enter or Return. Look what happens.
06:24I now have a red headline.
06:25So now if I switch back over to Current, I can see that that is much more specific now.
06:30It's 111 as opposed to 101, and our conflict has been resolved.
06:35All that's left for us to do, really, is just move this up into the proper location,
06:38so that our styles are organized properly.
06:40Now that was a pretty easy conflict to resolve, I have to admit, but if you have
06:44been writing CSS for any time at all, you've probably come across at least one
06:49instance of style conflicts that took a long time to resolve. Using the Current
06:53view in the CSS Styles panel to display the cascade and the specificity of your
06:57rules makes hunting down and solving those conflicts remarkably simple.
Collapse this transcript
Organizing style properties
00:00Just how much organization you add to your styles is totally up to you.
00:04You can keep your organization strictly to sectioning styles off,
00:08splitting layout, typography and color into their own sections, or you can
00:13get really detailed with it.
00:14In this movie, I want to talk about various ways you can organize your style
00:18properties and some of the strategies behind doing so.
00:21We really just have a couple of different categories of style organization that
00:24we are going to talk about here.
00:26One is organizing the properties alphabetically, another one is organizing
00:30properties by the type of property and then finally, we have a little section
00:34down here where we are going to experiment a little bit with Dreamweaver's
00:37default property organizations and try to make some sense out of that. Okay.
00:41So I am going to go back up in my styles to the section where we're going to be
00:45organizing these properties alphabetically.
00:48So here we have all of our properties for our rule: background, margin, padding, position.
00:52Now, why bother to organize these at all?
00:55Well, when you're looking through your code later on to try to help solve the
00:59problem, resolve the conflict, that sort of thing, it's really helpful if you can
01:03quickly and easily find a property.
01:05Imagine trying to sort through this and figure out what font you are using, what color;
01:09it's really unorganized.
01:10Now it probably wouldn't take you that long, but anytime you can save is very valuable.
01:16So what we want to do is we want to rearrange all these
01:18properties alphabetically.
01:19Now I wish I could tell you that Dreamweaver had a miraculous
01:23alphabetize properties command. It does not.
01:26So we are going to have to do this by hand, but it's not that bad. Let me show you.
01:30So what I am going to do is highlight the property for border.
01:33Now be very careful when you do this.
01:35Notice that I have got the property itself, the value and the semicolon.
01:39Don't forget that semicolon;
01:40it has to highlighted.
01:41Now, of course you can cut and paste. You can do that.
01:43But you can also drag properties around. Watch this.
01:45I can just drag this right into that position.
01:48So now border is right after that.
01:49I can drag color right after that.
01:52Now, why am I stacking them on a single line?
01:54Don't I want them on separate lines? I do.
01:56But what I am doing is I am going to go ahead and stack them, and then just move
01:58them down all at the same time.
01:59It's really an interesting technique.
02:01We'll just keep going.
02:01Let's go ahead and do font, and I am going to put font up there.
02:05Also, notice one other thing that I am doing here.
02:08When I highlight a property, I could, if I wanted to, highlight all the way over
02:12here and get the tab as well. I don't want that.
02:14I just want to the very edge of the property.
02:16So now I've got background, border, color, font. Those are all more or less in
02:20the order that they need to be in.
02:22And the remaining properties: margin, padding, position, text-align and width,
02:25those guys are already in alphabetical order. So we are good.
02:29Now watch what I am going to do here.
02:29I am going to start with width.
02:30I am going to highlight all the way up, and get font.
02:32Now again, notice how careful I am being here.
02:34I've got the closing semicolon on width. Not touching the semicolon on color.
02:38Now, I can grab these and just move them straight down until I see this little
02:42line and look, it returns font to me. Wow, cool!
02:44So all I have to do is do that each time.
02:47Just drag that whole block down one line, and then it just sort of
02:50pulls everybody down.
02:51One more time, and there we go.
02:53So now our properties are organized alphabetically.
02:56Now of course if you are writing your styles by hand, you can write them in
02:58alphabetical order and save yourself a ton of time, if that is the
03:02organizational technique you want to use.
03:04Now, for a different organizational strategy, let's go down and look at our next selector.
03:08So same selector, same properties, but we are going to organize them in
03:11dramatically different ways.
03:13Here, we're going to split them by the type of properties.
03:15So we are going to have one section for layout, another section for box
03:19model properties, another section for presentation, like typography and
03:22color, that sort of thing.
03:23So right above the first property, I am going to hit Return and create myself a
03:28blank line, and I am just going to type in the word "layout."
03:30I am going to highlight that and then apply a CSS comment to it, sort of to gray that out.
03:36Now, I'll go down and create another section here, and this one is going to
03:40be called Box model.
03:41I am going to highlight that, and again apply a comment to it.
03:45So you can have comments directly inside the rules.
03:48There is nothing wrong with that.
03:50There is nothing to say you can't do that.
03:51Then finally, I'll create another little section.
03:54You'll notice I am just kind of going down a little bit; obviously these
03:57properties aren't organized yet.
03:58I am just creating these sections.
03:59We are going to do Presentation, and then we'll highlight Presentation and wrap
04:04a comment around it, as well. Okay.
04:06So now we need to move things where they go.
04:08One move that's really easy to make here is position:
04:10relative needs to go up under layout.
04:12So I am going to highlight position: relative.
04:14Notice that I got the semicolon as well, and move it up.
04:16Now, background on the other hand, background belongs in the presentation.
04:20So I'll move it to presentation.
04:22Box model, margin, and padding, how lucky was that? We got all those.
04:26But width is also part of that, and I am going to go ahead and do width
04:29and place it there.
04:30And if you need to, you can always hit Return or Enter to give yourself a line.
04:34Now, do you see what I just did there?
04:36I hit Return, but the semicolon came down with me.
04:38Actually, syntaxually, there is nothing really wrong with that, but that is a mess.
04:42So I am going to make sure that I undo that, and I get that so that the
04:45semicolon stays right there.
04:47Now, the rest of these guys are all presentation styles, and what I am going
04:51to do now is I am going to alphabetize them as well, because I'm just that organized.
04:56Anybody that knows me knows that I am really not that organized.
04:59But I am just going to grab these guys and start moving them around, and I am
05:03going to put color where it goes, text-align where it goes. There we go.
05:07So these guys are now in alphabetical order as well.
05:09So now we have a different structural model for our properties, and this is
05:14something that if I was going to use this, I would do every single selector,
05:19every single CSS rule to get the same thing in the same order;
05:22layout first, box model second, presentation.
05:24That way, if I'm going and checking out the margins on a property, for example,
05:28I know exactly where to find those.
05:30If I'm looking to see if there's been any kind of an offset or absolute relative
05:34positioning, again, I know exactly where to find that.
05:37So this is another way to organize it, and again it's totally up to you to decide
05:40how you want to do that.
05:41Now, I mentioned that we would do one more, and that's really just to see how
05:44Dreamweaver does this.
05:45So I am going to go over to my CSS Styles panel, and since we've been making some
05:49manual changes, we're going to have to have a Refresh there, and what I want to
05:52do now is create a brand-new CSS rule.
05:54I am just going to do a tag selector, and we're just going to do h1, although
05:58really any selector would work for what we're doing here.
06:00So I am going to do a tag selector h1, and I am going to define it in
06:03this document only.
06:04So this is kind of interesting.
06:05While you're working in the CSS file, you are free to still use the same dialog box.
06:09That's kind of nice. I am going to go ahead and click OK.
06:11Now I am going to go in a very specific order here, because I want to prove a point.
06:15The first thing I am going to do is go to my Font-size and Font-size, I am
06:17going to type in 2em.
06:19So that's the first property.
06:20Remember, the number one property we did was Font-size.
06:23Then I'm going to go to my Block category.
06:25So notice that I am going to be jumping around from categories, so just think
06:28about the order that we are doing these in.
06:29I am going to go to Block category.
06:31In the Block category, I am going to choose Text-align, and I am going to choose Center.
06:34Here we go. I am going to click on the Box category.
06:37In the Box category, I am going to deselect Same for all for margin and give it
06:40a Bottom margin of 2em, for ems.
06:42Notice there's no spacing there.
06:43If you hit Tab, it will go ahead and populate that out.
06:45I am going to go back to Type.
06:47So again, we went down the list. Now we are going back to Type.
06:50For Color, I am going to type in #333, and then I am going to go to Border
06:54next, deselect Same for all, and I am going to do a Bottom border, solid, 1 pixel, #333.
07:03Let's just do one more rule.
07:04Go back to our Box model property.
07:05So you can see we are jumping all over the place.
07:07We are not doing these in order at all.
07:09I'll deselect Padding, Same for all, and for Bottom padding we'll do .5em.
07:12I am going to go ahead and click OK.
07:15Now, think about the order that we did these in.
07:16Font-size was first. Text-align was second. Margin-bottom was third. Color was
07:21fourth. Border-bottom was fifth. Padding-bottom was sixth.
07:24Now, if we look at the rule that's created, font-size was first, oh, but wait!
07:29Color wasn't next; text-align was next. And then after text-align,
07:32margin-bottom was next, after that border-bottom, and that's our border, and
07:36then I did padding.
07:37So obviously, Dreamweaver didn't use the order that those properties were done
07:40in to determine how to organize them in the selector.
07:43Now, a lot of people infer from that that is random, but it's not random.
07:47Take a look over here at the CSS Styles panel -
07:49I am going to go ahead and close the Files panel by double-clicking the tab -
07:52and we can see if we highlight the h1 rule in All view here, we get summary
07:57of all the properties.
07:58But there are three ways that you can view this.
08:00One is the way we are looking at right now, just those properties;
08:03another is a List view, and then the first icon right down here in the lower
08:06left-hand corner of the CSS Styles panel is Show category view.
08:10Take a look at categories: Font, Background, Block, Border, Box, List.
08:15So Font, these are all things that we can do font with.
08:18Block, right there, which would come next, since we don't have any our background,
08:22Box model which is right here, and then Border.
08:24Now, I can't figure this out for the life of me, but for some reason, it
08:28switches Border and Box.
08:29I have no idea why, but it does.
08:31So what Dreamweaver is doing is organizing these properties in their own categories.
08:36So you could almost imagine, above this, a little comment that says Font
08:39properties and then another comment underneath it that would say background,
08:42another comment that would say Block, and we'd organize them that way.
08:45So there is structure there; it's just not readily apparent.
08:48So aside from Dreamweaver's default way of organizing properties, we've seen two
08:52popular strategies for organizing our style properties, either alphabetically or
08:57through categories of properties.
08:59So aside from Dreamweaver's default organizational strategies, we've seen two
09:03popular strategies for organizing style properties: either alphabetically or
09:07through the categories of the properties themselves.
09:10Now, it's a personal decision, honestly, as to whether or not your styles need
09:14this kind of organizational structure.
09:16Now, I usually organize my properties alphabetically, and I find that
09:19it saves me time when scanning code for a specific property or value.
09:24In the end, however, it's totally up to you to decide if you need to take the
09:27time required, because it does take extra time, to organize your style properties
09:31all the way throughout your site.
Collapse this transcript
Writing a CSS reset
00:00One of the most common problems that designers face when writing their styles
00:04is failing to account for the default margins and padding inherent in most browsers.
00:09Every browser has a default style sheet that assigns properties to common
00:12elements like paragraphs and headings, and every browser's style sheet is just a
00:17little bit different from the others.
00:19It can be extremely frustrating
00:21to try to track down why you have that little bit of extra space between
00:24paragraphs in your styles, when in fact, the problem was with the default
00:28styling from a browser, not your style sheet.
00:31Now, to deal with this, and to make it a little bit easier to have pages look
00:34consistent across multiple browsers, many designers use a CSS Reset.
00:40A CSS Reset is typically a grouped selector that simply resets the values
00:45like padding and margin to 0, stripping off all the default values found in most browsers.
00:50So let's go ahead and build one.
00:51Again, this is a page with no styling whatsoever.
00:54You can see the main.css is empty, other than all the headers and the
00:58sections that we have here.
01:00So if I preview this page in my browser currently, I still see styling.
01:03So even though my CSS file doesn't have a single bit of styling in it, my
01:08headings are of certain size.
01:09They are of certain color, there is a certain amount of space between them,
01:12and the paragraphs.
01:13There is a certain amount of space between all my lists and the list
01:16items, things like that.
01:18So we've got a lot of styling going on here, even though we had absolutely
01:20nothing to do with it.
01:21So all these properties are currently being applied from, in this case Firefox
01:26default margins and paddings, and styling.
01:29If you have another browser open, you will be seeing that browser's default styling.
01:32So I am going to go ahead and close this, and we're going to go back and
01:35write our selector.
01:36Now, sometimes it's a little bit easier just to write certain selectors by hand,
01:39and this is one of those.
01:40So I'm going to select my main.css and switch to Code view.
01:45What I want to do is I want to scroll down, and this is another reason why we
01:48are doing it by hand,
01:49I want to find this limited-scale reset content feature because that is where this goes.
01:53So I am going to place my cursor just inside that area, and I am just going to
01:58start by using some of the elements that I know I am going to be using in my
02:01page and some of the elements that I know I am going to be using on my page
02:04that I am going to want to style myself.
02:07So I am going to type in h1, h2, h3, h4, h5, h6.
02:16Now, by the way, I am going to pause here for just a minute.
02:18Most of you probably already know this, but if you don't, the comma is used to
02:22group selectors together.
02:24So essentially, we're saying apply the same styling to the h1, the h2, the
02:28h3, so forth and so on.
02:30They don't all have to be element selectors.
02:32You could put descendent selectors, class selectors,
02:34you can group any selector types together.
02:36It does not matter.
02:37So right after h6 I am going to hit comma again.
02:39I'll do p, address, blockquote, div, ul, li.
02:49Now, you will note that I am not using a lot of elements here.
02:52I know you're probably tired of typing, but trust me there is a lot more that
02:56you can strip this out of.
02:56These are just elements that I know I am going to be using and I know I am
03:00going to style separately in my style sheet.
03:03So I am going to go ahead and open up a curly brace. Hit Return or Enter to get
03:06down the next line, and I am going to type in margin: 0;
03:10padding: 0; and note that I am using code hinting and code completion to help really
03:15speed that process up.
03:16So when I am done typing in margin: 0 and padding: 0,
03:20I'll just close my curly brace, and there is my limited-scale reset.
03:23Now, you'll note here that I'm only doing the margin and the padding. I am not
03:27doing any typography.
03:29I am not doing any line height.
03:30I am not doing any color resets here.
03:32Some resets are extremely detailed.
03:35They will tackle almost every single element you could possibly use, and they
03:38will reset every single property that you probably set for that.
03:42I am not a fan of that.
03:43The reason I'm not a fan of that is because you now have to remember to go back
03:47in and change all the stuff.
03:47Well, let me show you what I mean.
03:49Do a Save All, and preview that in your browser.
03:52You see how all the spacing went away? So the font size is still there
03:58obviously; the color is still there, that sort of thing,
03:59but any type of margins, padding, spacing, gone.
04:03If I want to make sure that my spacing has done correctly, now I have to
04:07write the styles myself.
04:08Well, that's okay because that's what I wanted to do.
04:10But I want to make sure that if I have some type of esoteric tag that I almost
04:14never use but somehow makes it into my site, I don't want to zero that out,
04:18because the answers are, I won't remember that I zeroed it out, and I'll be left
04:22with an element that I am like, hmm, why isn't that styling incorrectly?
04:24So it's a personal decision as to which elements you want to involve in your reset.
04:30It's also a personal decision as to which properties you want to reset.
04:33Do you want to reset font-size? Do you want to reset color? Do you want to reset
04:37margins and padding?
04:38Whatever default value you want to reset, you can go ahead and pass that
04:41into your CSS Reset.
04:42Not every CSS Reset is just one selector like ours is, either. Some of them
04:46are multiple selectors, because they're stripping off properties that not all tags share.
04:50So your CSS Reset might be a lot more complex based on what you are trying to do with it.
04:54So as I mentioned, the downside to stripping all of those default margins and
04:57padding is that now I am going to have to remember to write those styles, and put it back.
05:02So any elements that I know I am going to style of the course of my style
05:04sheets, I'll go ahead and reset those.
05:06Now other elements, I will wait and write specific values for them, if necessary.
05:09But the browser default value will still be available if the element is used in
05:13the page without me realizing it.
05:15Like many things in CSS, the use of the Reset usually comes down to
05:18personal preference.
Collapse this transcript
Writing global classes
00:00For the most part, your style sheets will consist of specific styles targeting
00:04elements on the page;
00:05However, it's extremely helpful to have a global serve classes that can assist
00:09when needing to do common tasks, such as floating elements, clearing floats and
00:14basic elements styling.
00:15These classes can then be used to add styling without needing to write
00:18extraneous markup all the way throughout your styles.
00:21So here I have the main.css, and I want to go down to my global classes sections.
00:27I am just going to scroll down through my sections until I find this one, about line 129.
00:32Now, these are going to be what I consider to be utility styles, meaning I'm not
00:36going to rely on them to do this every single time, but if I'm working and
00:40maintaining my site later on, and all of sudden, I am like, hey, I need to float
00:43this element to left, or float it to right, and I don't want to change its parent
00:47selector, then I'm going to apply the class, alright.
00:49So the first class I want to do is .floatRight.
00:53Notice that's all one word, and the dot is in the front of it because this is a class selector.
00:57I'm going to go ahead and open up my curly brace and come down and choose floatRight, just like that.
01:04So now anytime I need to float an image, or some text, or an element to the
01:09right, and it's not part of my overall stylessheet, I can simply select it and
01:13apply this class to it.
01:14So that's why I kind of think of it as a little utility. I can just go ahead,
01:18anytime I need it, go ahead apply it. Let's keep going.
01:20Let's do a .floatLeft, again notice that I'm preceding that little period,
01:25and for that one I want to choose float, and I want to choose left of the value.
01:29There we go. Let's keep going.
01:32I'm also going to do a .clearRight, and its property is indeed going to be clear right.
01:39Now this is actually a more common need, frankly, than the classes above it.
01:44Anytime we do in a float-based layout, a lot of times you have an element that
01:48you really don't want to wrap around another element, or an element that you
01:51don't want to float above to affect.
01:52Well, if that's the case, then I can just go ahead and apply this, and
01:55again, it's going to eliminate the need for me to have this property as part of the parent class.
01:58Let's go ahead and do .clearLeft, all one word, while we're at it, and indeed do clear
02:05left on this one as well as a property.
02:07So you will notice that these are a single property and very descriptive as to
02:11what they do: clearRight, clearLeft and in case of the next one .clearBoth.
02:15Now, did you see how I left that period off? It's so easy to do when you are hand-coding that.
02:18So always get in the habit of putting those on there. Sometimes, like me, you'll
02:22just kind of forget them. clearBoth,
02:25and now anything that we don't want any floating, left or right, we can
02:29use that class to apply.
02:30We are going to do one more, and here I'm going to go ahead and do .quote and
02:38under that, I'm going to do font style, so font-style, and we are going to do italic.
02:44So those are our global classes, very simple, very easy: floatLeft, floatRight,
02:48clearRight, clearLeft, clearBoth, and the just a quote so when we want to
02:52italicize some text and we don't need to use the emphasis tag, then we will use
02:56a Span tag and apply this class to it.
02:58Now, by no means is that all of the global classes that you can write.
03:02I have seen css styles out there where they have hundreds and hundreds of
03:06lines of global classes that they can apply anytime they need it.
03:10You have to be very, very careful about that.
03:12Global classes can really speed up your site development, but you can also
03:16become too dependent upon them.
03:18Overusing classes is one of the most common mistakes made when writing css,
03:22and it results in a lot of unnecessary code and harder styles to edit and maintain later on.
03:27Imagine that if you want all of yours headings to be a certain color, instead of
03:30just writing a heading selector, you apply that class.
03:33Now, you have got to go in and if you delete the class, really make them, just
03:37really large edits to your styles. Be careful about that.
03:40My advice is to add global classes that won't conflict with any specific rules,
03:45because that's the other thing.
03:46You want to avoid style conflicts, and you can turn to them and use them when
03:50you need that particular styling without having to affect or write a brand-new
03:55parent style for it.
Collapse this transcript
Creating a style guide
00:00Depending upon what type of site you are building, you may want to consider
00:04building a style guide for your site.
00:06A style guide can assist anyone building content for a site by displaying the
00:10visual formatting for your site, explaining how certain styles are executed and
00:15even pointing to online resources to explain how specific techniques work.
00:19Style guides come in many shape and many sizes, and can be customized for your
00:24site's specific needs. And you can see there is a lot of stuff already on the
00:30page, and we're going to take a look at all the stuff in just a moment and
00:33explain kind of how this is structured.
00:35But we need to finish our style guide out, so a lot has been done, but we need to finish it.
00:38So right here the headline says, General Page Layout. I'm going to hit Enter or
00:42Return to create a blank line above that, and that's where we are going to enter
00:46in our content on this page.
00:48So the first thing I'm going to do is I'm going to type in Heading 1, and then I
00:53am going to use my Properties Inspector, make sure I'm on the HTML tab, and I am
00:57going to change the Format from Heading 3 to Heading 1.
01:00I'll hit Return or Enter to go down next line.
01:03I'm going to type in: Used once per page to identify page content.
01:11So you can see we are showing somebody what a Heading 1 looks like, and
01:14then we are telling it how Heading 1 should be used on the pages within our
01:18Explore California site.
01:20I'm going to go down to the next line, and I'm going to type in Heading 2.
01:23I will format that as a Heading 2, again it changes, and just below that I
01:28am going to type in a paragraph: Used for all top level headings not
01:36identifying page content,
01:40again, setting some ground rules for when this should be used. Hit Return to go
01:44down to the next line, and I'm going to type in a Heading 3.
01:47Once again, remember I can grab my pulldown menu here for Formatting and change
01:51that to a Heading 3, and below that, I am going to type in: Used for subheadings
01:58and any headings not categorized as a "main heading".
02:06And then finally I'm going to go to the next line, and I'm going to type in, Not used:
02:12and here we are going to follow our own advice.
02:14So if I have a subheading and any heading not categorized as a main heading,
02:18which I guess this is not a main heading,
02:19that would be a Heading 3.
02:20So I am following my own advice in using the structure of the site.
02:24Go down to the next line, and I am going to type in: Headings 4-6 are not used
02:31in the Explore California Web site.
02:36So this style guide is not just showing you how something should look.
02:39It's telling you about when you should use something, how you should use those
02:42elements, that sort of thing.
02:43So we've just added some headings to the page, and letting people know how those
02:48are supposed to be used and how they are supposed to look like.
02:50You will notice that we also have an identifier that this is the style guide.
02:53This is how our breadcrumb looks, and if we scroll down we can see that we have
02:58some information about the General Page Layout.
03:00This is telling it how pages are typically formatted, what type of accent
03:04images should be used, how our breadcrumb are used, how links should be styled
03:09and used, and things like that.
03:10We also have further explanations about Navigation, Sidebar & Extras, Call Outs
03:15within our main content, table styling, which we turn to Live View we get to see
03:19that's a little bit clearly,
03:22how Lists should be styled: ordered, unordered, definition list. And we have
03:26some information about validation: how we should validate our code,
03:29where our hacks should be placed so that proper validation occurs, that sort of thing.
03:33So there is a lot of information on this page; however, we've left a lot of stuff off.
03:37There is no instructions on how to style forms, to show how those are done,
03:41a comprehensive navigation guide to tell exactly how the navigation should be
03:44done and show it, and things like that.
03:46So obviously, some style guides would be of single page; other style guides
03:50are going to be an entire section of the site, sort of explaining how the site works.
03:54Now I want to highlight on my style guide as an example of this.
03:57Here I have the New York Public Library's online style guide, and you can
04:00find this yourself at legacy.www.nypl.org/ styleguide/, so this is their old style guide.
04:07They left it up here as a reminder for people working on their Web site.
04:11Now, the benefit to this particular style guide was that not only can we sort
04:15of see how the styling works, but you will notice they are giving clear
04:17guidelines as to how you should use things, which document types they are going
04:22to be using, and the benefits of working through them, how to make sure your
04:25XHTML valid, that sort of thing. We have a CSS:
04:28Style Sheet & Tips.
04:30They have guidelines on linking to Style Sheets, Style Sheets that you can use
04:35from the Public Library and CSS Validation.
04:37So this was really made because there are lot of developers and freelancers
04:41that are all not connected at all doing Web sites and pages for the New York Public Library.
04:47Well they all need to look the same.
04:48So this style guide not only gives them access to the existing style sheets,
04:52which they can use for their projects, but it shows them how the documents
04:55should be formatted in terms of this XHTML, the best practices that they should
05:00follow, some places online where they can go and learn more about validation.
05:03It's a very comprehensive style guide, and it's something that, as a designer, if
05:07you are going to work on a project for them, this is godsend to have.
05:09You can come right here and figure out exactly what you need to do with the
05:13content you're creating.
05:14So that's really cool.
05:15Now not every site is going to need a style guide -
05:18the New York Public Library is huge; however, their flexibility in providing the
05:22exact information needed, makes them extremely useful and versatile, regardless
05:27of the type of site that you are building. Now, when working on sites that will
05:30use a development team, or any sort of outside vendors, a style guide can
05:34provide crucial information that ensures content is designed and developed
05:38according to your standards.
05:40Now if you are using a smaller site, style guides can serve as a single-page
05:44overview of your site design, which is nice, and that makes actually a good way
05:48of communicating the design principles you are working with to your client, as
05:52they can just go online and look at the style guide.
05:54Now regardless of how you use them, style guides give you a living, breathing
05:58document that can change as your site changes, and an effective way of
06:02communicating your design and development strategy.
Collapse this transcript
3. Reusing Styles
Preparing custom starter pages
00:00Once you have gone through the process of creating your layout and presentation
00:04styles, chances are that you won't want to do it again to achieve the exact same,
00:08or even similar, results.
00:10As such, finding ways of reusing your styles, whether it's for other projects
00:14for the same client or just a way of reusing the same layout with a different
00:17design, can save you a considerable amount of time.
00:20In this chapter, we are going to focus on techniques in Dreamweaver that allow
00:24you to reuse your CSS and your code for future projects.
00:28We will start by taking a look at how you can create your own custom starter
00:31pages as a way of helping you jump start future projects.
00:35Let's take just a moment to review what it is that we are going to be building.
00:38In Dreamweaver, if you go File and choose New, you can go to Blank Page HTML,
00:43and you have some Preset Layouts that you can choose from.
00:47Notice there are 1 column versions, 2 column versions, 3 column versions,
00:51that sort of thing.
00:52And these are very solid layouts, but from time to time you might create a
00:55layout that you want to reuse over and over again for different projects, and
00:59you might want to go through the same process, stripping out all the
01:02presentational markup, just having Layout Only styles, or being able to rapidly
01:06build pages based off a certain point.
01:09This is a really good way of doing this.
01:10So Dreamweaver also allows us to create our own custom starter pages.
01:14This requires a little bit of know- how in understanding which files within
01:18Dreamweaver you have to update.
01:19So I am going to hit Cancel and just take a moment to take a brief tour of our starter page.
01:23So what we have done here -
01:25now, a good bit of this has already been done - but the strategy and the theory
01:27behind what we are doing here is we are trying to make everything as neutral as
01:30possible, and by that I mean not related to Explore California.
01:33We want a layout that we could use really for anything.
01:36So what I have done here is stripped out a lot of the Explore
01:40California-specific styling.
01:41We are going to talk more about that in just a moment.
01:43But we have also given some instructions.
01:45So we just opened up one of the regular Explore California pages, stripped
01:48things out, started changing things around a little bit, so that we could get a
01:51more neutral layout.
01:52Notice, for example, that we have some instructions in the body copy on how
01:57to do certain things.
01:58We have instructions for the way the header should be treated.
02:01We have instructions for the navigation, instruction for breadcrumbs, footer.
02:06So these are all things that we are basically just passing along to either
02:09ourselves, or whoever might be creating pages based off of starter page in the future.
02:13Now, notice also that the Footer has been changed.
02:16It has been neutralized a little bit.
02:18We don't have that sort of Explore California-specific graphic in the background.
02:22We have sort of descriptive items here for where certain content goes.
02:26You will also notice that the navigation has been changed.
02:28Instead of those Explore California- specific navigation links, we just have
02:32the sample links there.
02:33And if you want to delve in that a little bit more deeply, if I switch over to
02:36the main.css and scroll down to about line say 320 or so, you are going to find
02:42these base navigation selectors, and they have been modified and commented.
02:47So we are telling folks if you are going to use background images for your
02:50navigation instead of text, uncomment that out.
02:53We also have comments explaining how to use the background images, that sort of thing.
02:57So the code has been modified and commented to make things a little bit easier for you.
03:02It's a great recommendation.
03:03If you are going to work with starter pages, you want to add more comments to
03:06your code rather than less, so that you kind of leave yourself or other people's
03:10instructions on how to build pages with that. Okay.
03:13Now, that being said, a lot has been done, but we still have more left to do.
03:17You will notice, for example, that the Header is still the Explore
03:20California graphic.
03:21This image probably will not be available to us when we create starter pages.
03:25Starter pages consist of HTML and CSS.
03:28So links to images are going to show up as broken links.
03:30So we certainly don't need that image there, but we need to be able to represent
03:34that image that's supposed to go there.
03:35So we are going to use a placeholder image for that.
03:38And even though we can't really see it, maybe I am going to collapse my panels
03:41down, so we can see this a little bit,
03:43we still have this background graphic in the background.
03:44It's that sort of gradient that's going down there, and that's really sort of
03:48Explore California-specific.
03:50So those three things we want to go ahead and deal with. Okay.
03:52Let's first turn our attention to this accent image that we have on the page.
03:56I am going to go ahead and select that.
03:57Just click on it one time to select it.
03:59And I am going to Delete it, so Backspace or the Delete key now.
04:02I am going to be very careful about doing this.
04:03When I hit Delete, I am not going to move my cursor at all.
04:06I am going to leave my cursor at exactly where it is.
04:08You can see it's blinking right here.
04:10Then I am going to go up to my Common Objects.
04:12I am going to go to my Insert Images, and grab that pulldown menu, and I am
04:16going to insert an Image Placeholder.
04:18An Image Placeholder is a neat little Dreamweaver device.
04:20It's going to give us a square or rectangle the size of the image that we need
04:24in that place, and we can name it, and even give it alt text.
04:26So I am going to say Image Placeholder.
04:27I am going to go ahead and name the one, accent_image.
04:32It has to be all one word.
04:34I just like being descriptive with it.
04:35I am going to go ahead and give it a Width of 350 pixels, and I am going to
04:39give it a Height of 315.
04:41I could give it a Color as well.
04:42I think I will just stick with sort of a neutral gray color, like this sort
04:45of light gray there.
04:46And then I can give it Alt text if I needed to, but I don't really need to.
04:50So I am going to go ahead and click OK, and now our placeholder image shows up on the page.
04:54Well, it's the exact size that our image is going to be, but we want it to
04:58behave like that image as well.
04:59So I am going to go ahead and select this placeholder image, and the cool
05:02thing about it is I can do anything to this placeholder image that I could do to a normal image.
05:06I could Add a link to it.
05:08I could All Tag it.
05:09I could do all sorts of stuff.
05:10What's really neat is I also have this little Fireworks Create button.
05:13So when I am ready to go ahead and build this graphic, I could double-click it,
05:16or hit the Create button and go out to Fireworks or Photoshop, build the image,
05:19and have it brought back in.
05:20I am going to select this class.
05:22Grab the pulldown menu, and I am going to choose articleImage.
05:24You will notice that it goes ahead and floats, just like the image was doing
05:28before that. Text wraps around it.
05:30And the only thing that's really kind of weird about doing this is notice the
05:33padding actually displays as a gray background.
05:36So you might be tempted to think that the image is really close to the text, but it's not.
05:40Make sure you select it, and double-check that padding to make sure that that is okay.
05:45So that takes care of the actual image tag that was on the page, but it doesn't
05:49help us with these background images that we still have.
05:51So we need to identify the rule that's driving these, and go ahead and make that
05:55rule a little bit more neutral in regards to any type of image.
05:58So we will replace the image with color.
06:01So what I am going to do now is just click inside Explore California.
06:04This way I don't have to hunt down where that rule is.
06:06I am going to go ahead and hold down the Alt key and click on that image.
06:09And on the Mac, you would hold down the Command+Option key to bring up the Code Navigator.
06:12Now, when I bring up the Code Navigator, I notice something really weird here.
06:16I have starter_page, and I have main.css, and they have the exact same cascade.
06:21What is going on here?
06:23Well, this is something very important about starter pages.
06:26The CSS for a starter page must be located in the head of the document.
06:30So it must be using embedded styles only.
06:32Well, all of our styles were moved to an embedded style, but it's still linked
06:36to the external style sheet, as well.
06:38So during the process of creating a starter page, the CSS styles were moved to an
06:42embedded style, but the link to the external style sheet wasn't broken.
06:45As you can see, this could cause a lot of confusion.
06:47What if I edit this instead of this?
06:49That would be a problem.
06:50So before we do any of this, what we are going to do is go right over here to
06:54the CSS Styles panel, highlight the main.css, and then just click the Trashcan icon.
06:59Now remember, don't have an individual rule selected, have the actual CSS selected.
07:04Click the Trashcan icon one time.
07:06Clicking it repeatedly will result in other things being taken away, and
07:10you don't need that.
07:11We also don't need the link to the print style sheet, so we are going to Delete that, too.
07:14Don't have any links to external style sheets in your starter pages, because
07:18it's going to be document-relative, and you might not use the same naming
07:21conventions or even locations for styles in the next project. All right.
07:25So now all we have are embedded styles.
07:27That's going to make life a little easier.
07:28Let's come back to our header graphic here.
07:30Again, I am going to Alt+click this or Command+Option click, depending upon my platform.
07:35And we have two header selectors.
07:37The first one gives positioning, height, that sort of thing.
07:40The second one is giving the background image.
07:42That's the one we need to edit.
07:44So I am going to go ahead and click on that, and that's going to give me the
07:47sort of Split Screen View.
07:48I am going widen that up just a little bit.
07:50And sometimes when you widen it, you have to scroll back up a little bit, but that's okay.
07:54So about line 238, I see the #header background URL.
07:57I am going to change that.
07:58I am going to highlight the entire property, which is the link to the external
08:02graphic, and I am just going to go ahead and change that to a color.
08:06So I am going to type in #193742, and now if I click back in Design View, the
08:14graphic goes away, and the color just shows up.
08:17So that's replacing the graphic with sort of a relatively neutral color, that
08:21dark blue color, and when I create a brand-new page off of this, I will know to
08:24go in there and edit that and switch that out with the graphic.
08:28Now, how would I know that?
08:29Well, I would know it because I created this page, but somebody else
08:31wouldn't, would they?
08:32So one of the things that you can do for people, if you really feel like being
08:35nice to them, and I am going to use the Code Navigator to navigate back up into
08:38my styles, is it's not a bad idea to go ahead and add a comment to this.
08:42And you can comment things out any number of different ways.
08:45I like commenting them out like this, right beside the property.
08:47So I can just hit space and type in: replace color with background image.
08:57And it wouldn't hurt to let somebody know what size that image needed to be, as well.
09:01So I can go up here in the header and find that the height is 237px. The width is 192.
09:08So we are 192 x 237.
09:11I found my other header, and I am going to say 237px x 192px, and I am going to
09:20highlight that, wrap it with a CSS comment, and now anybody building a page off
09:25of this will at least have some instructions on how to deal with that.
09:27Now finally, we need to do the body tag.
09:29I am going to move up to the body tag.
09:31You will notice that the body tag is also using a background color and an image.
09:35I think color is a little too specific for this site, so I am going to go
09:38ahead and highlight that.
09:39Make it a little bit more neutral by doing #333, which is a gray, almost black,
09:44and as soon as I do that, if I switch back to Design View, I can really see that
09:47all the way around the edge, just that sort of dark color.
09:50So I am going to go ahead and save that, preview that in my browser, and now I
09:54can see there is really no Explore California-specific stuff anywhere. Neutral colors.
09:58We have our Image Placeholder going on.
10:01We have sort of the Header area, right here,
10:03that doesn't have an image in it.
10:04This page is ready to go.
10:05So the last thing that we need to do to this page in order to make it a starter
10:08page is to give it a descriptive name.
10:10So I am going to go to File and choose Save As, and save in the 03_01 folder,
10:15and I am going to save it as 2ColExplore.htm, so 2ColExplore.
10:26So this would tell somebody it's a 2 column layout.
10:27It's based off of the Explore California Web site, or theme, or whatever you were doing.
10:31You just want to be really descriptive with the name, or at least as descriptive
10:34as you can be within that.
10:35So I am going to go ahead and Save that, and we are ready to move on to our next exercise.
10:40Now, in this case, our page had to undergo really extensive changes before we
10:45could use it as our started page.
10:46You could tell by all of the stuff that was already done.
10:48The goal of saving a starter page is to have a neutral page layout that's not
10:52dependent upon any specific images or content.
10:55Now, in the case of the Explore California site, the one that we have been
10:57working on, this required us to pay attention to the page navigation, background
11:02images, and element styling to make sure we stripped away enough specific
11:05content to create an effective starter page.
11:08I would really recommend going and checking out a version of the Explore
11:11California page in one of the other Exercise Files, and comparing it to the
11:15starter page and looking at the changes that have been made, so that you can
11:18sort of understand some of the decisions that were made as well. Okay.
11:21So now we have got a neutral page, with the desired layout and structure.
11:25Now, we need to let Dreamweaver know that we want to use this as a starter page,
11:29and we are going to do that in our next movie.
Collapse this transcript
Building custom starter pages
00:00Now that we have built a custom starter page, the only thing left for us to do
00:03is to let Dreamweaver know that our new page is the starter page.
00:07To do that, we will need to copy our page into Dreamweaver's
00:10directory structure.
00:11Although we could stop there and still have the functionality we want, we are
00:15going to take our starter page a little bit further by adding a preview image
00:18for it, and passing along some descriptive information for our page in
00:22Dreamweaver's New Page dialog box.
00:25Now, I have Dreamweaver open right now, but no individual file open.
00:28And for what I need to show you guys now, we are going to have to go exploring
00:31through our hard drive.
00:32So I am on a PC. The location of the files for me is going to be a little
00:35different than for any of you guys that are on the Mac, but once we get into the
00:38folder, the location is exactly the same.
00:40So what I am going to do is go down to my Start menu, and I am just going to go to My Computer.
00:44I am going to go to my Local Disk.
00:47Now, I am going to go into my Program Files (x86). I'm on my Windows 7 here.
00:52Any version of Windows you are going into Program Files.
00:53Now on the Mac, you are going to go into your Application Directory.
00:56From there, we are going to go into Adobe, and we want to go to Dreamweaver CS5.
01:02Inside Dreamweaver CS5, we want to go into configuration. All right.
01:07So once again, you want to find the Adobe folder inside either Program Files or
01:11your Application's Directory, if you are on the Mac.
01:13Go in the Dreamweaver CS5 folder/configuration.
01:17Now, once you are in configuration, it's the same for all of us.
01:20We want to go into BuiltIn and Layouts, BuiltIn and Layouts.
01:25So let's examine what is here.
01:27So we see oneColFixCtr.htm, oneColFixCtr.png.
01:34We see that sort of pattern repeated over and over again.
01:37As a matter of fact, if you go to Dreamweaver and choose File > New > HTML, you
01:42can quickly and easily see what those files are:
01:452 column fixed, left sidebar, 1 column fixed, centered.
01:49So again, returning to our folder.
01:51That's exactly the structure we are seeing here.
01:52So these are the actual layout files: an HTML file followed by a PNG.
01:56Now, the PNG is the actual preview file.
01:58You can see here, for example, that we see a preview for each one of these guys.
02:02That's sort of descriptive as to what the page is all about. Okay.
02:06So in order to make ours work, we need to have a preview file, and more on that
02:10in just a moment, and then the HTML file that we created in the previous
02:14exercise, and they all need to go in this folder.
02:17Now, that would be all well and good, and it would still work, but all of this
02:21information that I am getting in the dialog box here, where I have a description of
02:25it, and that sort of thing, I wouldn't be able to get that unless we somehow let
02:29Dreamweaver know that we have a new starter page, and this is the description
02:32for it, and this is the preview that we use for it, that sort of thing.
02:35So how do we do that?
02:35Well, let's go back into either our Finder or Explorer window here.
02:40I notice that there is also another folder here called _notes.
02:44When I open that up, I see that we have some text files that also follow that
02:49same naming convention.
02:50Notice that it says oneColFixCtr.htm.mno.
02:56MNO is a Macromedia notation file.
02:59It takes you a little bit further back before Adobe and Macromedia merged.
03:04But this is basically an XML file.
03:06It's an XML file that describes to Dreamweaver where the starter page is, what
03:10its name is, what preview image to use for it.
03:13So if you want to pass along that same information, you are going to need to
03:16pass that information on to Dreamweaver.
03:19The best way to do this, honestly, is instead of trying to write your own, take
03:23one of the existing ones and just change it.
03:25So I am going to click on any of these.
03:27I will just take this twoColFixLt.htm.mno.
03:30Anyone of these would work for what we are doing.
03:33Now, what I am going to do is I am going to right-click this or Ctrl+Click it,
03:36and I want to Edit it with Adobe Dreamweaver CS5.
03:39So even if that's not your default, based on your installation, like mine, you
03:42want to edit this with Adobe Dreamweaver CS5.
03:45You can open this up in Notepad, or WordPad, or TextEdit; any Text Editor would work.
03:49We might as well open it up in Dreamweaver as well, so that you edit with
03:52Adobe Dreamweaver CS5.
03:54There is our file open.
03:55Now, I don't want to close this window just yet.
03:57I am just going to minimize it, because we are definitely going to be
03:59coming back to that. All right.
04:00So this is an XML file.
04:03It's pretty easy to determine exactly what's going on here.
04:05Notice that we have a tag called infoitem, so information about the item.
04:08We have a key attribute that basically tells Dreamweaver what type of
04:12information is being passed.
04:14So document type, it's a layout document, what the name of the document is, the
04:18description of the document, and preview.
04:20Now, currently it's pulling all these information sort of dynamically from a function.
04:24It's running a function, and it's passing in these literal string values to the description.
04:28And that's going to basically take script that is writing the descriptions and
04:33populate them with what we see here.
04:35Now, what's really nice about this is you don't have to know all this.
04:39You can just type in a literal value for all of these.
04:41So what we are going to do is we are going to go ahead and save this.
04:43Let me go to File and choose Save As.
04:46We definitely don't want to overwrite this.
04:49So we just want to do Save As.
04:50We also want to make sure we are saving it in the same directory.
04:52So again, notice that you are going to go either in Program Files or your
04:55Application Directory, depending upon which platform you are on,
04:58into Adobe > Dreamweaver CS5 > configuration > BuiltIn > Layouts, and _notes.
05:03I know it's long, but you want to double-check that, okay? Okay.
05:07Now, what we are going to do is we are going to name this the exact same thing
05:10that our starter page is named.
05:12That's helpful for a lot of reasons.
05:14It looks for this document to be named the same as the starter page itself.
05:17So you want to make sure they are exactly the same.
05:19I am going to type in 2ColExplore.htm.mno.
05:28So again, the exact same name that we named our document
05:31earlier, 2ColExplore.htm,
05:34you want to follow that.
05:34So you want to make sure it's case-sensitive.
05:36And at the very end of it, there is going to be mno.
05:37So I am going to go ahead and save that.
05:39So now we have our own note object inside of that folder, and now we can pass
05:43the values that we want for it.
05:45So, for example, right here, the new document name, I am going to take
05:49the literal string that they have here, and I am going to replace it with 2ColExplore_theme.
05:58Now, you can pass in spaces and punctuation here. It's okay.
06:03I just kind of like that nice, compact explanation.
06:05It's a 2-column Explore theme layout.
06:08Now, we need to give it a description.
06:10The description can be a lot more descriptive.
06:12So again, I am going to highlight the literal string value, and inside this, I
06:15am going to type in Explore theme - to let them know it's from the Explore theme -
06:19fixed width, 2 column, badge header, large footer.
06:34So we are being a little bit more descriptive there.
06:36Now, the preview is something that we need to change as well, and I want to talk
06:39about that for just a moment.
06:41You can look over in the Files panel, and I will expand this a little bit so you can see it.
06:45We have a PNG file that's already been saved, 2ColExplore.png.
06:49Now, how did we get that?
06:50What I did was I took one of the Explore California pages, previewed it in the
06:53browser, and took a screenshot,
06:55took it back into Photoshop, or Firework,s or whatever image editing program you
06:58like, and cropped it down.
07:00It has to be a specific size.
07:02It has to be 227 pixels wide, 193 pixels tall.
07:08As soon as you have that, you can save it as a PNG file, as a JPEG, as a GIF;
07:12any of those will work, but I saved this one as a PNG file.
07:15So I am going to highlight the value for the PNG file here and change that, as well.
07:18I want it to be exactly the same as this.
07:20So here I am going to type in 2ColExplore.png. Okay.
07:27So it's case-sensitive.
07:29You want to check your spelling there. Make sure that's right.
07:31Make sure everything is the way that you need it to be.
07:34So our note file is finished.
07:35I am going to go ahead and Save that and Close it.
07:39You want to go ahead and exit out of Dreamweaver.
07:41I am just going to go to File and choose Exit.
07:43Whenever you are adding a new starter page, Dreamweaver needs to refresh that cache.
07:48One way to force it to do that is to close out the program and then open the
07:52program back up again. Okay.
07:53I want to go and open up my _notes folder.
07:57I am just going to hit my Back button, so that I am back into the Layouts folder.
08:01So you want to be in the configuration folder of Dreamweaver, in the BuiltIn
08:04directory, and in Layouts.
08:06Then in another window, I am going to open up my Exercise Files.
08:09This is the folder you can find on the Desktop.
08:11I am going to open up Chapter_03, got into 03_02, and find those two files.
08:17That's the 2ColExplore.htm file that we created in the previous exercise, and
08:21this is the preview.
08:22So I am going to grab both of those guys, and I am just going to Copy them.
08:25I like doing copying instead of moving.
08:28That way I have got the originals if I ever need to make changes to them, or if
08:31something doesn't work, I can kind of open them up and see what's going on.
08:33I am going to go ahead and copy them to layouts folder. There they are.
08:36I will close that. Close the other window.
08:39Now I can launch Dreamweaver again.
08:43All we need to do to check to see if this works is go up to File and choose New.
08:48Now when we go to Blank Page > HTML, you can see right here, we have our
08:51new 2ColExplore_theme.
08:52When I select that, we see the preview image of the page design.
08:58So you can make this a little bit more descriptive than sort of their generic layouts.
09:02So there is that.
09:03Notice that here is our description: Explore theme, fixed width, 2 column, badge
09:06header, large footer.
09:07So again, you could be as descriptive as you want.
09:10We get the option of Adding the CSS to the Head of the document, Creating a New
09:14External CSS File, Linking to an Existing File.
09:17We can use any Document Type we want.
09:19This is a really cool way to reuse your code and extend the life of these
09:23layouts that you are creating.
09:24I will go ahead and create my page, and here is my starter page.
09:28So if I go over to Design View, there is the starter page that we worked on.
09:32All the CSS is in the head of the document, as we asked it to.
09:34Although, we certainly could have placed it an external style sheet.
09:37So one of the main attractions to using these starter pages is they aren't
09:41tied to a specific site.
09:42We have a natural starting point now for working on new projects based on this layout.
09:46They can be extremely detailed, with a lot of content styling already completed,
09:50or if you would like, they can also be really, really basic, with just a
09:53rudimentary layout, no presentational styling at all.
09:56How you use them is totally up to you, but by creating a series of starter pages
10:01with pre-built layouts for your projects, you can extend Dreamweaver's power and
10:05functionality even further.
Collapse this transcript
Working with code snippets
00:00Another extremely effective way of reusing code in Dreamweaver is through the
00:04use of Code Snippets.
00:06Code Snippets allow you to store any code, whether it's CSS or HTML, in your
00:10Snippets library, and then reuse that code at any time.
00:13For CSS, this allows us to build libraries of formatting, layout and
00:18presentation styles
00:19that can speed up the process of building complex style sheets.
00:23In this movie, we're going to examine how Snippets work as a way of sort of
00:26preparing ourselves for using them with our CSS later on.
00:30Before we build any snippets, we need to take a brief tour of the Snippets panel.
00:34So in our CSS workspace, we have the Snippets panel docked with the Files panel.
00:37That's typically where it's found.
00:39If you don't see the Snippets panel, you can go to Window and choose Snippets,
00:44right there, and it'll activate the Snippets panel.
00:46Now I'm going to double-click the CSS Styles panel to collapse that, so I have a
00:50little bit more room for the Snippets panel.
00:52Okay, so the Snippets panel comes with some pre-built snippets
00:55already built-into it.
00:57You can see that those are categorized.
00:58We have some Comments.
01:00We have Footers, Form Elements, JavaScript, so area conclusions, browser functions.
01:06So this is not just for HTML and CSS.
01:07This is also for JavaScript and really any code that you write.
01:11Well, you're free to make your own Snippet folders, and you're free to save your
01:15own Snippets inside of them.
01:16So I'm going to go down to the bottom right-hand corner of the Snippets panel.
01:20I see a little folder icon there.
01:22I'm going to go ahead and click on that.
01:23That's going to create a New Snippet Folder.
01:25Now one of the things I've always be kind of frustrated about with Snippets
01:27folder is I always forget where I'm focusing.
01:30You can see what this did.
01:31As soon as I click this, because I have the Comments folder highlighted, it
01:35placed it inside of this.
01:36So I'm just going to go ahead and name this snippet Structure.
01:39Don't worry if yours is not in this.
01:42Frankly, mine is not supposed to be.
01:43But the good thing is about this is it shows you that you can nest these folders
01:47inside of each other.
01:48So you can create some pretty complex structures out of this.
01:51Okay, I'm going to go ahead and move that out, so that it is a top-level folder itself.
01:56What am I going to do next,
01:57now after creating Structure, I'm going to go ahead and create a
01:59brand-new Snippets folder.
02:01Here, I'm going to call this one CSS.
02:04So we have one for HTML Structure tags, and then we have another one for CSS.
02:08Now you can create snippets in one of two ways.
02:10One is you can create a Snippet from scratch yourself using the Snippets panel,
02:14or a option two, which is probably the more likely option, is you're going to
02:18take existing code that you already have in your styles, or your HTML, and then
02:22save that as a Snippet.
02:23Well, let's examine option number one.
02:25I'm going to go and click on the Structure folder, so that it's our active folder.
02:29That insures that any snippet that we create is going to be placed inside that.
02:33As you can see, it allows you to rename folders, as well.
02:35Snippets panel is really sensitive.
02:37So be careful about clicking in and around it a lot.
02:39So I'm going to go and create a brand-new Snippet.
02:41I'm just going to go ahead and name this Snippet,wrapper div.
02:45Now in almost every single Web site I create, I create a wrapper div tag that
02:50sits inside the body tag.
02:52That helps me center the content on the page, if that's what I'm wanting to
02:54do, and give definition to the page. Use a position attribute of relative on
02:59that, so that anything positioned will position inside the wrapper and not the body tag.
03:03So it's something that I'm going to do almost every single time.
03:05So what I'm going to do now in the Description,
03:07I'm just going to type in description of what this snippet is going to do, sort
03:10of describe its functionality.
03:11I want to say, Inserts a wrapper div tag around selected elements.
03:19So I'm very clearly stating that this is going to insert a wrapper div tag
03:23around selected elements.
03:25Notice that that directly plays into the type of snippet that we can create.
03:29We can do a Wrap selection or Insert block.
03:31Wrap selection will go ahead and wrap an opening and a closing section of code,
03:36and it can be a little code or it can be a lot of code, around whatever code you have selected.
03:41Insert block is just going to take that block of code and insert it into the
03:44location where you are on the page.
03:46So it's not going to do any wrap.
03:47So we want this going to wrap the selection.
03:49In the Insert before, I'm just going to write a div tag.
03:52I'm going to say <div id = "wrapper">, and then I am going to close my opening tag.
03:58Then Insert after, I'm just going to go ahead and close the div tag.
04:01Now you'll notice we're not getting any code hinting or code completion here.
04:03So you've got to be certain of what you want to do.
04:06Syntax matters. Spelling matters. Whitespace matters.
04:08You want to be very, very careful when entering code into these panes.
04:12So again, I would say Wrap selection and Insert block in.
04:14Notice that the Preview type can either be Code or Design.
04:18Now when you click on a Snippet in this area of the Snippets panel, you'll see a preview of it.
04:22I really like just seeing the Code, so I can read the Code and know what
04:25I've got going on there.
04:25I'm going to go ahead and click OK.
04:27There is our wrapper div.
04:29As soon as I click on that, it says div id= wrapper and then close the div.
04:33So it's giving me a little summary of what this Snippet is all about.
04:35If I expand my CSS Styles panel by clicking right there on a divider, I can also
04:40see that right over here is the Description for that.
04:42So anytime I have a Description for a Snippet, when I select it, I'll be able to
04:45see that in the Description area. Okay.
04:47Let's take a look at how we can use these Snippets.
04:50So now what I'm going to do is click anywhere inside my page, and notice that
04:54I'm not even in Code view, so you can use Snippets in Design view. It's okay.
04:57Going over here to the Tag Selector, I'm going to click the body tag.
05:00That's going to highlight everything inside the body tag, so all the content on the page.
05:05It's a very easy way to do a select all.
05:06I'm going to go over to my wrapper div tag, and using a snippet is as easy as
05:10double-clicking on it.
05:11I'm going to go ahead and double-click that.
05:13Notice as soon as I do that, I have the div with an id of wrapper.
05:16If I do switch to Code view, notice that there is the opening wrapper div tag,
05:20and there is the closing wrapper div tag.
05:22So it went ahead and wrapped all of the code on the page, so a very quick and
05:25easy way to do that.
05:26Now what about CSS?
05:28How does working with Snippets benefit us when we're working with our
05:31cascading style sheets?
05:32Well, I'm going to go back to the Files panel, and in the _css folder, I'm going
05:36to open up main.css, of course.
05:38Notice that this is the style sheet for the Explore California Web site
05:42that we've been using.
05:42What I'm going to do now is when I scroll down to my line 80, and find the h1 tag.
05:47I am going to go ahead and highlight the whole tag.
05:49Make sure that you get the opening curly brace, the closing curly brace, the selector.
05:52You want to make sure you have all of this selected, because when you create a
05:55snippet based off of your selected code, what's going to happen is everything
05:58inside the highlighted area will be converted to a snippet.
06:00If you leave something off, then that snippet is going to cause you so many
06:03problems a little bit later on down the line.
06:04All right, so I have that selected.
06:06There are so many different ways to create a snippet.
06:08I can go back over to the Snippets panel and click the New Snippet icon.
06:11That'll be the one way to do it.
06:12Another way would be to go ahead and right-click, and you can also Ctrl+click if
06:17you're on a Mac, and I'm going to choose Create New Snippet, right there.
06:20Now as soon as I do that, I get the dialog box that we were just looking at when
06:23we created our wrapper div tag snippet.
06:25But notice that this one is pre-populated with the h1 selector that we had highlighted.
06:30So that's really cool.
06:31The Name of this one, I'm going to go ahead and call this one h1.
06:35That's fairly descriptive right.
06:37In the Description section, I'm going to type in Explore California h1 selector.
06:46This time, instead of having the Snippet type be Wrap Selection, I want it to be Insert Block.
06:50Notice that we lose our double pane down there, and we just get the one section of code.
06:54Now here is the other thing.
06:56I can modify this. If whatever reason I've left off that curly brace,
06:59I'm free to go ahead and type that now.
07:00I'm going to keep the Preview type as Code, and I'm going to click OK.
07:04Right now, we didn't really see anything happened.
07:05But if I switch over to my Snippets panel, I can see right there that the h1
07:10showed up in the Structure.
07:11Now why did it show up in the Structure folder?
07:12Oh, that's why I had highlighted, because that's what we were using just a minute ago.
07:15So if for whatever reason,a snippet goes in the wrong folder - and trust me
07:19it will happen to you,
07:20the Snippets panel is really sensitive -
07:22it's okay because you can simply grab your snippet, and then just drag it into
07:26the folder you want.
07:27So you can do that anytime.
07:28You're going to rearrange entire folders, individual snippets within folders or
07:32whatever you'd like to do.
07:33It just does not matter.
07:34Now I want to show you one last thing before we move on to discussing strategy
07:38for using Snippets within your CSS.
07:40You can assign keyboard shortcuts to Snippets that you need to use all the time.
07:44So if you're rapidly building pages, it'll be really nice to go ahead and have
07:47keyboard shortcuts assigned for these.
07:49So I'm going to go to the h1 snippet, which is right here, right-click or
07:52Ctrl+click that, and I'm going to choose Edit Keyboard Shortcuts.
07:55Now you can also go up to Edit and choose Keyboard Shortcuts, as well.
07:58If you're on the Mac, you can go to Dreamweaver Keyboard Shortcuts, and you will
08:01see the exact same panel.
08:03Now you don't want to modify the Dreamweaver Standard keyboard shortcuts.
08:06So I'm going to go ahead and make a new one.
08:08I'll just say Duplicate Set, and this comes up.
08:11I'm just going to call these my shortcuts.
08:14You can call them whatever you want.
08:15You're free to create as many of these as you would like.
08:17So you might create a set of keyboard shortcuts to use only when you're doing Snippets.
08:21So it's totally up to you.
08:23All right, now we want to modify our Keyboard Shortcuts.
08:26What's really interesting about this is notice that we've got our commands for Snippets.
08:30We can go to menu commands or all of those, but Snippets has their own category.
08:33Inside Snippets, I'm going to open up the CSS and choose the h1.
08:36Now I'm going to go ahead and give this a keyboard shortcut by clicking in the Press key.
08:41I'm just going to do Ctrl+Shift+1.
08:44Now you'll notice that the keyboard shortcut is already assigned to Align Left.
08:48You know what? I never use that keyboard shortcut for Align Left. So don't panic.
08:52If you see something that you want to do, and Ctrl+Shift+1 is the easy one to hit.
08:55If you see something like that, and then Dreamweaver says, oh, I'm sorry.
08:58This is already taken by Align Left or Align Right.
09:01Well, if you're never going to use it, what do you care?
09:03So I'm just going to hit Change and Dreamweaver further scolds me about it. I'm like no, no.
09:08I'm really serious about that.
09:09Then I am going to go ahead and click OK.
09:11Now anytime I wanted to, I could add the selector again just by using
09:16the keyboard shortcut.
09:17Let me show you what I mean.
09:17I'm just going to highlight my h1 selector again.
09:20Make sure you're in the Code view. Delete that.
09:22Then I'm just going to do Ctrl+Shift+1.
09:24There is my h1 selector.
09:26So if you have a lot of those in your library, or even whole sections of styles,
09:30you can really rapidly build pages.
09:32It doesn't matter whether you're working with HTML CSS or be even something like JavaScript.
09:37If you write a lot of code, I think it's pretty easy for you to see how much
09:40Code Snippets can help speed up your workflow.
09:43Now that we know that working with Code Snippets can help us reuse our CSS,
09:46we need to discuss strategies for working with CSS and Code Snippets.
09:51That is going to be the focus of the next movie.
Collapse this transcript
Writing snippets
00:00Using snippets to reuse CSS code requires a good deal of planning to build a
00:04strategy around how your code will be reused and how much of your layout and
00:09presentation will be saved in your Snippet library.
00:12In this movie, we'll begin to build a small-scale CSS Snippet library that can
00:17be used over and over again for other projects.
00:20To do this we'll need to examine our current site, evaluate elements or
00:24structures that we could reuse in other projects, and then modify existing CSS
00:29rules to create a more neutral snippet version of them.
00:32And if you were to really take a look at this layout, you would call it a
00:36two-column layout. The header, instead of panning the entire width of the page,
00:39is really just a small little area.
00:41It could be a badge, or a banner, or something of that nature.
00:45The main content fills up the entire right side of the page, and we have a
00:49footer at the bottom.
00:51Everything else, in terms of the colors being used, the graphics being used to
00:56the way that the navigation is structured, is really designed specifically for
00:59the Explore California Web site.
01:01So unless we were going to have to reuse these snippets in order to build more
01:05pages for the Explore California Web site, it really wouldn't make a whole lot
01:08of sense to use the existing CSS to build snippets.
01:11We need to modify them a little bit more, and make them a bit more neutral.
01:16Now that way any time I wanted this particular layout or even color schemes and
01:19things like that, if I want to keep those, and typography, I could save those as snippets.
01:23So what I'm going to do is I'm going to go over to my Files panel.
01:28I'm going to go into the 03_04, which is my root directory here.
01:32Open up the _css folder and open up main.css.
01:36Now yes, we can access the code from here, but we need to do something
01:38very special with this.
01:39I'm going to go to File and choose Save As.
01:42I'm going to save this in the same folder, the _css, and I'm just going to call
01:47this one snippet_source.css.
01:51So, snippet_source.css.
01:53Now why are we doing this?
01:54Well, as I mentioned before, we're going to have to modify some of these styles,
01:57some of them quite extensively.
01:59The last thing in the world you want to do is make changes to your site's CSS
02:03file when you're building your snippets.
02:05You want to leave that alone.
02:06So we're just creating a copy of this.
02:08I'm going to close the main.css that we had opened and focus on my
02:11snippet_source file.
02:12Now the next thing I'm going to do is go to my panels and click on my Snippets
02:16panel to activate that, and sort of expand that out a little bit more.
02:19I really like being able to see this panel, read some of the descriptions and
02:22tell what's going on here.
02:24Okay, so the first thing that we're going to take a look at is our global constants.
02:28As I scroll down a little bit, I get down to about line 43 in my code,
02:31I can see some constants that are going to be used kind of over and over again.
02:35To be honest with you, this is one of the selectors that I have at the top of
02:38almost every single one of my style sheets.
02:40It takes a default margin and the padding for documents in different browsers,
02:44and just sort of zeros them out, so that you can do with them what you want.
02:47So we've other ones like the body tag that we could reuse, our limited-scale
02:51reset, so we've got some pretty generic global classes and constants in here
02:55anyway, so we could go ahead and start our CSS Library based on those.
03:00Now I'm going to go over to our Snippets panel and clean up some of the stuff
03:03that we've been working with before.
03:04I'm going to go inside that CSS folder,
03:07click on the h1 selector that's currently sitting in there
03:09and I'm just going to delete that by clicking the Trash Can.
03:11So anytime you want to delete a snippet, just highlight it.
03:14Click the Trash Can.
03:15It says, Are you sure you want to delete it?
03:16I'm going to go and say, Yes, and now my CSS folder is empty again.
03:20It's empty because I want to give it a little bit more structure than what they've got.
03:24So I'm going to click on the CSS folder to activate that folder, create a
03:27brand-new snippets folder, and I'm going to go ahead and call this one Global Constants.
03:33Now sometimes you could have snippets that relate to a specific layout, so we
03:38can create an Explore California theme, for example, and have snippets related
03:41just to this particular layout.
03:42You can also have snippets that could be used for really any site, and Global
03:46Constants really fits that bill.
03:47You could have snippets that you use anytime you create a project.
03:50You can just create and start putting some of these things in here.
03:52Okay, so I'm going to go back over to my snippets_source.css.
03:55Highlight the html in the body selector.
03:57Once again, make sure you get the opening and the closing curly brace, as well as
04:01the selectors itself.
04:02I'm going to go ahead and either right -click or Ctrl+Click that and choose
04:05Create New Snippet, and I'm just going to go ahead and call this snippet html & body reset.
04:15You can name snippets anything you want.
04:17You want to be a little descriptive, but you don't want to be the overly long.
04:19And for the Description, I'm going to type in: Resets the default browser page margins.
04:29Again, the Snippet type is going to be Insert block.
04:31Whenever you're dealing with CSS-based snippets, you're always just going to
04:34insert the block of code.
04:36CSS doesn't work that way.
04:37You are not going to wrap code with it.
04:38I'm going to have my Preview Type be Code and again, I'm going to double-check
04:42the style, make sure everything is in its right place - it is - and go ahead and click OK.
04:46So now over in my Global Constants, I've my html & my body reset. Excellent!
04:50Now I'm going to go down to the body tag, and here I'm going to create a couple
04:54of different versions of this body tag.
04:55So I'm going to go ahead and copy this and then paste it on a line below it.
04:59So now we've two body selectors, two body element selectors, and we're going to
05:04change up a few things in it.
05:05First off, we're going to take the margin top and get rid of that.
05:08That margin top is very specific for the Explore California Web site.
05:11If we were creating just some generic body tags that we can use on any site that we want,
05:15we're going to go ahead and take things like that away.
05:17Now the next thing I want to do is the top body tag is using Georgia, Times New
05:21Roman, Times, and serif.
05:22It's a font stack I use a good bit, but it's not always the font stack I want to use.
05:26So what I'm going to do is on the body selector below that, I am going to go
05:30ahead and replace that Georgia, Times New Roman, Times, serif.
05:32So I'm going to go ahead and delete that, and then I'm going to type in ar, and
05:36it actually gives me, Arial, Helvetica, sans-serif.
05:37Now remember you want a space between the % for size, and Arial,
05:42Helvetica, sans-serif.
05:43Okay, so now we've two body tags, one using Georgia and one using Arial.
05:48We're going to go ahead and add them to our CSS Library.
05:51So I'm going to highlight the first one.
05:52Now, we want to do these individually.
05:54So I'm going to highlight the first one, I'm going to right-click that and
05:57choose Create New Snippet, and I'm just going to go ahead and call this
06:01one, body 100% Georgia.
06:06And that way I can scan these body tags here.
06:09So I have got some body tag selectors, 100% font size and Georgia.
06:12And for description, again, I can be a little bit more descriptive here.
06:14I'm going to say, Neutral body tag, meaning no margins associated with it
06:19or anything like that,
06:20100% font size, Georgia stack. For me that short for Georgia font stack, you
06:29could be a little bit more descriptive there if you'd like. And that's good.
06:32Now I'm going to look at everything here to make sure everything is okay, and
06:35everything is not okay.
06:37What I left in there that I didn't mean to leave in there was the background.
06:41So here's the beauty of the Snippet dialog box.
06:42I'm going to click on the Insert block and then this background part, I'm just
06:46going to go head and get rid of it.
06:47I can even adjust my spacing by moving those guys up.
06:49So you can edit in your Insert Code dialog box the same way that you could code
06:54within the CSS Style panel.
06:56So that's pretty cool.
06:56So I'm going to go ahead and click okay, and it creates that.
06:59Now notice how it doesn't affect the style in your CSS.
07:02So if you do have a selector that you need to make slight modifications for, but
07:05you don't want to disturb it in the native style sheet,
07:08you can go ahead and create a snippet and just make your edits in that little
07:11window, and you'll be okay.
07:12All right. Now, I definitely don't need it for my next one, so I'm going to remember
07:15go ahead and get rid of that.
07:16I'm going to highlight it, create a new snippet out of this, and I'm going to
07:20call this one body 100% Arial, since we're using Arial as a font stack, and
07:27for the Description, I'm going to type in: Neutral body tag, 100% font size, Arial stack.
07:42And you always have to remember to do Insert block, the default is Wrap selection.
07:45So if you keep doing CSS snippets over and over and over again, keep in mind
07:49that you're going to have to continually insert that block.
07:51I am going to go ahead and click OK.
07:53Now you'll notice that the way that these guys are stacked up, it's really easy to scan this.
07:56It says, body 100% Arial, body 100% Georgia.
07:59You might be wondering, why don't I just name it body1 and body2 and let the
08:03Description tell me what it's doing?
08:04Well, you can see I've got my Snippet panel really extended to see
08:08the description at all.
08:09More than likely, you're going to view your Snippets panel like this.
08:11So you want those names to be descriptive enough to where you know which one
08:15you're going to use for a given situation.
08:17Now let's do one more.
08:19I am going to go down to the limited- scale reset, and I'm going to go ahead
08:22and highlight that.
08:24Remember, you can choose to add the comment as part of this, as well,
08:28if you think you'd always want to put a comment above that, which I think is a
08:30pretty good idea, actually.
08:31I'm just going to go ahead and highlight that as well, and Dreamweaver can be
08:34really tricky sometimes when we're highlighting this code.
08:36So double-check that you've got the comment before it and the closing curly brace.
08:40We're good there, and then I'm going to go ahead and create a new snippet.
08:43Now you can also simply highlight your text, instead of right-clicking, you can go right over to
08:47the Snippets panel and click right there on New Snippet, and as soon as you get
08:51that, the Name comes up, and we're just going to call this one limited reset, limited reset.
08:57Now I don't like the way that these guys are all on separate lines, so I'm just
09:00going to take just a brief moment to bring them all back on one line.
09:04I probably could have done that in the code using my AutoFormat Options, but this
09:08is not that strenuous.
09:10So we're going to go ahead and do that for each one of these guys, get them all
09:12up in the same line.
09:13And I noticed when doing this that we're leaving somebody out here.
09:16We have got an ul, which stands for unordered list.
09:18We have the list item, but we don't have ordered list, and that's because we're
09:21not using ordered list in the Explore California Web site.
09:24It doesn't mean that for our limited- scale resets on other sites that we
09:27shouldn't have that.
09:28So I'm just going to add an ol in the mix there, and make sure I have a comma, so
09:32that the ol and li tag are separated.
09:35Now this is a limited reset.
09:37I'm just going to give it a brief Description here.
09:38I'm just going to do a brief, little title here that says CSS margin and padding
09:45reset for basic HTML elements.
09:51And then I'm going to click Insert block.
09:53Always remember to do that.
09:54That's so easy to forget.
09:55So just force yourself, every single time you do this, to remember to click Insert block.
09:59Go ahead and click OK.
10:00Now here is the nice thing about this, because I can preview which elements are
10:03added to the limited reset by looking above that.
10:06I probably don't need that identifier in there either.
10:08So if you want you can edit your snippets, you can right-click a snippet and choose Edit.
10:12It brings up this dialog box, again, you can make any edit you wanted and click
10:16OK, and you are in good shape.
10:18Now this looking pretty good, but more than likely, for any type of library, I'm
10:21going to have more than one resets.
10:22This is a limited reset.
10:23What if on one site I want to do a full reset, or use the Yahoo user interface reset?
10:28Well, if I go up to my CSS folder right here and click on that, I can create
10:32a brand-new folder.
10:33I can call this CSS Resets, and just like that, I can take my limited reset
10:40and drag it in there.
10:41So if you don't get the organization that you want at the beginning of it, you
10:45can add it at the end. Okay, cool.
10:46We're now well on our way towards having a library of CSS snippets that we can
10:51call on whenever we're building a CSS file for our projects.
10:54Now as you can imagine, you can go on from here and add more CSS resets, add
10:59global classes and other site-neutral styles.
11:01The limits on what type and how many snippets you have are entirely up to you.
11:06Now when creating snippets, try to imagine how often you'll use certain rules and
11:11how you might need to modify them for other sites or projects.
11:14It's going to go a long way to telling you what type of snippets you need and
11:17really how ought to be structuring them.
11:19So as we continue to explore snippets in more detail, we're going to move on to
11:24discuss the topic of creating CSS-specific libraries of snippets.
Collapse this transcript
Importing snippets
00:00At this point, I hope you are getting an understanding of how helpful
00:03snippets can be in reusing code and speeding up the page creation and CSS writing process.
00:08In a larger team environment, or working with other developers, they can be a
00:13great way to share code from one team member to another, or just to make sure
00:17that everybody is using the most up-to-date code.
00:20Well, that's true, but there's just one problem.
00:23The Snippets panel, as you can see right here from going to the menu and looking
00:27at that, does not allow you to export, import or share snippets.
00:31They are local to your machine, and your machine only.
00:34But hey, all is not lost.
00:36In this movie, I'm going to show you how to locate your snippets and share
00:39them with other users.
00:41Then in the process, we are going to load some snippets that we'll need for the
00:44rest of the chapter.
00:45So I'm in Dreamweaver, but Dreamweaver cannot help me here.
00:49I need to browse outside into my hard drive.
00:51So of course, you guys on the Mac are going to go to a slightly
00:54different location than I am.
00:56I'm going to open up an Explorer window here in Windows 7.
01:00If you are on Mac, you can open up a Finder window, and what you're looking for,
01:03there's snippets located in actually two locations, and I want to show you
01:07where you can find them.
01:08Now, the first place you can find them is in Program Files, or your
01:11Application Folder.
01:12So, for example, if I open up Program Files here, go into Adobe, and let me
01:16stretch this out a little bit, because I don't have quite enough room just yet,
01:20Dreamweaver CS5 and look under configuration, inside that, I'll find Snippets.
01:27Now, these are the snippets that come with Dreamweaver.
01:29You're certainly welcome to go ahead and change them here;
01:33however, a better location for your snippets is in your local application data.
01:38That way, if you ever have to reinstall Dreamweaver or have to wipe clean some
01:42files, those will still be there.
01:44So what I'm going to do is close my Program Files, and I'm going into the Users.
01:48Now, on the Mac, of course, you are going to go into your Users, and you are
01:51going to go into your Library.
01:53On the PC, I'm going to go into my Local User, which is me, James Williamson >
01:56application data (AppData), and I want to find Roaming.
01:59When I open up Roaming, I want to open up Adobe and browse down and
02:03find Dreamweaver CS5.
02:05So this is not in the most intuitive of locations.
02:08I'm going to open up Dreamweaver CS5, English US (en_US) > Configuration, and
02:13there are my Snippets.
02:14Now, these are my local snippets.
02:16You will notice that we have CSS, Structure.
02:18So these are the snippets that we've added in our past movies.
02:21Now, if you're on the Mac, you are going to go to your User Data, and you are
02:25going to go into your Local Library, find your Application Data inside that,
02:29find Dreamweaver CS5,
02:32and you want a look in your Configuration folder, and you'll find Snippets.
02:36So they are in roughly the same location.
02:37You need to basically, no matter what system you're on, go into your Users Data,
02:42find your Local Application Data, and you should be able to find these.
02:46Sometimes they are little harder to find than others, but you should be able to find them.
02:49Okay! Now what I'm going to do now is keep this window open, and I'm going to open up
02:53another window that's pointed at my desktop.
02:57Looking at my desktop, I'm going to find the Exercise Files folder. Open that up.
03:01I'm go inside the Chapter_03 directory, and what I'm looking for is 03_05.
03:05There is a folder in there called snippets.
03:09Now, inside my snippets folder, I have a folder that's called Explore_Theme.
03:14So what I've done here is created a much larger theme here.
03:18In the past, in our snippet movies, we've created one or two snippets and
03:22kind of done a little bit from organization, but here, this is on a much larger scale.
03:25So what I want to do now is I want to take this Explore_Theme, and I want to copy it.
03:29I am going to copy this directly into the CSS folder that we created earlier,
03:33because that makes sense for the organization.
03:35These are full CSS snippets.
03:36So I'm going to drag it over to CSS. Make sure I'm copying it,
03:40in case I ever need to go back in, and work with it again, and then it just
03:43should copy right over.
03:44Now if I go into CSS, there is the Explore_Theme.
03:46So now inside my CSS folder, I have the Explore_Theme snippets. Okay!
03:50So we know that they've copied there.
03:51Now, let's take a closer look at them, but in order to do that, I need to go
03:55back in the Dreamweaver.
03:56So I'm going to go ahead and close both of these windows, and you will notice we
03:59don't really see a change over CSS folders.
04:01We don't see any Explore_Theme.
04:02That's because in order to refresh that, we are going to need to close
04:07Dreamweaver and then open it back up again.
04:08So let me do that really quick.
04:09I'm just going up to Dreamweaver File and choose, Exit.
04:13Now when I go into my Snippets panel and open up CSS, there is the Explore_Theme.
04:17Now I mentioned that we are going to examine this in a little bit more detail.
04:20So, if I open up the Explore_Theme, you can see this is a lot larger.
04:23We have folders for CSS Resets that we can use within this theme.
04:27We have place for our form styling, Global Classes, Global Constants, Layout
04:32Styles, Navigation, Presentation Styles, Tables, and Utilities.
04:36So we've got all these different categories of styles that we can sort of build this off of.
04:40Now what you're seeing here is what I like to call a theme.
04:43The Explore California Web site has that sort of a two-column layout with a small header.
04:47It's more like a badge header. It has the footer at the bottom of that.
04:51I might want to reuse that from time-to-time.
04:54So in order for me to reuse that, building a theme is really nice.
04:57Notice that if I open up Layout Styles, for example, that I have even
05:00styles inside that.
05:02I have one design to target a 1020 screen resolution and other one designed to
05:05target a 930 screen resolution.
05:07So you create different layout styles for targeted resolution, sizes.
05:11Notice that I've got different headers.
05:13I've got a larger header and a smaller header based on the same layout, and with
05:17enough proper planning, you can really create a structure that's going to be
05:20extremely flexible, that will allow you build any project you want to build that
05:23the Explore California theme would be appropriate for.
05:26Now, I'm not going to sugarcoat what we just did here.
05:29Sharing and moving snippets is a pain, no doubt about it.
05:33Instead of being able to export and import snippets, or even accessing them from
05:37a shared directory, you have to manually copy and paste them into local
05:41directories on each individual machine.
05:44Now, that may seem like a deal breaker, but don't let this little bit of manual
05:48labor dissuade you from utilizing snippets.
05:51While needlessly complex, the ability to distribute snippets to team members, or
05:56even simply moving them from one machine to another, gives you an extremely
06:00powerful way to distribute and reuse code.
Collapse this transcript
Understanding snippets libraries
00:00Saving individual blocks of code as a snippet is a wonderful way to speed up
00:04coding in development.
00:06You can take the organization and scope of snippets even further by
00:09building Snippet libraries.
00:11Snippet libraries are organized collections of snippets built around a specific
00:15layout or element structure.
00:17While they take a little bit of work on the front end to build them, the ability
00:20that they give you to put together pages, or even entire sites, in minutes is well
00:25worth the time required to build them.
00:26Now in this movie we're going to examine the Explore Theme Snippet library that
00:31we imported in our last movie, and add some additional snippets.
00:35Now it's important that you have the starting library in place, so if you
00:39have not completed the previous exercise, please do so now before continuing with this movie.
00:46And I just want to switch over to my Snippets panel, and I can expand that out a
00:51little bit, so I can read these a little bit more and open up my Explore Theme.
00:54Now in the previous movie, we went over the structure of this in a little bit
00:58more detail, but I just want you to notice that there is a certain strategy
01:01behind how these styles are being separated out.
01:04And every single theme, or library, or project that you work on is going to be a
01:08little bit different.
01:09Don't anticipate that you're going to be using the same structure every single time.
01:12What you should think about is if you're really trying to reuse your code,
01:16look at the project you're working on and imagine the pieces of that you can
01:19use in other projects.
01:21That will give you a good idea as to what organizational structure it needs to take.
01:24For example, inside the Explore Theme you'll notice we have several CSS Resets.
01:28We have Eric Meyer's famous Reset,
01:30we have own limited reset that we've used, and we have Yahoo's YUI 3.0 Reset.
01:35If you're going to Google search on CSS Resets, you're going to find pages and
01:38pages and pages of these guys that you can use, and you can build your own.
01:41So I find it kind of handy, even within a theme, to have all those resets
01:45available so that when I create any project, I can just start using them.
01:48Our Forms is empty.
01:49We're going to take care of that in just a moment, but we have these Global
01:52Classes that we can use, our Global Constants that we can use.
01:56Notice that we have various Body tags, some that use Ariel, Tahoma
01:59the Georgia Font Stack.
02:00So we've got a lot of different things going on here. And outside of just
02:04the global things, we have specific Layout Styles targeting different screen resolution.
02:09We have different styles for the Home page.
02:11You'll notice that Navigation, we have some Base navigation styles, Home page
02:15navigation, Sub navigation, so if we're working a project, for example, that
02:18isn't going to use this Sub navigation styles,
02:21they're separated from the rest of them.
02:22We don't have to worry about using those snippets to get started.
02:24That's the other thing that I want to point out.
02:26Please don't anticipate that you're going to be able to deliver a fully-realized
02:31CSS file from using snippets.
02:33What they really forced to speed the process up, just sort to get the base and
02:36the foundation in place,
02:37so that after you're done with that, you can go and style individual elements.
02:40Okay, well we're going to go ahead and continue to add some snippets to our
02:44libraries, and we're going to do that first by adding the Form styling that the
02:49Explore California Website uses.
02:51So we're going to add the form styling as part of our theme. So go over to
02:54your snippetSource.css.
02:56This of course is a copy of the main. css file, and I'm going to scroll down a
03:01little bit to line 785.
03:05You'll find that on 785 our form styling begins.
03:10So what I'm going to do is I'm going to start, even with this comment on line 785.
03:12I'm going to select that, and I'm going to drag down and select all the
03:18way through line 852.
03:20You'll notice that is all of our global form styles.
03:24Directly underneath that, we have the individual form.
03:26So first we're just going to take care of sort of the generic, sort of global
03:30form styles that any Explore California theme page is going to use.
03:34So with that selected, and notice we have a wide range of text selected,
03:38we're going to go ahead and right- click that and choose Create New Snippet.
03:43Now I've also highlighted the Forms folder, so if you haven't done that yet, just
03:46cancel out of that and go highlight that.
03:48So Create New Snippet. I'm going to go ahead and call this Global Form
03:56Styles, and my Description for this is going to be Global form styling for Explore Theme.
04:05I also want to make sure it says Insert block,
04:07scroll through to make sure that everything has the closing curly brace, the
04:10proper opening curly brace and click OK.
04:13So it goes ahead and adds that over there and again I can preview that by
04:17highlighting the snippet and taking a look at it.
04:18Now I'm going to scroll down a little bit further to line 855.
04:24which is where our individual forms start, and I'm going to start with the
04:27support form so I'm just going to go ahead and take every single one of these
04:29guys out of here now.
04:31If I'm building another project, I now have three very distinct form looks: one
04:35that's using a multicolumn approach to forms, one that's using the more narrow
04:38form, one that's using sort of a basic, generic form.
04:41So I'm going to have some options for these guys.
04:43So I'm going to start with the support form and highlight from 855 all the
04:47way down to line 902.
04:49You ought to be kind of careful about this. This thing will absolutely take off on you, if you let it.
04:53Make sure you get that closing color brace, and this should end right above the contact form.
04:57I'm going to go ahead and create a new snippet out of that.
04:59Notice that I just love right-clicking, and I think that's the easiest way to do
05:02it, so either right-click or Ctrl+click > Create New Snippet and we're going to go
05:06ahead and call this one Support Form Styles and the Description for this is
05:15Style for the support form in the Explore Theme.
05:24Once again, we're going to Insert this as a block of code. Make sure you always do that.
05:28Preview is going to be set to Code.
05:30I'm going to make sure I got everything, and then we'll click OK.
05:33There is our next one.
05:34And next we're going to our contact form, so from line 904 to 940.
05:40Again, you may have to scroll back up a little bit. If you are like me, this
05:44thing it will absolutely take off on you.
05:44You want to make sure that it is just above the joint form, and you want to make
05:47sure you have everybody selected.
05:49So this is our contact form.
05:51We're going to go ahead and create a new snippet out of that.
05:53I'm going to call this Contact Form Styles.
05:57The Descriptions that I'm going to give this one is Styling for the contact form
06:04in the Explore Theme.
06:06You can be a little bit more descriptive, if you would like.
06:08So we've going to make that Insert block.
06:10We're going to preview in Code and go ahead and click OK.
06:12And we have one last form to do.
06:15And this one is going to be the join form, so it starts at line 942. That's going
06:20to go all the way down to a 1002, so a good bit more going on here.
06:25And again, you can see it's just above the Sidebar, so line 1002, make sure you
06:28get that closing curly brace.
06:30I'm going to convert that to a snippet as well, so I'll Create New Snippet.
06:33We're going to call this one Join Form Styles, and the Description for this one
06:41is going to be Styling for the join form in the Explore Theme.
06:51Once again, make sure this is Insert block, preview it in Code View and click OK.
06:55All right. So now we have all of our form styles over there. We have our Global
06:59Form Styles so we can use for pretty much everything.
07:01Then we have the individual forms: Contact, Join and Support.
07:04Now you may have noticed that we didn't have to modify any of the styling of
07:08these styles. We just went and highlighted them and converted them and converted them.
07:11Depending upon the strategy of your library, you may want to strip out items, like
07:15background images or other presentational markup.
07:18Thankfully, we don't have any in our form styling,
07:20but in other places we did have to strip that information out.
07:23So in the case of our library, we would strip out any background images, but we
07:27would allow Color and Typography to remain as part of our theme.
07:30So you sort of set those ground rules very early on.
07:32What is it that I want to be part of theme?
07:34What is it that I'm stripping out?
07:36What am I making neutral, and what am I keeping?
07:37And that's earlier strategy you need to take very early in the process.
07:41Now obviously this takes time, okay, but building an organized library around a
07:45specific design or a theme isn't only that hard to do.
07:49You'll obviously you want to take a good deal of time to think about how you're
07:53going to use this library.
07:54This will help you determine how it should be structured,
07:57when to provide snippet variations and how much detail your snippet code should have.
08:02Now that degree of planning will make you Snippet libraries easier to use and
08:07certainly make them more flexible in the long run.
Collapse this transcript
Building a CSS framework using snippets libraries
00:00When you're working with Snippet libraries, building them is really the hardest part.
00:05Using it to create site content is actually quite easy, and it should be,
00:09because those are the benefits of using snippets;
00:11they make building things a little bit easier.
00:13Now, how you build your site content with your Snippet libraries is going to
00:17depend on how you organized and structure your library and the amount of options
00:23that your specific library gives you.
00:25In this exercise, we are going to use our explore theme in CSS Snippet library
00:29that we've been building in the previous exercises to build the initial global
00:33styles and layout for the new site.
00:35So we are going to be working on a new project here, and all we really want is
00:38sort of a jumpstart to the project,
00:40do all of our global styles written, the layout specific styles written, then
00:45after that, we can go in and sort of style everything for the project.
00:48So it's going to be sort of a leg-up, if you will.
00:50So what we want to do is start with a brand-new CSS file.
00:54So I've defined the 03_07 folder as my root directory, but we need a
00:59brand-new CSS file.
01:01So I am going to say Create New, right here, CSS.
01:04I am going to go to File and choose Save.
01:06I am going to go to the 03_07 CSS folder, and inside that I want to go ahead
01:12and name this main.css.
01:15Now, at this point, I'm just going to start structuring the CSS Styles document
01:19the same way that we would normally structure one.
01:21I am going to let the Snippets library assist me in doing that.
01:24So I am going to switch over to the Snippets panel, open the CSS folder, and
01:28again, I am looking for the Explore Theme that we were working on earlier.
01:32Now again, if you don't have this, please refer back to the earlier movies in
01:35this title where we were sharing snippets and importing the snippet library into Dreamweaver.
01:40Okay, so the first thing I want to do is I want to go down to the Utilities, and
01:44I am going to go ahead and placethe header in our file.
01:45So I can get rid of this comment, we know it's a CSS file, and I am going to go
01:50to the Utilities > CSS Header and double-click that, and it's going to insert
01:53that into our document.
01:54I am just going to change a few things here, and make it specific for the new project.
01:58So I am going to say style sheet for Hansel & Petal,
02:03that's our new client, and I am just going to do version 1.0.
02:06I am not going to put a modify date on there, and I'll leave the copyright
02:09the way it was before.
02:10I'll go down to the next section, and I am going to use a section indicator.
02:14That is something that's going to tell people that we are moving from one
02:16section to the other.
02:17Notice we have just got a generic section name here, and we are going to change
02:21that to global constants, and we'll just leave that indicator at ^1, because it
02:26is our first option.
02:28So your global constants are going to be the styles like your basic page
02:31elements, your headings, your paragraphs, your HTML items, things like that, and
02:35we have an entire directory for our Global Constants.
02:38So I am going to go ahead and open that up, and the first thing I am going to do
02:41is place my html and body reset.
02:43I use that a lot, and again, that just sort of clears out the default page
02:47margins and paddings that certain browsers might place.
02:50So we all start from the same spot.
02:52Next thing I am going to do is go down to the next line and just hit Return, and
02:55I am going to open up my <body>tags.
02:56Now here, I have some choices.
02:57I could use Arial, Tahoma, or a Georgia font stack, whichever one that I want.
03:02For the design, we're doing for the Hansel & Petal site, the Tahoma makes
03:06a little more sense.
03:07So I am just going to double-click that, and that's going to import my body.
03:10Now notice that I've got sort of a default background color. It's just white.
03:14So that's a perfect setup for importing a graphic to edit that style later on.
03:18So don't assume that your snippets are going to come in finished.
03:21In this case, we just have a couple of options here that we could go ahead and
03:24change anytime that we want.
03:25Also, notice that this one has a top margin of 25 pixels, which is going to sort
03:29of push everything down the page a little bit.
03:32We're doing that because it's specific to the Explore layout, which is why it's
03:35in the Explore theme.
03:36I'm going to go down the next line, and I am going to go back to my utilities
03:39and add another section indicator, and here we are going to do a CSS reset.
03:44So I am just going to type in css reset, change my indicator to 2 instead of 1,
03:49and then below that I am going to go into my CSS Resets.
03:53Now, I am going to close some of these folders.
03:55I don't like having a lot of folders open when working with this, because it's
03:58really easy to get confused.
04:00In my CSS Reset, I noticed I have three of them:
04:02Eric Meyer's, the limited reset that we did, and Yahoo Interface 3.0 Reset (YUI 3.0 Reset).
04:07If you go out on Google and search for CSS resets, you are going to find version
04:11after version after version of these things.
04:12But I am just going to use the limited reset that we've done, here we go, and we
04:16get that on the page.
04:18Below that, I am going to return to my Global Constants, and inside my Global
04:22Constants, I am going to follow up with basic elements, and then directly after
04:26that, notice I whenever I have to link, I can double-click link globals and get
04:29those in there as well.
04:30So 81 lines of CSS already written, right on the page, doing what we need it to do,
04:35and we really haven't had to code a single thing yet.
04:39Now, if I'll scroll up a little bit, you are going to notice that the css reset
04:42kind of interrupts our global constants.
04:45It just sort of inserts itself in there.
04:47The reason for that is the cascade.
04:49We want to go ahead and clear those values out for elements, and then the
04:53selectors below that are sort of reestablishing those values.
04:56So the order that those styles come in is really, really important.
04:58So remember that when you are building your libraries, you still have to
05:02understand the structure of your pages.
05:05You have to understand the order that the styles need to appear in, or you are
05:09going to be causing more harm than good.
05:10So really approach snippets from the standpoint of I really know what I am doing with this.
05:14I know the order that I need to assemble these in, and I am just going to give
05:17myself as many options as I need for this particular topic.
05:21Okay, we are almost done.
05:21What I am going to do now is after the last item, I am going to go ahead and add
05:25another separator, and this particular section is going to be global classes.
05:30We'll go ahead and do 3 for indicator there.
05:34Below that, we are going to go into our Global Classes folder, and I am going to
05:38add the global classes and the Call Out Classes.
05:41I am just going to sort of not put in the IE Globals. There we go.
05:45So, all those are looking good.
05:46We have all of our individual global classes and we have our callouts. Now,
05:51notice what happened here.
05:53The callout is added to the same line as the closing one.
05:56Now actually, syntaxually, that's not going to hurt anything, but
05:58readability suffers there.
05:59So I am going to hit Return to take that down to this next line, and remember,
06:03the period must remain in front of that.
06:05So you want to be really careful.
06:07If you ever have to go in and edit where the CSS was placed, you want to be
06:10really, really, really careful with that.
06:12Okay, just below that, we are going to go ahead and add another section
06:15indicator, and this is going to change to number 4.
06:19The section name here is going to be top-level layout styles. Here we go.
06:26Now, I can close this Global Classes and Global Constants, and I am going to
06:30open up the Layout Styles, so I can see what's going on here.
06:32Now, here I have two different screen resolutions that we can target: 1020 and 930.
06:37Hansel & Petal is going to use the 1020.
06:39So I am going to go ahead and open up my 1020 styles.
06:42The first thing I am going to do is add the wrapper for a 1020 width, so notice
06:46that, again, neutral background can be changed to another color or a background
06:50image, centers it on the page, and the width is targeting 1020.
06:54I am going to hit Return to go down the next line, and I am going to open up my
06:58headers, and I am going to do a header for 100x600.
07:02So instead of the Explore California site, where we had just that really, tall
07:07thin header, we're going to have a really wide, short header, more of a banner
07:11type header in this particular layout.
07:12Directly after that, I am going to go over to my Layout Styles and add
07:15my top-level layout.
07:17So these are all of the individual settings for sidebar, mainContent, mainNav,
07:21so all of their layout.
07:22Notice that this code is extremely stripped out.
07:25It's not presentation at all. It's just layout.
07:28That is all that's there.
07:29So I am going to go ahead and save this, and we are only going to need to make a
07:32couple of minor modifications to our styles in order for it to give us a
07:37starting point for the Hansel & Petal.
07:40So the first thing we want to do is I am going to go up to the very top of the
07:43page, find the <body> tag here, and I am going to change the background color.
07:46So again, it's one of the nice things about it. Fff is neutral.
07:49You'll never notice it, but it does give us a property that we can go ahead and edit.
07:53So what I am going to do here is edit this to a5bf94. So a5bf94.
08:02So now we have a solid background color that we are going to be using for our
08:06<body> tag, and it relates a little bit more with the color scheme and the theme
08:10of the Hansel & Petal Web site.
08:11I am going to scroll down a little bit and find the header selector, which is
08:15going to be found right at about Line 138 in mine; yours might be in a little
08:20bit different location, but it's in those main layout styles.
08:22So in order to keep these now in alphabetical order, I am going to go up to the
08:25first property and hit Return.
08:26It gives me a blank line here, and then I am just going to type in
08:29background, and after that, type in a u, and I am going to let code hinting do the rest for me.
08:34When it goes down to the link, I'll hit Return, and I get to browse.
08:38Now, I am going to go up to the 03_ 07 folder, I'll go up to the _images
08:41directory, and the only image I've got in there is this Hansel & Petal banner
08:45graphic, and that's what I want to use.
08:47I am going to go ahead and click OK, and I only want it to show one time, and
08:50I'll type in a semicolon. There we go.
08:52So I'll go ahead and save that, as well.
08:55Finally, we have one more thing to do here. Because we are using the sort of
08:59longer, skinnier background image, the main page content and things like that need
09:03to sort of move down a little bit.
09:04So I am going to find this mainNav, and I am going to change a couple of things here.
09:09I am going to change top margin to 133, rather than 233.
09:13Then I am going to scroll down and find mainContent.
09:15It should be right below that.
09:17I am going to add a margin-top property to that and give that 100 pixels.
09:22So that's going to push the mainContent down just a little bit.
09:24Now I am going to go ahead and save this, and I want to go to my Files panel
09:28and open up start.htm.
09:30Start page already has link to the main.CSS in it, and you can see, there's
09:34not much going on here.
09:35It's just some place holder content.
09:37Now I want to Save All, and I want to preview that in my browser.
09:41Let's take a look at it.
09:45To be honest, this page looks terrible. But that's okay.
09:49It's because we still need to do things like hide this header text up here.
09:52We're going to hide that.
09:53We've got to add padding and margins to page elements, control navigation style.
09:57You can see over here, we still have bullets showing up, and all those other
10:00presentation styles.
10:01We still have a lot of them in our library.
10:03That, however, is not the point.
10:05The point is look how fast we created a two-column layout with a CSS Reset using
10:10our snippets library.
10:11If our Explore theme library had extensive presentation styles snippets, the
10:15rest of our job would be even easier.
10:18Having organized, well-structured snippet libraries enable you to rapidly build
10:22complex style sheets.
10:24Properly planned, snippet libraries can be an amazing time saver, helping you to
10:28get the foundation of your site out of the way quickly so you can have more time
10:32to focus on specific design elements.
Collapse this transcript
4. Deploying Styles
Writing a print style sheet
00:00As Web designers, we are likely to get caught up and writing styles for the
00:04screen without taking into consideration that there are many other devices such
00:08as printers that are likely to consume your content.
00:11If your site is not equipped with printer styles, pages will be printed as
00:15unstyled content, or by using your site's default styles.
00:18Now, the good news is that writing print style sheets is incredibly easy to do
00:22and gives us the ability to create an entirely new look and feel for our site,
00:26designed specifically for the printed page.
00:30So I have the resources.htm file open in the 04_01, and I'm just going to
00:35preview this really quickly in our browser.
00:38So I'm going to preview that in Firefox, and I'm going to go up and do a Print Preview.
00:43So on the Mac, you could go ahead and do Print and then click the Preview button.
00:47And now we get to see what this page would look printed out.
00:49So we have a nice, big headline that shouts Welcome to Explore California, an
00:53unordered list that doesn't mean anything on the printed pages, an image, boy, that looks horrible.
00:58Look at that.
00:59The page breaks are happening poorly.
01:01There's some really bad stuff going on here.
01:03Our sidebar information is printed.
01:05Now, some of the things that people might want such as the address here is
01:09printing out just all by itself.
01:11So not really what you would want in terms of user experience, or in terms of
01:16passing brand from one medium to the other.
01:19So I'm going to close that, close my browser.
01:21Let's go back into our Resources page and begin to create our print style sheet.
01:27So what I'm going to do is open up my CSS Styles panel, and with that open, I'm
01:31going to go over to the New CSS Rule, that little icon right there. Click on that.
01:37And the first thing we're going to do is a compound selector.
01:40We're just going to go ahead and basically tell certain elements not to print.
01:43There are certain things we don't need to print.
01:45The navigation doesn't need to print.
01:47You cann't navigate using the print document.
01:49The sidebar information probably doesn't need to print.
01:52The footer information doesn't need to print, the header information.
01:55So we're just going to go ahead, and do the following selectors.
01:57So type in #header, #mainNav, #sidebar, #footer.
02:07Okay, so we're going to define that, not in main.css, but in a brand-new style sheet file.
02:12So this is kind of an interesting technique because here, we're going to create
02:16a brand-new CSS rule, put it in an external style sheet and link the external
02:20style sheet to this page, all in one step.
02:22So that's pretty cool.
02:23I'm going to go ahead and click OK, and I'm going to save our brand-new
02:27external style sheet in the _css directory, and I'm just going to call it
02:31print.css, perfect.
02:33I'm going to go ahead and save that.
02:34Now our CSS Rule Definition dialog box comes up.
02:37So it went ahead and created the style sheet for us, linked it to the page, and
02:41now we're free to go ahead and place styles inside of it, which is really cool.
02:45Now, I'm going to go to the Block category, and the first thing that I want to
02:48tell this is to display none.
02:50I don't want these to print out at all.
02:52So display none, I'm going to go ahead and click OK and do a Save All.
02:57Now, I wasn't going to say well, look, nothing on the page changed, but nothing
03:00could be further from the truth; a lot of stuff changed.
03:03So what happened here?
03:04Well, if I look over at my CSS Styles panel, and I'm just going to roll the
03:07Files panel down a little bit here, you can see that the print.css style sheet
03:12looks very different up here from the main.css.
03:14Let me collapse those so you can see them together.
03:16Notice main.css says hey, I'm only affecting screen of projection but print,
03:21it's mum on that issue entirely.
03:24So if a style sheet does not have a media type assigned to it, it goes ahead
03:28and applies to all media types, which in this case is causing us some big
03:32problems here onscreen.
03:34So we need to tell the print style sheet that indeed it only affects the printed page.
03:38You'll notice we didn't get that prompt
03:40when we created the style sheet that way. That's for me one of the drawbacks of
03:44using that, but it's easy enough to put in ourselves, and we'll just switch over
03:46to code and do it very quickly.
03:48So I'm going to switch over to Code View and in Code View, I want to find Line
03:51#7, that's where my print style sheet has attached itself.
03:55At the very end of that, I'm going to add media="print", and you can just go
04:00ahead and let code hinting help you out with that.
04:02Just make sure that you have the self closing tag done right, space forward
04:05slash and that there'll be end of the tag.
04:07So I'll go ahead and save that and switch back into Design View.
04:11Now what's really interesting here in Design View, we get our page back,
04:14yay, right?
04:15Everything is showing up again. And over here, it says print.css, and this says print.
04:19Now, I want to introduce you to a toolbar that you may have seen.
04:22I know we've talked about a little bit earlier, but you may have never used it,
04:25and it's this toolbar right here.
04:27This is the Style Rendering toolbar.
04:29If you don't see it, you can go up to View, choose toolbars, and you want the
04:33Style Rendering toolbar.
04:34You can also right-click the Document toolbar and choose it that way.
04:37Now, this toolbar can float unless you are on a Mac, in which case it's always
04:42going to remain docked with the Document toolbar.
04:45I like it being there as well, and so I'm using to have it docked somewhere on
04:49the Document toolbar, usually on the right-hand side, but left-hand is fine, too.
04:52It's not really hurting anything.
04:53And what I'm going to do now is going to make designing our print style sheet
04:57a lot easier for us.
04:58So what I'm going to do is go over to the Style Rendering toolbar, and I'm going
05:01to tell it to render the Print Media Type.
05:03As soon as I do that, notice that the page entirely changes, and now we're
05:07seeing a preview of what the printed page is going to look like.
05:11This is really cool.
05:13This means that we can start designing inside of our print style sheet,
05:16adding selectors to it, and we'll see the changes here directly in our screen,
05:19which is really neat.
05:20Now let's add a few more selectors to our print style sheet.
05:23So I'm going to go over to my CSS Styles panel and click on the selector that
05:27I have here already.
05:29And I'm going to go ahead and create a brand-new CSS Rule.
05:32Now for this one, again, I'm going to go down to Compound because I'm going to
05:34be grouping some selectors together.
05:36I'm going to type in a.breadcrumb, that's the links at the top of the page, comma
05:42a.top,ul.faqNav so faqNav.
05:52So three other elements:
05:53breadcrumbs, links at the top of the page and any unordered list that is part of
05:58the faq.navigation, so those were actually links that you could click on to jump
06:02further down the page.
06:03I'm going to make sure that they're being defined in the print.css.
06:07I'm going to go ahead and click OK, and I'm going to go to the Block category
06:10and once again, I'm going to tell it to display none.
06:13So while I think they are great,
06:15I certainly don't need to see them in the printed page.
06:17So I'm going to go ahead and Save All.
06:20If you're working on your print styles, you don't have to create all of them
06:24within the CSS Styles panel.
06:25I'm going to go ahead and collapse the CSS Styles panel down to Icons, switch to
06:29a Split View and click on the print.css.
06:33So I'm actually working on the print style sheet.
06:35So again, I can see the Design View to the right of me.
06:37It's showing my print styles, and on the left-hand side, I get my code. Cool!
06:41Let's do a couple of more styles here.
06:42Let's type in #wrapper and put up curly brace, hit Return to go down to the next
06:47line, and here we're going to just type in width and then 6.5in, for inches.
06:54Now that, my friends, is interesting, is it not?
06:57Let's go ahead and close our curly brace.
06:59Now every single medium you design for is different, and I've had plenty of
07:03students asked me before, why in the world you can use inches in CSS?
07:08It doesn't translate to the screen at all.
07:10No, but it translates to the printed page.
07:12So when you're doing a print style sheet, it's really handy to be able to use inches.
07:15I'll go down to the next line.
07:17I'll type in body, and in the body tag selector, I'm going to do a font-family,
07:23and I want to do a font- stack that I don't see here.
07:26So this is one of the cool things about working in Dreamweaver.
07:28If you want to do a font-stack that you don't already see, you can click Edit
07:32Font List, and that comes right up.
07:34I'm actually going to check for Chaparral Pro, and after Chaparral Pro, I'm
07:39going to do Cambria.
07:40So I'm going to find Cambria. There we go.
07:44After that, I'm going to do Georgia and then a San Serif.
07:48Now, if you're wondering, these are fonts, at least the first couple of them, that
07:52are more likely to be installed on your machine.
07:55Because these styles are for the printed page, I have a little bit more freedom
07:59in working with specific types of fonts.
08:01In this case, Chaparral Pro comes with a lot of programs these days.
08:04It's installed on a lot of machines. So is Cambria.
08:07And then finally, I have a Georgia fallback font.
08:08So these are more print friendly fonts and at the very end, I'm going to add the Serif.
08:12There we go.
08:13So if you don't like the font stacks that are in there, you can build your own.
08:15I'm going to go ahead and choose that one and click OK, and then I can scroll
08:19down and grab it, hit Return, and it finishes it for me.
08:22You don't have to do that every single time.
08:24You only have to do at once, and it will remain in there.
08:26After that, I'm going to do font-size and my font-size is going to be 12 points. Points, ya!
08:35So again, all of our graphic designers, when I tell them only when you're doing
08:38the style, print styles sheets can use points.
08:40They get so excited because they know exactly what 12-point text is supposed to look like, right?
08:43All right, now I'm going to do a line-height here.
08:46So I'm going to do a line-height of 16 points.
08:48So now we're just going to go ahead and continue using points for the units of
08:52measurement when we deal with the print page.
08:54Let's do one more selector.
08:55Hit Enter, go down and do an h1 selector and here, we're going to do a font-size
09:01of 20 points, font-weight of normal -
09:07so I don't want it bold - and a margin-bottom of 20 points.
09:15Again, we're working in points is quite extensively here, so there is our h1 selector.
09:18All right, so now, let's see if this looks any different.
09:21We're going to do a Save All.
09:22We're going to preview this in our browser.
09:24Now once again, we're going to do a Print Preview, and that looks a lot better. Notice the font.
09:30Again, there's Chaparral Pro font in here.
09:32Everything is looking pretty decent at least, or at least it's moving in
09:35the right direction.
09:36Let's put it that way.
09:38Now if we were satisfied with just changing the look of the printed pages, all
09:42we would really need to do is continue to style a couple of these individual
09:45elements here and there;
09:46however, there are some styles that are specific to print styles, and they can
09:50only be used with the printer, and they give us a pretty powerful functionality.
09:54In our next movie, we're going to explore some of those print-specific
09:57styles and a few other techniques that can make our print style sheets even
10:01more powerful.
Collapse this transcript
Creating print-specific styles
00:00One of the really cool things that CSS allows us to do is design for a
00:04specific environment.
00:06In our previous movie, we wrote some basic styles that control how our site
00:11looks when it prints.
00:12We can take that even further by writing styles that are specific to the
00:16printed environment itself.
00:18CSS properties like page-break allow us to write styles that target that
00:23environment and give us even more control over how our style prints.
00:27So, I have the resources.htm file open from the 04_02 folder.
00:34Now, if I take a look at our print style sheet, I can see that the style sheet
00:37that we started in the previous movie, really the only thing that's been done is
00:42some of the additional elements on the page have been styled, just so that we
00:44have more of a finished product to work with here.
00:47All right, so I'm going to preview this page in our browser, and I'm going to go
00:51to my print preview, so that I can kind of see how the printed page looks.
00:55It's looking pretty good, but there's a problem.
00:59It might be a minor problem, but it still looks like a problem for me.
01:02Trip planning is fine, but look at Tour checklist. Look how that's breaking.
01:06It's always kind of annoyed me when I print out some of these Web sites, and I
01:10get half of the information on one page, and half of it on another page, and it
01:14really kind of gets jumbled up.
01:16So, I want to force page-breaks, and that's really easy to do by using the
01:21page-break-before or the page-break-after property.
01:25So let's go ahead and write a couple of styles that we can use to control
01:28specific elements and whether they need a page-break-before or after them.
01:33It's probably easier just to do this in code, so I'm going to select the
01:36print.css, switch over to code view, and I'm going to go all the way down to the
01:40bottom, and at the bottom of the page, I'm going to type in .pb.
01:44Now, because it's a class, it has to start with a period, dash before, and I'm
01:49going to go ahead and open up a curly brace and in the line below that, I'm
01:52going to type, page-break.
01:55Now, notice that we have page- break-after, page-break-before,
01:59and page-break-inside.
02:00I'm going to go ahead and do page-break- before, which would insert a page-break
02:04directly before the affected element.
02:06And I'm just going to go ahead and type in always.
02:08Notice that we can also have avoid, auto, all those types of things.
02:12That actually leads some very interesting settings.
02:15You could take a heading, for example, and do a page-break-auto, and if the
02:19heading was a little long, and was forcing page-break, your browser would go
02:23ahead and insert the page-break itself.
02:25I've had mixed results with doing that sort of thing.
02:28Sometimes, it works really well.
02:29Sometimes browsers don't pick up on it.
02:30So, I actually prefer to control mine manually.
02:34Now, I am going to go down the next page. I'm going to type in .pb-after,
02:39and once again, I'm going to do page- break, and this time, we're going to do
02:44a page-break-after.
02:46In this case, I'm going to do always as well.
02:49So, I'm going to do always for both of them.
02:51Now the reason I like controlling these manually is it's just a little bit
02:53easier for me to do a print preview, find a page and say, yeah, that needs a page-break.
02:57Now, on larger sites, or sites where you have a lot of dynamic content being
03:00generated, that's not always possible.
03:02So, sometimes you can set up these guys to automatically do a page-break if they need it.
03:07So, you could maybe make that part of your paragraph style;
03:10A page-break-before:
03:11auto, and it would just go ahead and assign one wherever needed.
03:14I'm going to do a Save All.
03:16Now, we need to go apply these classes.
03:18I'm going to go back to my design environment.
03:20I'm going to scroll down a little bit, and remember, Trip planning was okay, but
03:24Tour checklist was the one that really needed the page-break.
03:26So, I'm going to select Tour checklist, click on the h3, and in my HTML
03:30properties, I'm going to go ahead and go pulldown menu, and I'm going to choose
03:33pb-before, so that there's a page- break before the Tour checklist.
03:38Now, that class only applies to your print style sheet, but it is part of your HTML now.
03:42I can do a Save All.
03:44Notice that if I go back, right here, and render my screen media type - so this is
03:47my Style Rendering toolbar,
03:49notice that still visually no different whatsoever. So this is only going to
03:53affect the printed environment.
03:54We're going to go ahead and preview that in the browser again.
03:57I'm going to go ahead and do a print preview.
04:00Now, sure enough, notice that Trip planning is right there, but Tour checklist
04:04is now breaking down to the next page.
04:06So, that is a much nicer presentation of that.
04:09We get to control that within the printed environment, which is really, really cool.
04:12All right. Let's go ahead and take a look at some of the other things that we can do
04:15for the printed page that isn't necessarily a print-only property.
04:19CSS can do a lot of things.
04:21One of really cool things it can do is it can generate content.
04:24You can basically tell a browser, or any type of device that when you experience
04:28this particular element, go ahead and generate this content after it.
04:31As you can imagine, there are some incredible usage for that.
04:35Now, you'll notice that on the page, I have a sentence here that says, for more
04:38information on traveling to California, check here.
04:41Now, on the printed page, what is check here referring to?
04:43That doesn't make any sense, and if I look at that with the screen styles turned
04:47on, well, that's pretty obvious; it's a link.
04:49So, checking here would click to take you to a Web site, but when you're looking
04:53at your print style sheet, not only is that not obvious;
04:56you have no idea where to check.
04:58So, what we're going to do is we're going to write a pretty advanced selector
05:01that allows you to generate content after any external link, so that people that
05:05print your page out will have that Web address later on.
05:08All right, so let's take a look at how we can do that.
05:10I'm going to switch back to code view, again, focusing on the print.css
05:14Scroll all the way down to the bottom, and I'm going to add a selector right
05:17down here at the bottom.
05:18Now, this is going to be an attribute selector.
05:20Now, I'm sure some of you have done attribute selectors before, but for those of
05:23you that have not, attribute selectors allow you to basically say, okay, I want
05:28to style this particular element when it has this attribute.
05:31You can be as specific as you want.
05:33You can just say if it has the attribute, you can say, if its attribute is this
05:38value, or you can do what we're going to do, which is to say, if it has an
05:41attribute that contains at least this particular string of characters.
05:45So, what I'm going to do is I'm going to type in a, for link, and then open up a bracket.
05:48That bracket indicates that this is an attribute selector.
05:51Now, for that, I'm going to type in href, and then close my bracket.
05:55We're going to add more to this, but I want to explain this piece-by-piece
05:58for those of you that maybe haven't dealt with attribute selectors before in the past.
06:02This selector would target any link with an HREF attribute.
06:06So, any link that actually goes someplace, to a local page or to a remote page,
06:11whatever, this would apply to that.
06:13Now, let's get a little bit more specific with this.
06:15After the HREF, what I want you to do is type in ^=.
06:20That's a special character, obviously.
06:22It's basically saying if it contains the following.
06:25Now, after the equals, type in a quotation mark, type in http://, and then close
06:33your quotation mark.
06:34Okay, so what is that saying?
06:35Well, it's now saying, find any link with an HREF attribute that contains http://.
06:44The only time that condition is going to be met is when we're dealing with an
06:47external link, a link that goes away from our site.
06:50If you think about it, that makes sense.
06:51What we're going to be doing here is displaying the link, so that people that
06:55print this out know where to go later on.
06:57Well, they don't need to know that you're going to click to go on the Contact
07:00page, or you're going to click to go to the Index page.
07:02That really doesn't make a whole lot of sense to show them that.
07:04But if you're navigating away from the site, that's going to be a resource
07:07they're going to want to know about.
07:09Okay, now let's go write the rest of the selector.
07:10Right after the bracket, type in :after.
07:15So now, what we're doing is we're using a pseudo-selector.
07:17Now, most you are probably familiar with pseudo-selectors, at least the Link,
07:21Hover, Visited, Active, maybe even the Focus one, that sort of thing, but after
07:25is one that you may or may not have used before.
07:28After is essentially saying, once you find this, directly after it is what I want you to do.
07:34So, this pseudo-selector is basically saying, after the element that you
07:37find, let's do something.
07:38Okay, I'm going to go ahead and open up my curly brace, hit Enter and go
07:41down the next line.
07:42Here, I'm going to type in the property content.
07:45The content property allows you to generate content on the page.
07:48So, essentially, what we're saying is after you find the absolute link, we want
07:51to generate some content.
07:52Let's take a look at the content that we want to generate.
07:54I'm going to type in space, and then a quotation mark, and then another
07:59space, and that's going to give us a little bit of space between the link and this content.
08:03Now, I'm going to type in a parenthesis.
08:04I'm going to type in online at, and then a colon.
08:08What's interesting about this is because we opened up a quotation mark, this
08:11is a literal string.
08:12That means that this content is going to be displayed on the page.
08:16So, these strings of characters, such as a literal string, Dreamweaver doesn't
08:19really care what it is.
08:20The browsers don't really care what it is.
08:22They're going to place that directly after any link that's an absolute link.
08:25Now, I'm going to go ahead and close my quotation marks, because here I need
08:29to go grab a value. Check this out.
08:31I'm going to type in attr, and then in parentheses, href, close my parenthesis,
08:39close quotations marks.
08:40Now, what is that doing?
08:41Well, essentially, we're doing concatenation.
08:43Concatenation is just another way of saying we're joining a couple of things together.
08:46So, what we're doing is we're taking these literal strings, the text "online at,"
08:51and then directly after that, we're going to place an attribute.
08:55We're going to place the HREF attribute.
08:56So, it's basically saying, hey, go get the contents of this HREF attribute and
09:01place it right here.
09:03So, it's going to say, online at, then whatever the link would be.
09:06Now, we still need to finish something here.
09:07Remember, we have parentheses around this, so I'm going to go ahead and close
09:12the parentheses and close the quotation marks.
09:14Type in a semicolon, and then we're done with that rule.
09:17That is a really complex selector.
09:19Let's take a small second to go over it one more time.
09:21So, we're saying anytime you find a link with an HREF attribute that contains
09:26http://, so any external link, after that selector, we want you to generate some
09:33content, and we want you to generate the text saying, online at, and then go
09:39grab that HREF attribute, place that there, and close your parenthesis out.
09:44Let's Save this, and we'll just see if it works.
09:47I want to preview this in our browser.
09:51I'll do another print preview.
09:52If I scroll down, you can see, right here, for more information on traveling to
09:59California, check here (online at: http://www.visitcalifornia.com). Cool!
10:04So, it's pulling the information we want, it's formatting it the way we asked it
10:08to, and our print style sheet is a lot more robust now.
10:11It's allowing us to control exactly how our content is presented on the printed page.
10:15We can determine which elements print, how they look, and even have a granular
10:20level of control over how our pages behave.
10:22Now, the best part about all of this is that print style sheets really don't
10:26take that long to create.
10:27They add an amazing amount of value for your site's users.
10:31My advice is to go ahead and create your print style sheets at the same time
10:35you're writing your other styles.
10:37This is going to ensure they get finished along with the rest of the site, as
10:40well as making it easier to apply print -specific styling to individual pages.
Collapse this transcript
Preparing modular styles
00:01Earlier in this title, we discussed the advantage of separating the styles in
00:04your style sheets into sections.
00:07By creating separate sections for items such as layout, typography, or page
00:11regions, you create more organized files and make editing and maintaining them easier.
00:16You can take that concept a step further by creating what's known as
00:19modular style sheets.
00:20The modular style sheets are created by separating the site's CSS into individual
00:26style sheets and then reassembling them at run time.
00:30Before we discuss how to assemble style sheets at run time, let's focus on
00:33preparing our modular stylesheets by separating our styles into separate files.
00:38So, I have the main.css open from the 04_03 folder.
00:42What we're going to do is we're going to separate out a couple of sections of
00:46styles that not every single page is going to need.
00:49We have a full set of styles for table design, and we have a full set of styles for forms.
00:54But not every page is going to be using tables, and not every page is going to be using forms.
00:59So, if that's the case, then really loading up those styles is pretty
01:02much wasted content.
01:04So, we're going to go ahead and separate that out, and then just let the site
01:06call for those styles when it needs them.
01:08So, the first thing I'm going to do is I'm going to go up to File and choose Save As.
01:13And I'm going to save this in the 04_03/_css directory.
01:18And I'm just going to call this one global.css.
01:22So, this is going to contain the majority of our global styles.
01:24Now, before we go too far down this road, I want to talk a little bit about strategy.
01:29The reason I'm separating out the table styles and the form styles is they are
01:33pretty easy to separate.
01:35In a lot of cases, when people are creating modular styles, they'll put their
01:38layout styles in one file.
01:40They'll put their typography in another file, their color treatment in other file.
01:43It's really up to you in terms of how you want to separate these styles out.
01:48You can separate them out like content, or you can separate them out by the type
01:51of selectors you're dealing with. Okay.
01:54So now what I'm going to do is go down and find my table styles.
01:56I'm going to scroll down all the way to around 600 -- line 698. All right!
02:00So, 683. Here we go.
02:04So, there is our data tables.
02:05We're going to go ahead and take that.
02:06so, I'm going to highlight all the way down to about line 738. There we go -
02:12just above this spotlight region. You want to make sure you'll getting that last
02:15curly brace there, too.
02:16I'm going to go ahead and cut those.
02:17So, Command+X or Ctrl+X, so there we go.
02:21I'm going to go ahead and cut that out.
02:23Now, create a new file, and we're looking for a new CSS file. Create that.
02:28And then go ahead and paste the table styles that you just cut from
02:33your previous CSS file.
02:35We're going to go ahead and do a save on that.
02:37We want to save that in the 04_03/_css.
02:42And we're going to save this one as table _styles.css, tables underscore styles.
02:49I am going to close that.
02:50Next, I'm going to go back into my global.css.
02:54I'm going to strip out some more styles.
02:55I'm going to go down to around line 705.
02:56I can found my form styling here.
02:59I'm just going to go ahead and highlight that all the way down, and there is
03:02a lot of form styles.
03:04Pass 900 to about 919.
03:07You can see right there the sidebar is the next divider that you have to worry about.
03:11Make sure, again, you're getting the closing curly brace, and cut that so Ctrl+X. There we go.
03:17We'll remove some of the extra space there.
03:19And then we're going to go ahead and create a brand-new file, CSS again.
03:23We're going to paste the code that we just cut into that file.
03:27And we're going to save this as form_ styles.css and go ahead and save that, as well.
03:38Close that.
03:39Our global CSS is considerably shorter. Where it was past 1,000 lines of code before,
03:43now, it only goes out to 130, so we're saving a little bit of weight there.
03:47I do want to go back up, however, and modify table of contents.
03:51I'm just going to go ahead and get rid of data tables, and I'm going to get rid of forms.
03:57Now, if we were doing this for real, we'd probably want to update the
04:00identifiers too, but as it is, they are fine where they are.
04:03Now, obviously we could have chosen from a variety of organizational strategies
04:07for these modular styles.
04:09By separating forms and tables, we remove hundreds of lines of code.
04:12The most were pages we don't even need.
04:15Now, we could have just as easily separated layout, typography color,
04:18any of those other groups that I was talking about, the exact same way.
04:20Well, now that we've our styles separated, we need to make sure each page in our
04:25site is getting exactly the styles that needs.
04:28We'll do that in our next movie, as we learned to build modular styles.
Collapse this transcript
Creating modular style sheets
00:01Now that we have separate style sheets for our tables and forms, we have a few
00:04options for how to apply them to the pages that need them.
00:08The first option would be to add another link on the page to the necessary page.
00:11So, let me switch over to Code View real quick, and you can see right there is
00:16the link to our main style sheet.
00:17So, if we needed to, we could add on the link tag below this that would link to,
00:20say, the table styles or the form styles, whatever we would need.
00:24Now, we do have a title attribute.
00:26Notice this title attribute right there.
00:28Now, that lets the browser know that this is the default style sheet.
00:32If you've got more than one link tag, it's really hard to blend all those guys
00:36together and let them know that those are the default style sheets.
00:39That can become an accessibility problem.
00:42So, we want to try to avoid that a little bit. All right!
00:45So, I want to switch over to our main. css, right up here in our related files.
00:50Honestly, it's going to take you forever to highlight this thing. There so many styles in it.
00:53So, here is my advice.
00:55Go ahead and highlight the character encoding and cut it.
00:58Then do a Select All, hit Delete, paste it back. Easy!
01:02Everything is gone.
01:03I'm going to go ahead and save the file,
01:05switch back over to Design View, and oh, no, all the hard work, all the months
01:10of labor in getting our styles written shot.
01:12Well, don't worry about it.
01:14Let's go back into our main.css.
01:16In the main.css, go down the next line, and we're going to do an @import.
01:21Now, if you've never seen the @import, this is how it looks.
01:23A couple of lines below the encoding character, you're going to type in @import.
01:27Now, as soon as you do that, notice that Dreamweaver recognizes it and changes the color.
01:31So, I'm going to type in a space, and then url.
01:34So, we need to indicate where these styles are located.
01:37What we're going to do is inside the parentheses here, I'm going to type in
01:40global.css, and then a semicolon.
01:44Okay, so if you remember, we pared down our main styles as global.css in
01:50the previous exercise.
01:51So now, using @import, we're basically telling this external style sheet, bring
01:55in those styles at run time and display them on the page. How cool is that!
02:00I'm going to do a Save All, and switch back over to Design View, and our
02:04styling is right back. Cool!
02:06So, our external sheet, main.css, is now actually bringing in global.css at run time.
02:12Notice that in the related files, global is showing up here, which is really cool!
02:16Now, you want to be careful about trying to daisy-chain these.
02:19You wouldn't want to do an @import in the global style sheet as well.
02:23The problem with that is a lot of browsers don't recognize any type of an
02:27@import that is more than one layer nested deep.
02:30So, you want to keep those on the top-level style sheets. All right!
02:33I'm going to go ahead and close all of our open files.
02:36After I've closed all my open files, I'm going to scroll up and open up the _css
02:41folder, and I'm going to open up main.css from there.
02:45Now, I know this is the file that we were just looking at, but it's now opened
02:48without being a related file, and I'm a little freer to do extra things with it,
02:52such as do a Save As.
02:54Okay, so here in our main.css, really, what we're bringing in is the global styles.
02:59We're going to need a version of this that's going to bring in the Table styles,
03:02and we need a version of this that's going to bring in the Form styles.
03:05So, let's go ahead and take a look at maybe the possibility of doing that.
03:09Let's do a Save As. Save it in the same directory.
03:13This time what I want you to do is save it as main_forms.css. There we go!
03:22In the main_forms.css, we're going to do another @import right below the first one.
03:27We're going to do @import url, and here we're going to do form_styles.css.
03:36So, we're going to just look right over here, and bring in the one we need. Cool!
03:40So now, this main_forms.css is saying, okay, I've got all the global styles
03:44inside me, as well as the form styles.
03:46So, if you have a page that's using forms, go ahead and link media rather
03:49than the other one.
03:50Now, I want to talk about something else here, too.
03:52You'll notice that both of these @ imports are importing a singular file that's
03:57found in this directory.
03:58One of the things you want to avoid is trying to do any type of importing
04:02past one level deep.
04:03What I mean by that is I wouldn't go under the global.css and put an @import
04:08in that one, because most browsers won't be able to drill down that deep and retrieve it.
04:12The other thing you want to be careful about here is the cascade.
04:15The order in which these styles are defined are the order they appear in the cascade.
04:18So, anything in these form styles that had a conflict would actually overwrite
04:22anything in the global styles.
04:23So, that's a very real concern when you're planning out how you're going
04:26to strip these styles apart and how you're going to work with them within the cascade.
04:30I'm going to go ahead and save that, and let's do one more Save As.
04:34Now, this time in the same directory, save it as main_tables.css, as well.
04:43Here, we're going to replace the form_styles.
04:44So, I'm going to delete that.
04:45Now, the reason I deleted it is because I wanted to show you an alternate
04:48method of using @import.
04:50I'm going to go my CSS Styles panel, and I'm going to click to attach a style sheet.
04:54I'm just going to hit Browse, and I'm going to browse to the 04_04/_css directory.
05:01Here, what I'm looking for is this table_styles.
05:04So, just like our forms, table_ styles has all of our table styling.
05:07Let me go ahead and click OK.
05:09Notice that Link is grayed out.
05:10The only thing available to us here is Import.
05:12So, when I click OK, I can see directly underneath that top one now, @import
05:16url("table_styles.css");. All right.
05:19We're going to go ahead and save that, and now we have our modular styles.
05:23We have one that's just bringing in all of our global styles.
05:25We have one that's bringing in the global plus the forms, and another one that's
05:28bringing in the global plus the tables.
05:30Now, as you could imagine, this is an incredibly simple example.
05:33You could go ahead and import multiple style sheets on this. All right!
05:37Now, let's show this in action.
05:39So, I'm going to go ahead and close all of these.
05:42I'm going to go over to my Files panel, and I want to scroll down and open
05:46up the Contact page.
05:47Now, currently the Contact page has a lot of forms on it.
05:50But if I scroll down, the forms look horrible, or at least they don't look the
05:55way that I want them to. Now, why is that?
05:57Well, remember, main.css doesn't have those in it anymore; it just has the global.
06:01So, what we're going to do is we're going to change the page that's being linked here.
06:05So, I'm going to switch over to Code View.
06:07I'm going to go up to the very top of the document.
06:09There is link href here.
06:10I'm going to change main.css to main_forms.css, just like that.
06:17I'll do a Save All.
06:20If I preview that in my browser, I now see that this one has the form styling,
06:25although the rest of the site doesn't need the extra code.
06:29So, we just sort of leave it off.
06:30Now, this approach is not going to work for everyone, nor is it appropriate for everyone.
06:35But for certain sites, you can certainly save bandwidth, increase organization,
06:38and that might be the most important part, and make modifying and maintaining
06:42styles easier by using modular style sheets throughout the site.
06:45So, one team member could be working on the layout while another team member
06:49could be working on color, and
06:50you don't have to be worry about overwriting anything.
06:51Now, as with many things, proper planning is required in order for styles to
06:55render properly and not conflict with other modular styles at run time.
07:00As a matter of fact, that could be an absolute nightmare!
07:02Now, be sure to think through the execution of modular styles carefully, before
07:06attempting to implement them into your site.
Collapse this transcript
Checking browser compatibility
00:00Before deploying your styles, you need to make sure that they work properly
00:04across multiple browsers. Although there is no substitute for actually testing
00:08your pages in the browsers themselves,
00:10Dreamweaver has a browser Compatibility Check feature that can often find
00:14problems in your CSS that you might otherwise miss.
00:17This feature also allows you to target specific browsers, allowing you to check
00:22your pages against browsers you might not have installed on your system.
00:25So here I have the index file open from the 04_05.
00:30And I am just going to go ahead and run a browser compatibility check.
00:33You can find that right up here in your Document toolbar.
00:35And before I run it, I am going to check on my settings.
00:38Now your settings allow you to determine which browsers you want to check against.
00:42I am not going to worry about Internet Explorer for Macintosh.
00:45And I am not going to worry about Netscape too much either.
00:48And notice for other browsers, you determine which version you want to start
00:51checking with and then kind of go out from there.
00:53So I am going to go ahead and click OK.
00:54As soon as I do this it's going to go ahead and run the check for me.
00:58And I get to see the results down here in the Browser Compatibility panel.
01:02Now I could also just go ahead and go over here and say, Check
01:05browser Compatibility.
01:07And I could just hit the play button in this panel, as well; it would give me the same results.
01:11Okay, so problems here.
01:13It found one error in main.css.
01:16Before I move on, I really want to figure out what's going on there.
01:19So I am going to switch over, up here in my related files, to main.css, and I'll
01:24just switch to Code View, so I can really see what's happening here.
01:26Now you can check for browser Compatibility if you're on a HTML file, or if
01:30you are on a CSS file.
01:31And sometimes you are going to find more information by checking just the styles.
01:35So this really isn't a bad idea.
01:37I am going to come in and run another browser Compatibility check.
01:41Here I find some specific issues. On line 459,
01:45I have an unsupported value called transparent.
01:47I don't know about that. Let's go and see.
01:49So I am go down to line 459, and sure enough, right there is color transparent.
01:56Now transparent is not a proper value for the color property.
02:00It is, for background color, but not foreground color.
02:02So this particular property actually won't do anything in any of the browsers,
02:06so I am just going to go and get rid of that, so I can avoid causing any type of
02:09confusion in certain browsers.
02:11Now it's also telling me that on line 1,045, it had trouble parsing the styles.
02:16Now that could be a real trouble.
02:17So I am going to scroll down to line 1,045. Here we go.
02:24And that really looks - hey, look at that.
02:27We have got two semicolons in a row here.
02:29That's really weird.
02:30So I am going to get rid of the extra semicolon.
02:33And then I need a semicolon here, so I am going to go ahead and add one here.
02:36All right, so that was just a syntax error.
02:39It happens when you're typing your CSS.
02:41You are going to leave things off, and it's nice to know that Dreamweaver can
02:44catch that for you so easily.
02:46I am going to go ahead and save this file.
02:48And I'm just going to run the browser Compatibility check one more time.
02:51And now no errors come up, good.
02:53So we know that at least the external style sheet, from that standpoint, is
02:56looking pretty good.
02:58I am going to go back to my source code for index.css, and it really doesn't
03:02matter whether you're in Code View or Design View, to be quite honest with you.
03:05I am going to go right back up and do a Browser Compatibility check again.
03:10Okay, so I am not seeing those issues with my external style sheet anymore,
03:14but I am seeing something called a Float Drop Problem.
03:17Now what's really cool about this panel is if you notice on the right-hand side
03:19it says if a container, including the browser window itself, is not wide enough to
03:24accommodate both a float with a specified width and any content with a specific
03:28width that follows it, the content after the float will drop below the float
03:32rather than wrapping around it.
03:33Essentially what's that's trying to say is if the content inside of a float
03:37is going to be wider than the float itself, then it's going to cause column drop, or
03:41it's going to cause some elements to drop underneath it.
03:43That could be a real problem.
03:45But I want to know who Dreamweaver thinks it's a problem for?
03:49So I am going to look on line 93.
03:50I am going to switch to Source Code.
03:52And I am going to scroll down to line 93.
03:53And by the way, you can double-click on these.
03:56It will take you right to that spot.
03:57So it's thinking that my footer is the problem.
04:00Well, you know, really, honestly, the footer, it's got these 3 columns 1, 2 and 3.
04:05Their width is equal to the width of the footer itself.
04:08So what the Dreamweaver is trying to tell me is like, hey, you know, if you put
04:10something inside here, this is going to be wider than that.
04:12It's going to drop the columns.
04:13You didn't know that, right?
04:15So it's not always an emergency; sometimes it's just saying, hey, you might want
04:19to take a look at this.
04:20Now if you do have a real bug, you can click on this View solutions right here,
04:24and it's going to take you to Adobe's Web site, to the CSS Advisor, which is
04:29sort of an aggregate of all these bugs and issues that come up.
04:33So it's a really nice place to kind of go just check out and read about some
04:37browser compatibility issues, and try to find some solutions for it.
04:41Now this particular problem doesn't have any type of hacks or solutions that we
04:44can use other than the just-don't-do- it solution, but to be honest with you, I
04:49know that my footer is going to stay exactly the way it is.
04:51I am not going to put any extraneous content in there.
04:53And so in this case, it's nice for Dreamweaver to give me a warning about it,
04:57but it's really not something I need to be concerned with.
05:00So if you're tired of getting messages like this, and I am just going to go back
05:03into Dreamweaver here,
05:05I can go right over here to the Float Drop problem and right-click and say, you
05:09know what, go ahead and ignore that particular issue.
05:12And what it will do is whenever you run a browser Compatibility check, from that
05:16moment forward, it will not report back on that problem.
05:19It just ignores it.
05:20Now from time to time, if you move from one site to another, you might want to
05:24turn it back on, because you might want to really see if that is an issue.
05:27So I can go right back here to my Browser Compatibility.
05:30I can click on this little play button and I can say, Edit Ignored Issues List.
05:35When I click on that, it's actually going to open up an Excel Spreadsheet, and
05:39it's going to show me any of the conditions that I told it to ignore.
05:43If I wanted to go back to actually reporting on those, all I have to do is
05:46delete the issue tag, save the file, and now the next time I check, it will
05:53actually go in and check for that specific issue.
05:56Now I do want to mention that the Browser Commendably check is not going to pick
06:00up on every single error or browser rendering error on your page.
06:04And it sometimes is not really going to offer you the specific advice you need
06:09in order to fix the problems that it does find.
06:12It does, however, do a really great job of picking up on errors and problems
06:16within your code that you might have missed, especially when targeting older
06:20browsers, or browsers on systems other than the ones installed on your own.
Collapse this transcript
Using conditional comments for Internet Explorer
00:01One of the most annoying aspects of running CSS is the annoyance of having
00:05to deal with browser incompatibility in writing hacks or alternate styles
00:09for various browsers.
00:10Although all browsers have their individual quirks, by far the worst offender
00:14is Internet Explorer.
00:17Entire Web sites are dedicated to dealing with errors in that
00:20particular browser.
00:22Now one way to deal with IE Errors are to place hacks and browser workarounds
00:27directly within your CSS.
00:29This creates messy code, makes your IE- specific workarounds harder to find and
00:35makes editing your styles even more difficult.
00:37A better way of dealing with Internet Explorer is to place those specific styles
00:40in external style sheets, and then pass them to Explore through the use of what
00:45we call conditional comments.
00:46So here I have the tours.htm file open.
00:50And what I want to do is go ahead and just preview this page in Internet
00:54Explorer, so we can see what the issue is.
00:58So here we are in Internet Explorer, and right now everything looks fairly okay.
01:02But if I scroll down, ooh, there is a problem. Right after my tour descriptions,
01:07things just start falling apart, and they go from bad to worse.
01:10Okay, so that's obviously not the user experience we are going for within
01:14Internet Explorer 6.
01:16So let's go see how we can fix this.
01:18So here we are, back in Dreamweaver.
01:21And I want to show you that inside the _CSS directory,
01:26I have a style sheet already written, ie6.css, and what that's doing is it's fixing a few float
01:33problems that Internet Explorer had in dealing with those tour descriptions.
01:37So a lot of times, it's trial and error.
01:39Sometimes you are going to know specific issues to Internet Explorer and kind
01:42of how to fix them.
01:43But you notice that we are going ahead and placing them in its own style sheet,
01:47called ie6, and we are commenting those guys out.
01:50So we really don't want to pass these styles to anybody but Internet Explorer 6. Okay.
01:55I am going to go ahead and close this and go back in tours really quickly.
01:59Now what I am going to do is I am going to switch to Code View.
02:01And I am going to highlight the link tag for my main styles, and I'm a copy that.
02:07And then on this blank line just below my print style sheet, I am going to paste it.
02:10Now the reason I am doing that is because I want to import my Internet Explorer
02:136 styles in, and I just don't feel like typing all that out.
02:16I am going to highlight main .css and change it to ie6.
02:21And then for media screen projection is fine.
02:24But I want to replace the title.
02:25I don't want any browser to think that these are the main styles.
02:28So I am going to get rid of that title attribute.
02:30So this is what it should read: link href _css ie6 css.
02:35And the rest of it I am just going to sort of leave from before, except for the
02:39title attribute, and we are moving that.
02:41Now I am going to save this, and if I preview this in another browser, let's say
02:45Firefox, for example, we are going to end up with some real problems.
02:48As you can see, we started having some issues as we scroll down and these guys
02:53-- the spacing is just going all crazy.
02:55The reason that spacing is going crazy is because of the fixes that we did
02:58for Internet Explore 6.
02:59What works for ie6 is not going to work for everybody.
03:03So we only want these styles to be passed to that browser.
03:07So one of the ways to do that with Internet Explorer is through the use of
03:10conditional comments.
03:11Let me show you what I mean.
03:12Go ahead and highlight that link tag.
03:14You want the whole thing highlighted, from sort of finish.
03:16And this of course is the link tag that's dealing with ie6.
03:19And then go over to your Snippets panel.
03:21Now this is one of the pre-built Snippets.
03:23It has nothing to do with what the snippets we created earlier in our title.
03:26I am going to go ahead and open up the Comments Snippets region.
03:30Now these are really neat.
03:31These have HTML Comments.
03:33They have CSS Comments.
03:34They have all sorts of cool stuff.
03:35I just want to expand that a little bit more so I can read these better.
03:38So notice that we have all sorts of interesting comments here, Greater Than or
03:41Equal to IE7 Conditional, IE5 Mac Comment, If IE6 Conditional, If Less Than IE8.
03:49So this is really cool.
03:50I am going to do Less Than or Equal to IE6.
03:52So with that highlighted, I am just going to double-click Less than or Equal to IE6.
03:56You'll notice what it does is it surrounds that link tag with this, If Less Than
04:02or Equal to IE6 Conditional statement.
04:04Now every single browser in the world is going to ignore that, except
04:08for Internet Explorer.
04:09It's going to look at those conditional statements and say, ooh, you are
04:12talking to me, are you?
04:13And then it says, okay, I need to add this link.
04:15So what's going to happen now is when I save this file, if I preview that in my
04:20browser in Firefox, I notice that it don't really have any issues.
04:26However, if I go back to Internet Explore, I am just going to scroll down a
04:29little bit, and sure enough, everything looks fine.
04:32All the spacing looks the way I needed to; everything looks really great.
04:35All right, cool. So now I am going to go back into Dreamweaver.
04:38And what I'd really like to do is go ahead and change this site-wide.
04:43It works on this page, but it doesn't work on the rest of them.
04:45And there really isn't an attached style sheet sitewide, and there is certainly
04:49not a use conditional comment sitewide.
04:51So we are going to use Find and Replace to kind of help us out with this.
04:53What I am going to do is I am going to highlight all of my link tags, starting
04:57with main.css, and going to the conditional comment, I am just going to copy
05:00them, so Ctrl+C or Command+C copy.
05:03Then I am going to take the conditional comment and just strip it out and save my file.
05:08Now why am I doing that?
05:10Well, because I don't want it to appear on this page twice when I do my find and replace.
05:14That's why. So I am going to go up to Edit and choose Find and Replace.
05:16Here I am going to choose Entire Current Local Site, and for Replace, I am going
05:22to go ahead and paste the code that we copied earlier.
05:25So it should have both link tags and the conditional comment, and then for the
05:29Find I am going to paste it again, but this time, I am just going to delete the
05:34conditional comment.
05:35And be sure not to hit Return or Enter with that.
05:39You want to just hit Delete or Backspace to get rid of that stuff.
05:42So now double-check what's going on here.
05:44I am looking in the Source Code.
05:45I want to replace the entire current local site.
05:47I am going to find those two link tags to the main.css and the print.css.
05:52And I am going to replace them with both of those titles, plus the ie6 down there, okay.
05:57So I'm going to go ahead and hit Replace All.
05:59It's going to warn me.
06:01It's going to say I can't undo this, are you sure?
06:03I am going to say Yes.
06:04And now it's going to go add it to this file.
06:06You can actually see it added to the code, but look at the Search dialog box.
06:09Look how many it's added to.
06:10It's added to a bunch of them right there.
06:12That's really cool.
06:13Now I would also need to repeat this procedure by going into the subdirectories,
06:17like explorers and resources, and doing the same thing, because they are going
06:21to have a slightly different document-relative link.
06:23So they weren't found in this Find and Replace.
06:24We would need to do a specific Find and Replace for each subdirectory level.
06:28And it works just to be fine, and be a lot faster than doing it by hand.
06:32Okay, well conditional comments, these things are great.
06:35Using them for Internet Explorer- specific style sheets is going to allow you
06:38to pass all the ultimate styles necessary for Internet Explorer to function
06:42properly without having to clutter up your existing code, or worrying about other
06:46browsers being affected by the styles.
06:48I mean, that's the best part to me is that the other browsers just ignore them.
06:51It's also a nice way of getting all of the Internet Explorer-specific styles in
06:54one place to make updating and editing them even easier.
Collapse this transcript
Optimizing CSS with Dreamweaver
00:01Throughout this title, we've talked about writing clean, organized styles that
00:04make it easier to maintain and troubleshoot your code.
00:07While this makes our styles easier for us to read, it also tends to make them a
00:11little larger than they need to be.
00:13To save file size, many designers optimize their CSS before deploying it by
00:17stripping out comments and removing white space.
00:20This can cut your styles and file size almost in half.
00:23And it can produce serious savings in bandwidth for larger sites.
00:27Let's take a look at some of the options that we have for optimizing our CSS
00:30before deploying it on our site.
00:32So I have the main.css, and if I take a look over in the Files panel I can see
00:37that our main.css is 20K, which you know that's not that big, but if enough
00:42requests are made over the course of a day, that can take up some bandwidth.
00:47So what I want to do is change some of my formatting settings here in Dreamweaver.
00:51Now we will notice that we got over 1,000 lines of code, over 1,100 be exact.
00:56And if I go up to Edit, I go to me Preferences,
01:00or if you are on a Mac you are going to go to Dreamweaver and
01:02choose Preferences,
01:03I can go to the code formatting category.
01:05So I switch over to code formatting category and click on the
01:08Advanced Formatting CSS. There we go.
01:10Now currently I've got Each property no a separate line, and I've got All
01:14selectors for a rule on same line.
01:16So I am going to deselect Each property on a separate line.
01:18That's going to go ahead and place it up there.
01:20I like the All selectors for a rule on same line.
01:22That's going to save me some space.
01:23And then I am going to strip out the Blank line between the rules. Okay cool!
01:26So again, looking at the preview that's going to be a lot harder to read, but,
01:30and it's okay because I'm trying to compress it for a deployment, knowing that I
01:35could go back and change the formatting setting anytime I want.
01:38I can go ahead and click OK. Click OK again.
01:40And now if I look at my code, I notice that, we really don't have any change.
01:44Well, that's because you have to apply the formatting.
01:46So I am going to go right over here to my Code toolbar,
01:49click on my Show More so I can see my Format Source Code.
01:53And I am going to apply my Source Formatting.
01:55Now when I do that now, I am down to 246 lines of code.
01:59Now that's a significant savings from ,say, 1100 lines of codes.
02:02So I'll do a Save All.
02:05And now if click over to my _css folder and hit Refresh, I notice that I've
02:09saved a whopping 1K.
02:11It went down from 20 to 19.
02:13Now honestly this is going to help you more for larger CSS files, files that
02:17really are thousands of lines of code.
02:19And honestly, we saw some waste here.
02:21We have a lot of comments up top
02:23that it's going to help you and I when we are working on our styles, but really
02:26doesn't help a browser at all.
02:28So those could afford to be stripped out.
02:30Now that leads me to another strategy that we could do.
02:34You could have one CSS file that you use for writing and then another one for deploying.
02:38So you would have a non- compressed version of your style sheet
02:40that you would work day-to-day on, and then every time you needed to go ahead and
02:44upload it you could compress it down, and then upload it to the to a number of sites.
02:47A lot of people work that way.
02:49But really, it only depends on how much savings you need to do.
02:52Now in addition to Dreamweaver helping you out by sort of formatting the code
02:56for you, you can also run it through a compressor service online.
03:00And there are a ton of these online.
03:02If you just go up and search, or do a Google search for optimizing CSS, you are
03:06going to find a bunch of these.
03:07I'll show the one that I use.
03:08I am going to go ahead and select and copy the code.
03:12And then I am going to open up a browser.
03:15And I am going to cssdrive.com/ index.php/main/csscompressor.
03:24Now if you really want, you can go to just CSS drive and do a search on that
03:28site or look around.
03:29Now this is a nice little free service that you can use.
03:33And I'm going to say I want Super Compact.
03:36I am going to strip all comments out.
03:39And then I just insert the CSS code.
03:41You can also point to CSS that might already be on a Web site.
03:45So I am just going to go ahead and paste my code that I copied earlier there.
03:49And I am going to tell it to go ahead and compress it.
03:51Now it's going to take it a second, and as soon as I do, it gives me this result.
03:55Now what's really cool about this is notice that it's telling hey your original
03:59size was around 19K. We knew that.
04:01Your compressed size is now around 14K.
04:03We saved 23% of our space.
04:05Well just that's not too terribly bad.
04:07And now you can see that this is incredibly hard to read.
04:09Okay so I am going to go ahead and copy this, so Command+A or Ctrl+A and
04:15Command+C or Ctrl+C. I am going to leave this window open in case we need
04:17to come back to it.
04:18Then I am going to go to my main.css.
04:21Now ion this one I am going to change my Source Formatting back to where
04:24something that I can actually read.
04:26So I am going to go back to my Preferences and bring up my Code Formatting.
04:31And again, Each property on a separate line, Blank line between rules, we want that.
04:35Click OK.
04:36And apply the Source Formatting.
04:38Now the reason we did that is to get sort of this human readability back to this.
04:42I am going to do a Save As, actually.
04:45I am going to do a Save As.
04:47And in my _css folder in the 04_08, I am going to say this is main_noncompressed.
04:56All right, there we go. Close that.
05:03And I am going to go back and refresh that.
05:06I'm going to open up main.css again, and I'll select everything on the page here,
05:11so Ctrl+A, and then just replace it with the code that we got from our CSS compression.
05:17And notice that everything here is on the same line.
05:19So technically we really only have one line of code.
05:22All right I am going to save this, go back over to my Local Files panel and do a refresh.
05:29So notice that now we have a main_ noncompressed that we could write into our corrections.
05:34And then we have the main.css, which could be uploaded in its 14K.
05:37So yes, it's not that huge of a savings, it's only 6K, but on some sites that can
05:42be a deciding factor.
05:44And this is really useful when your style sheets are a lot larger and a lot more complex.
05:48But honestly, the question you have to ask yourself is is this process worth the effort?
05:53Well the real key to this technique is keeping a human readable version of your
05:57styles, comments and all, for development work,
06:00and then recompressing it each time you need to upload your styles.
06:03Now this can be time-consuming.
06:05And in a team environment it offers just one more thing that could potentially be
06:09forgotten about during an update.
06:11So in the end, the decision to optimize your styles is totally up to you.
06:14But it's good to know that Dreamweaver offers you a quick and easy way to add a
06:18degree of optimization, without having to jump through any hoops at all.
Collapse this transcript
Conclusion
Goodbye
00:00Thanks for watching Dreamweaver CS5 Managing CSS.
00:05I hope you've enjoyed going through these exercises, and have a better idea of
00:08how Dreamweaver can help you create, organize and deploy your site's styles.
00:13If you are new to coding, I hope you felt a little bit more comfortable in
00:16utilizing Dreamweaver's powerful coding tools.
00:19If you mainly rely on code, I hope you found several tools in Dreamweaver that
00:23can speed up your CSS workflow.
00:26For more on Dreamweaver, Web Design and CSS, be sure to check out the rest of
00:31the Dreamweaver and CSS-based titles in the lynda.com Online Training Library.
00:36Thanks for watching.
Collapse this transcript


Suggested courses to watch next:

CSS Fundamentals (3h 14m)
James Williamson

Typography with CSS in Dreamweaver (2h 30m)
Joseph Lowery


CSS3 First Look (6h 34m)
James Williamson


Are you sure you want to delete this bookmark?

cancel

Bookmark this Tutorial

Name

Description

{0} characters left

Tags

Separate tags with a space. Use quotes around multi-word tags. Suggested Tags:
loading
cancel

bookmark this course

{0} characters left Separate tags with a space. Use quotes around multi-word tags. Suggested Tags:
loading

Error:

go to playlists »

Create new playlist

name:
description:
save cancel

You must be a lynda.com member to watch this video.

Every course in the lynda.com library contains free videos that let you assess the quality of our tutorials before you subscribe—just click on the blue links to watch them. Become a member to access all 98,695 instructional videos.

start free trial learn more

If you are already an active lynda.com member, please log in to access the lynda.com library.

Get access to all lynda.com videos

You are currently signed into your admin account, which doesn't let you view lynda.com videos. For full access to the lynda.com library, log in through iplogin.lynda.com, or sign in through your organization's portal. You may also request a user account by calling 1 1 (888) 335-9632 or emailing us at cs@lynda.com.

Get access to all lynda.com videos

You are currently signed into your admin account, which doesn't let you view lynda.com videos. For full access to the lynda.com library, log in through iplogin.lynda.com, or sign in through your organization's portal. You may also request a user account by calling 1 1 (888) 335-9632 or emailing us at cs@lynda.com.

Access to lynda.com videos

Your organization has a limited access membership to the lynda.com library that allows access to only a specific, limited selection of courses.

You don't have access to this video.

You're logged in as an account administrator, but your membership is not active.

Contact a Training Solutions Advisor at 1 (888) 335-9632.

How to access this video.

If this course is one of your five classes, then your class currently isn't in session.

If you want to watch this video and it is not part of your class, upgrade your membership for unlimited access to the full library of 1,899 courses anytime, anywhere.

learn more upgrade

You can always watch the free content included in every course.

Questions? Call Customer Service at 1 1 (888) 335-9632 or email cs@lynda.com.

You don't have access to this video.

You're logged in as an account administrator, but your membership is no longer active. You can still access reports and account information.

To reactivate your account, contact a Training Solutions Advisor at 1 1 (888) 335-9632.

Need help accessing this video?

You can't access this video from your master administrator account.

Call Customer Service at 1 1 (888) 335-9632 or email cs@lynda.com for help accessing this video.


site feedback

Thanks for signing up.

We’ll send you a confirmation email shortly.


By signing up, you’ll receive about four emails per month, including

We’ll only use your email address to send you these mailings.

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.

By signing up, you’ll receive about four emails per month, including

We’ll only use your email address to send you these mailings.

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked