Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
Applying multiple class attributes to elements is a very common task in web design. However, until CS6, we've never had a way to apply multiple classes to elements directly within the Dreamweaver interface. Thankfully, not only does CS6 add this capability, it also adds it across all areas of the interface, making it easy to do no matter how you like working with your CSS. So with the file that we're going to be working on here, the index.htm file, I've turned Style Rendering back on, but I'm looking at the file in Design View and not Live View and that's going to help me select the elements that I want to apply multiple classes to.
Okay, so the first thing I'm going to do is I'm just going to scroll down a little bit, and there's this little region right below that sort of branding graphic called Student Spotlight and I want to focus on this. So I'm going to go ahead and click anywhere inside that region and I'll notice right down here in the Tag Selector I get section. I want to click on that so that I'm selecting the entire section itself. Okay, now some of you guys are going to be familiar with applying CSS styles to the Property Inspector, so I'm going to go ahead and start there. One of the things I'll notice is that if I go right down to the Properties Inspector and I can see right here I have a Targeted Rule.
If I grab that pulldown menu, I'll see the option to Apply Multiple Classes now right here at the bottom of it. So it's always going to be sort of at the bottom of whatever populated list you have here. Now if I click on that, that's going to bring up the Multiclass Selection dialog box, and this is the exact same dialog box that you're going to be looking at no matter where within the interface you're applying multiple classes. Now the first thing you're going to see is a list of all the available classes. Now these are classes that have been defined inside your CSS. So if you're working with a brand new CSS file that's totally empty, or if you haven't defined any classes yet, you're not going to see anything there.
Now of course, this is still an option because right down here where it says Type to specify undefined classes, you could simply say class1, and then space, class2, and you could just keep going and it will apply those multiple classes for you. Now I happen to have all of the classes up here that I need, so first thing I'm going to do is scroll down and find info, and I'm going to check that one. Then I'm going to scroll down and find spotlight, and I'm going to check that as well. Now when I click OK, I can see that the info class attribute has been applied and the spotlight class attribute has been applied, and of course the formatting updates to reflect that.
You can see that down here in the Tag Selector we can see section.info.spotlight. With it selected, I could also hit Ctrl+T, or Command+T on the Mac, to bring up the Code Editor and there you can see that we have our section class info, space, spotlight as well. So the Properties Inspector of course is not the only place that you can do this. The next thing I'm going to do is select Current Show, which is right there, and I'm going to do the same thing again. I'm going to use the Tag Selector to go down and select section. Okay, now the Tag Selector itself can apply these classes for you. Now if you have an element selected, you can right-click that element or Ctrl+Click that element directly in the document window, but it's actually a little bit easier, and probably a little bit more accurate, to do it right here in the Tag Selector.
So if I right-click or Ctrl+Click, the section tag right over here in the Status Bar, you'll notice that we have an option to Set Class and one of those options is going to be to Apply Multiple Classes. So again, if I click on this, I get to click to specify which classes I want to apply this to. Once again, I'm going to scroll down and find info, which is going to be consistent on all of these elements and then I'm going to scroll down a little bit more and find show. I'll click OK, and it'll apply those classes to that element. Now that right-clicking option that I just showed you, that also works in Code View.
So if you're in Code View and you right-click on a tag and choose Set Class, you'll be able to do that as well. But if you're in Code View, you're probably going to be hand-coding that. I just want to let you know that that is indeed an option. They really put it everywhere in the interface that you can apply a class, they went ahead and put it in there, so they were very thorough with that. All right! I'm going to click inside the Coming Events one right there. Again use the Tag Selector to select the parent section and it's also available to you directly from the menu. So if I go up to Format > CSS Styles, I can see right down there at the bottom, Apply Multiple Classes, I'm going to select that.
And for this, I'll select events and once again info, so it's consistent all the way through. I'll go ahead and click that and it applies that as well. And if I turn Live View on, I can see that now those three sections are styled exactly the way I want them to be styled, based upon those classes. Now there's still one more thing that I want to show you guys here. So I'm going to turn the Live View off and do a Save All very quickly, and if I scroll up to the very top of the page, I can see that I have a paragraph up here. That is a little confusing because it's sort of hidden, it doesn't look all that great. So I've got a couple of classes here that can help me out with that.
So I'm going to go up and open up my CSS Styles panel. Now because of the lack of space that I have here, I'm going to sort of minimize all the rest of my panels and I'm also going to grab that divider and make sure I can kind of see all the rules that are available to me here. So one of the things that you can do is you can use the CSS Styles panel to also apply multiple classes to an element. So if I go down to the Tag Selector, I'm going to click on the paragraph tag to make sure I've selected it and not any of the span tags inside of it. I can now go over to the CSS Styles panel and I can scroll through and find the selectors that I need.
I need .cf which is the clearfix, so I'm going to grab that, and then if I continue to scroll down, I can find the branding class as well. So I'm going to hold down the Ctrl key which will allow me to select noncontiguous items here. On the Mac you'll be holding down the Command key when you do that. You'll notice it has both of those classes highlighted, the .cf and the branding. Now if I right-click those, I have the Apply option and if I choose that, it's going to go ahead and apply both of those classes to my paragraph and give me the styling that I'm looking for.
So once again I can save this file, click on it in Live View, and I can now see that paragraph styled the way that I was wanting to, based on those multiple classes. So there you go! Not only does Adobe give us the ability to apply multiple classes in CS6, which is welcome enough, but they also give us a number of ways to do it as well, which means you should easily find a method that fits your own personal workflow.
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.
Your file was successfully uploaded.