Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
In this chapter we will explore Dreamweaver's powerful CSS Authoring and Management tools. Dreamweaver has made working with CSS a fundamental part of almost every workflow within Dreamweaver. As such, the options around creating and modifying your CSS can sometimes be a bit overwhelming. Fortunately, Dreamweaver has multiple preferences that allow customization of exactly how your styles are created, presented and formatted. Let's take a moment to go over these Preferences and customize how Dreamweaver goes about creating your CSS before we get into the actual tools themselves.
So to illustrate these preferences, I am going to work with just an external CSS file. I have the main.CSS file open from the 06_01 folder and it looks like a really complex rule, but it's really not. The only thing going on in this particular rule is we are describing what size the font should be, which font should be used for the headline, the amount of space through margin that the headline should have with other elements on the page, how much padding we should have inside actual heading itself and then a border and what that border should be all the way around the element. Now obviously here in this case we are just looking at the actual code itself.
How the code is generated is actually really, really important in terms of how efficient the code is, how easy it is to maintain. And if you're going to be using any of the tools inside of Dreamweaver they are going to create this code for you automatically, you want to take a little bit of control over how those code is created, so that it is created to your own personal standards. So the first thing I am going to do is go up to my Preferences. And I can go to Edit and choose Preferences, obviously on the Mac you will be going to Dreamweaver and choose Preferences. The first thing I want to show off is Code Coloring. I know we looked at this a little bit earlier when we were talking about Coding inside Dreamweaver, but I want to show you that it also applies to CSS as well.
So if I click Code Coloring, I can come down in the Document type and choose CSS. I can also choose to Edit the Color Scheme. So here, if I wanted to change this color scheme, perhaps you are somebody who's used to coding in another application and you are used to see your CSS looking a slightly different way, it's fine for you to come in here and change this. For example, the Properties and Values, they're a different shade of blue, but they are still very close to each other. So sometimes it's very difficult to tell when a semicolon (;) has been left off. So if you wanted to you could select Property and you could come up and you could choose maybe even a darker blue and if I click OK and click OK again, I can see that now I have a much darker blue for my Properties than I do my values and it's a little bit easier to see.
You're free to change that any time that you want, but of course, there's no sort of Reset to default button on this, so be very careful about changing them, if you're in a team environment. Somebody else might not be able to come back in and change it to the way they were used to working if they don't remember what everything is as well. Now thing that I really want to focus on in this movie is how the properties that you're seeing here are actually created by some of the various tools and procedures within Dreamweaver. So there are a lot of different ways to create styles inside of Dreamweaver. For instance so you could do it to the CSS Styles Panel or through their Properties Inspector and we are going to experiment with both of those particular methods in just a moment.
But when you're creating those styles visually through dialog boxes, obviously at some point Dreamweaver has to come in here and write the code. And you want to be in total control over how Dreamweaver generates that code. So I am going to go back up to my Preferences and this time I am going to come right down to CSS styles category, it's about midway down. The first set of options I have in this Preference are when I am creating CSS rules, should I Use shorthand notation or not? Now the code that you're looking at in this rule is obviously not using shorthand notation. Now if you are not familiar with CSS, and you are wondering what shorthand notation is; shorthand notation means instead of writing four separate properties for margin like we are doing here, where we explicitly state the top right and bottom and left margins, we just give it one margin declaration and pass the values into that.
It's a little bit more efficient in terms of writing your CSS. It's a lot more efficient in terms of maintaining and it certainly is going to save a little bit space and make your overall CSS file smaller. So it's a really good thing for you to do within your styles. So what I am going to do is I am going to go ahead and turn on Shorthand notation for everything, except for font. Now you will also notice that currently we are using shorthand notation for font. The font shorthand notation allows you to set the font style, the font weight, the font variant, the font size and the font family itself.
In this case the font size would be 1.4ems, while the font family would be Arial, falling back to Helvetica and sans-serif if Arial wasn't available. Well, we have left some stuff off here in this declaration and that's actually pretty common. But what we have left off is we have left off whether this should be bold or not, whether the font style should be italic or not or whether font variant, whether we should be using small caps. The problem with leaving that information off is that it assumes that you want the default, which in this case would be normal. So what happens when you use font shorthand notation is that sometimes you are overriding rules in a way that's totally unintended.
I have nothing against using it, Ijust want to be very explicit in terms of when I use it, I don't want Dreamweaver to go ahead and use font shorthand notation for me every single time and make a font declaration, because I may not want it to overwrite a rule that's a little further up the cascade. So that's something that I want to control myself. So I make sure that, you know, when Dreamweaver is actually writing in styles that it doesn't use shorthand for font notation. Now you may feel the exact opposite of me and that's the great thing about this is you have that option to say yes, I want to use shorthand notation there or no I don't.
You also control exactly when shorthand notation is used or not. You'll notice that the next set of options right down here for Use shorthand, our options are: If the original used it, according to all the settings above and then we also have the option of opening CSS files when modified. Now essentially what that is doing for us, is it's saying okay, do you only want me to use shorthand notation if the original rule itself, if I modify that rule if it used it, or should I go ahead and do it every single time I write a rule. I do like doing the According to settings above, so that every single time you write a rule, regardless of whether you are writing one from scratch or modifying the existing one, that it will go ahead and use the shorthand annotation settings.
The other option that we have here is when double-clicking a rule in the CSS Panel which we are just about to do, how would you prefer personally to edit that rule? Would you rather Edit it using the CSS dialog? That's a dialog box that comes up, that lets you Edit those Properties visual. D you want to Edit using the Properties pane which is a pane with in the CSS Styles panel or Edit using Code View. So if you're the type of person that really likes to hand code, you don't like to do a lot of things visually, you can click on Edit using Code View, when you double-click on a rule, it will jump to that rule within the code itself and bring that selector up.
If you leave it where is the default, which is what I am going to do, where it says Edit using CSS dialog; that's going to bring up the CSS rule definition dialog box and allow you to edit those rules visually. Okay, so I'm going to leave those Preferences the way I have them right there and click OK. And then we are going to see this shorthand in action. What I am going to do is I am going to come up to my CSS Styles panel and open that up. There is only one rule in the document, so it's really easy to find it, that's the h1 rule. I am going to double-click that. Notice, because of the Preference that I had setup, it brings up the CSS rule definition dialog box.
Now this may seem kind of weird to you right now because we are just editing a CSS file. But if we were on an HTML file that has an External CSS file attached to it, it wouldn't jump over to the External CSS document, it would just go ahead and open this up. And this will then allow me to Edit the rule and then click OK and continue doing what I'm doing. So also for people that are new to CSS, this is a nice visual way to edit Styles without having to worry about knowing the exact syntax of CSS. It's a very nice way sort of easing yourself into that, if you will. All right, what I am going to do here is I am going to change the font size to 1.2em, then I am going to go to the Box model category which is over here on the left hand side and I am going to change my Padding and I will change that to 12 pixels.
And notice that you've got the pull-down menu here, but if you want, if you don't want to have to stop to grab this pull-down menu, you could just type in 12px with no space, and when you hit Tab, notice it will resolve that for you. I am also going to change my Top margin, I am going to make that 2em and I will leave the Bottom margin at 1 and then finally I am going to go to my Border. And I am going to change my border so that instead of 1 pixel, it's 2 pixels all the way around. So essentially I've modified all of the properties that exist within the rule, I have modified some of the font declaration, I have modified the Margin, the Padding and Border.
So when I click OK, it's going to update the rule that we have on the page here, but remember it's going to update it using the Preferences that we just set. So when I click OK, I can see that now I have a much more efficient rule in terms of the size it's taking up and in terms of the actual number of properties that I would have to modify if I were doing this by hand. Although I do want to point something out; you will notice that the Margin, Padding, and Border now only occupy one property a piece, instead of like the four properties separately that they used to occupy, but look at the font. Notice that because I turned the Preference for font shorthand off, it actually took the font declaration, which was using shorthand property before, and it now split it out into the individual components, so font family and font size are now being defined separately.
And so, now in Dreamweaver I have it setup, so that any time a rule is modified or created through some other means than hand coding, it's going to format the syntax exactly the way that I want it. Now, not everybody likes to work with CSS the same way. Some of you may have different preferences than me. So I think it's great that Adobe makes it so easy for us to get Dreamweaver's workflow to match your own personal preferences.
Get unlimited access to all courses for just $25/month.Become a member
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.