Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
Usually placing the image on the page is just the beginning of making sure it fits within the design of your site. While there are certain properties that you can set manually on an image, for the most part you will want to customize the look and feel of your images through CSS. Using styles allows you to create different looks and behaviors based on where the image is found, the context in which it is being used or what type of image it is. The other rather obvious advantage to using styles for images is the ease of updating them. Rather than having to find dozens or even hundreds of images and modifying them individually you can update their specific style and have the change occur site wide.
So to experiment with styling our images, I am going to go back to the Index file this time in the 07_07 folder and just as a recap from our previous movie if I select the image that we modified, the image Properties in our last movie I can see that it has the Class, articleImg applied to it and that's the selector that we are going to work with when modifying the styling of this image. Another thing I want to do is I really like to be able to kind of see what's going to happen to this image as we style it, so I am going to work with Live View turned on. I am going to go ahead and turn Live View on.
Live View always jumps you back up to the top of the page, so I am just going to scroll back down again and I can see where the image is sitting. Now there are a couple of things I would like to do here. Number one, I really don't like the way that the image and the text are interacting with each other, that is to say they're really not interacting with each other at all. The image is sort of sitting there and the text is on the same line and that's because to the browser into HTML, this image and this line of text, they are both objects that occupy that particular line box. It doesn't really realize that the image is much taller than the text.
So I would really like the text to wrap around the image and I would like to style the image a little bit to give it a little bit of distinction, may be a bit of a border on the outside perhaps even a little fake bevel look to it. Nothing tacky I promise. So what I want to do now is I want to go over to the CSS Styles Panel and I want to find the selector that we are going to be modifying, and remember we are looking for the articleImg Class, so I am going to scroll down through my styles. I am going to collapse my Files Panel too, that's going to make it a little bit easier for me to find this. And as I scroll down through here, what I am looking for is right there, img.articleImg.
So that means any image with the class of article image applied to it. I am going to double-click that and again, that's going to open up the CSS Rule Definition dialog box. I am going to move this just to the right a little bit so that when I make changes to the styles I can see those changes reflected over here on my image. All right! The first thing I am going to do is I am going to give this a Background color. Which may seem a little odd, you may say, well why would you want to give an image a background color the image is going to sit on top of it. For the most part, but here we have the Box model properties like Padding that can cause some of this background to be visible.
So what I am going to do is for the Background-color, I am going to grab just a color chip here. I am going to choose kind of a neutral gray, maybe this second neutral gray which is the rgb(204,204,204). Now you are probably seeing something a little different there, am I right? Are you seeing a Pound symbol followed by letters and numbers? Well, that's hexadecimal notation. If I want I can to right over here to this little fly-out and I can tell it which Color Format to write the colors in. So I could come down here and say Three or Six-digit Hex. If I say Three-digit Hex which is the default, if I scroll down, now I can find the gray I am looking at is #CCC.
So it doesn't really matter which color format you have selected, we are just going to choose that sort of light gray color. Okay the next thing I want to do is go to my Box Model Properties and for Padding I am going to leave it Same for all, and I am just going to change to the Padding to 10 pixels. Now as soon as I do that, when I start making these changes, a lot of times I will have an idea as to what I want to happen with my image but until I actually see it in the context of the page, I don't know whether that was what I was going for or not. So Dreamweaver gives us a really nice little feature of instead of being able to commit and saying okay and then having to edit the style, I can come over here in the right-hand side and I can say Apply, and as soon as I do that, Live View is going to update, it's going to show me exactly what that's doing to my image.
You can see that because of the padding, this 10 pixels worth of padding that we have applied to the image, now that part of the background shows through and it gives us this kind of thick border look which is really nice. Now the next thing I want to do is I want to Float this image because I really want the text to wrap all the way around it. So from the Float pulldown menu, I am going to choose left because I want the image to be on the left-hand side of the text and then for Margin, I am going to deselect Same for all, and I am going to do about a Right margin of say 1em, which is basically equal to one character size of the text.
When I apply that, I can now see that the text is now wrapping around the image exactly the way I want it to and I can see that the Right margin that we applied here is pushing the text away from the image by about one character width, which is kind of exactly what I was going for. All right! Now I want to enhance this a little bit further by going over to my Border properties and what I want to do in my Border Properties, I am going to turn off Same for all, because I only want to apply a border on two edges. I am going to apply on the right and the bottom edge. It's going to give it just kind of fake bevel look. Now before you grown bear with me here, because if you do it subtly enough, it doesn't look that bad.
I am going to take the Style for the Right one, I am going to do solid, and Style for bottom I am going to do solid and I am going to do one pixel for each of those and then for the actual color itself, you can kind of experiment around with this a little bit, but I am going to go one up on this gray. From CCC I am going to go to 999 and that's a nice subtle change in color and when I apply that you can see it just gives it a real nice, subtle almost beveled look to the edge of that. Now in some situations where you have this on a darker background you might even want to do a highlight color on the Top and the Left, but since we are against a white background, that really is not going to do a whole lot for us.
So I am going to go ahead and click OK and I am extremely happy with my image styling, so I am just going to kind of leave it the way it is. It's one of the benefits of being able to hit Apply instead of just OK. It allows you to sort of preview your changes before you commit to them and it saves that sort of editing time that you would do otherwise. Now by no means is this a limit of what you can do with images in CSS. It's actually a pretty simple example. Now part of the fun of using CSS is the creative exploration that it can lead to. So I want to encourage you to just experiment with your images combining borders, background colors, padding and margins even try some of the new effects like box shadows and things like that for maximum creative effect.
Now the important thing to remember is that you can use CSS to control the visual presentation of images, making sure that they conform to the overall design strategy of your site.
Get unlimited access to all courses for just $25/month.Become a member
58 Video lessons · 65777 Viewers
61 Video lessons · 96479 Viewers
56 Video lessons · 110237 Viewers
82 Video lessons · 105093 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.