Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
So, how do you go about giving your styles into an External StyleSheet and then attaching them to the Page? Dreamweaver makes that process pretty seamless and gives you a tremendous amount of flexibility and control over it. You can create CSS file separately and then attach them to your HTML pages or or you can create CSS files as you create rules for your site. As usual, which method you use will largely depend upon your Personal Preferences. Now you may notice something little different about the programs.htm file here and that's that it doesn't have any styles applied to it whatsoever.
So, basically it is style-free for most the part and what I want to do is start attaching some External StyleSheets. I just basically want to go through some of the different ways that you can do that by first creating a couple of Test StyleSheets if you will. So, I'm just going to go up to Dreamweaver File>New>New CSS File. So you can create these separately from your HTML if you want. You can just start working on your CSS and I'm going to go ahead and create that. And just for brevity's sake, I am going to do a very simple rule here. I am just going to do a Paragraphs Selector. Inside the Paragraphs Selector I am just going to set the color something like red.
So I am going to save that. And what I am going to do is I am going to go in to this news 06_08 directory, which is the one we're working in. And I want to go into the _CSS folder and I am just can call this test.CSS and click Save. Now I'll close that, I don't need to have the CSS file open in order to attach it to one of the html files we are working with. All I need to do that is the CSS Styles panel. So, if I go over the CSS Styles panel, I can see down the bottom right hand corner, I've got the little Attach StyleSheet icon. I am going to click on that.
And when I do that I get a chance to Browse out to the file that I am looking for. So I want to Browse out to the 06_08 directory, I am going to go inside the CSS folder and I am going to Find the test that we created earlier. So I am going to go ahead and grab that, click OK and now I'm presented with a few more choices. Now the first choice is whether I want to link this or import this. It is a big difference. Link is going to use a Link Tag in the head of my Document and it's going to point to the External CSS Reference File. Import is actually going to place a Style Tag ahead of my Document and use the @import syntax in order to bring it in.
Really there are some just very specialized usages of the import syntax, so unless there's a reason for you not to, use Link. Now the next thing that allows me to do is choose Media Type. So I can grab that pull-down menu and I could choose any Media Type I want. Now if you have used a previous version of Dreamweaver, you'll probably notice wow there is a lot more in there now than it was before. Well that's because Dreamweaver now supports media query syntax which has a lot more Media options to choose from. I am just going to go down and choose Screen and then click OK.
As soon as I do that it attaches the Style Sheet. If I go under the Source Code, I can see there is a Link Tag that we just created through that process. And now all of my paragraphs are red which is exactly what we're going for. All right, I am going to delete this StyleSheet, I am going to click on it right over here in the All view of my CSS Styles panel. And then just click the Trashcan icon. Because I want to show you an alternate method of doing the exact same thing that we just did. If I go over to my CSS Styles panel unless I don't have any Styles applied. I can come down and create a brand New CSS Rule and when I do that I can say, Okay, I just want to do Tag Selector and I wanted to the Paragraph Tags.
So we're just going to do the same rule we did before. Now after that it's going to say, well, where do want to place that rule? And if you don't already have a Style Sheet attached, it's going to prompt you to do either in this document only which will do embedded styles, or you can prompt it to create a new Style Sheet file. So you can sort of do this all at once and not have to do in separate steps. So as soon as I click OK, it's going to prompt me to save this. This time I am just going to do a test 2.CSS. And I'm just going to change once again color to something like red and I'll click OK.
Now notice that as soon as I did that it did two things for me. It created the link in head of the document to that test 2 CSS file and it also created the first rule inside it as well. So that way, if you're creating a brand New StyleSheet from scratch, you know it's a lot quicker and a lot easier in terms of getting it done. I don't know if you notice this or not however, there is one crucial thing missing from that particular workflow. You'll notice that we were not able to choose a media type. So we couldn't do any type of media declaration to the rule.
Now you certainly we could go into the code and add that yourself little bit later on, but that's something that you need to be aware of in case you thinking of adopting that particular method. Ok I am going to go and delete this one and we're going to attach our actual Style Sheets. So now that we know kind of different methods that we have in terms of attaching a Style Sheet, it becomes pretty easy to do. First I'm going to do to Save All to get rid of those Links that we're not using anymore. And the next thing I am going to do is, I am going to attach the Style Sheet and I am going to Browse Out into our CSS directory. And this time, I am going to choose the one that was already sitting in there for main.CSS.
Now instead just grabbing the Media pull-down menu this time and choosing a Single Media type. You're also allowed to enter in a comma separated list or even if you guys are working with media queries, you can even type of media query directly into this. So I am just going to type in screen, projection and then click OK. And as soon as I do that I see all my styling show up the way that I expected to, Main.CSS shows up over here on the side. And if I go in the Code view again I'll see that link with my media type applied to it as well and I am going to do a Save All.
And it's a very quick and easy Way to go grab a Style Sheet that you already have and attach it to the page. Now you could always a hand code the link into the Style Sheet as well. It's a simple element and Dreamweaver's Code Hinting will even help you Browse for the correct CSS file as you link out to it. But in the end, like many of the options inside Dreamweaver, the method that you choose to use will largely be based on Personal Preference.
Get unlimited access to all courses for just $25/month.Become a member
58 Video lessons · 59226 Viewers
61 Video lessons · 92183 Viewers
82 Video lessons · 104057 Viewers
56 Video lessons · 106753 Viewers
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.