Join James Williamson for an in-depth discussion in this video Style formatting options, part of Managing CSS in Dreamweaver.
Everyone, as they say, likes to work a little bit differently. Although the foundation of how Dreamweaver manages CSS is fairly static, there are some ways that you can customize this process to meet your individual preferences. To a degree, Dreamweaver allows you to customize how your styles are created, presented, and formatted. Before we get too deep into the multiple ways to create styles in Dreamweaver, let's take a moment to go over Dreamweaver's CSS Preferences and see how we can customize them to meet our specific workflows. I'm just going to scroll around this a little bit to look at the formatting.
You can see that our styles are presented with the selector on one line, and then each of our properties is displayed on a separate line. You'll notice that some of the selectors have spaces between them and some don't. So when these styles were created, and there wasn't a whole of thought given to exactly the formatting and spacing options that we wanted for these. And different people have different preferences, in terms of how they would like their styles formatted. Well, you can control that. So what I'm going to do is I'm going to go up to Edit and choose Preferences.
Now if you're on the Mac, you're going to want to go to Dreamweaver and choose Preferences. So there aren't very many differences between the two interfaces, but that's one of the big ones. So I'm going to open up my Preferences. Now, the first one I want to take a look at is the Code Coloring category. You can see behind this that our CSS has certain colors that mean things. So we have sort of magenta for the selectors, a dark blue for the properties and a lighter blue for the values. Notice that we can edit that scheme. So I'm going to come right over here to Code Coloring. For Document type, I'm going to go down and choose CSS, and I'm going to click Edit Coloring Scheme.
Now, in the bottom of this dialog box, I get a preview of what the coloring scheme is. Now, you're free to go ahead and change this to whatever you want; for example, if I didn't like the magenta color for the selectors, I could select that and then choose something else entirely. The problem with that though, if you're in a team environment, you're more than likely going to get used to looking at your styles a certain way. When you get on somebody else's machine, and they have their Code Coloring changed, it can be kind of abrupt. So you might want to be kind of careful about changing any of these things. One of the things that I've always found to be a little confusing is the fact that my properties are sort of a dark blue, and my values are a lighter blue, but there's not a whole lot of difference between the two of them.
So I could grab that, if I wanted to, and maybe make them just a tad bit lighter. Now, there is a really nice visual difference between the two of them. There's a nice contrast there and even though I can still read it, I'm not going to mistake one for the other. So I'm going to go ahead and click OK. Now you can come back and change those preferences at any time. So if you decide after a while looking at it, you don't like it that way, it's easy enough to go back and change. Now the next thing I want to do is go down to my Code Hinting. So in my Categories, I'm going to choose Code Hinting, and I'm just going to make sure that the check box is set here for CSS property names.
You can see all of the different languages and elements that Code Hinting is available for. Now, the default is that CSS property names is going to be turned on. So the only time that's not going to be available is if somebody purposely came in here and turned it off. So if you're working in Dreamweaver, but if you don't see them, you can come right back here into Preferences, and turn them right back on. Let's do one last set of preferences here. I'm going to go to my Code Formatting category, right there, and although the majority of these preferences are talking about HTML, I do have a CSS button here that I can select. So I'm going to go ahead and click that.
Now this changes how Dreamweaver's going to format your CSS source code. So one of the things that I'm going to do is I'm going to turn off each property on a separate line, and then I'm going to turn on Blank lines between rules. You get a nice preview here of what this would actually like. Now, that would be a little bit harder for me to read, so I'm going to turn that back on and keep my Blank line between rules. I'm going to go ahead and click OK. Click OK again, and you see nothing changed. Well, that's OK because nothing is going to change in your Code Formatting until you actually apply the source formatting to your code.
Now, any new code that we create would have those properties, but if you want code that you've already created to look that way, here's all you have to do. I'm going to over to my Coding toolbar, right over here, and since I don't have enough stream real estate to show this, I have to click the Show More icon. If you've got a very high screen resolution, you can probably see this icon without having to do that. But I'm looking for this little paint bucket with the tags. That is Format Source Code. I'm going to go ahead and click that, choose Apply Source Formatting, and now even though it jumped me all the way down to the bottom of the page, I can scroll back up, and we can see that now, for example, all of these properties are on the same line, but I've got nice spacing between all of those guys, and that is extremely readable for when I'm working in, and editing my CSS code.
Now I know that not everyone likes to work with CSS the same way. That's okay. I think it's great that you can change how Dreamweaver displays your CSS to match your personal preferences, and as we'll see a little bit later, these properties can greatly assist you in deploying more efficient styles as well.
- 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