Start learning with our library of video tutorials taught by experts. Get started
Viewed by members. in countries. members currently watching.
CSS gives Web designers control over the appearance of their web sites by separating the visual presentation from the content. It lets them easily make minor changes to a site or perform a complete overhaul of the design. In CSS Web Site Design, instructor and leading industry expert Eric Meyer reviews the essentials of CSS, including selectors, the cascade, and inheritance. The training also covers how to build effective navigation, how to lay out pages, and how to work with typography, colors, backgrounds, and white space. Using a project-based approach, Eric walks through the process of creating a Web page, while teaching the essentials of CSS along the way. By the end of the training, viewers will have the tools to master professional site design. Exercise files accompany the training videos.
So, so far we've been in this chapter, we've been talking about color and how to add color to the foreground or the background. Now it's time to do something a little more interesting with backgrounds and that's add images, or an image, as the case may be and add one image per background, although you can add images, you can have as many different backgrounds as you like have images in them. So, what we're going to do in this video is just take an image and apply it to the background of an element using CSS. Now, if you look here, what you see is sort of a basic version of our Javaco design, and what I've done in the content area is I've given it sort of a light gray background, so everything underneath the masthead and that little white separator between the masthead and the rest of it, we have this light gray background, and that's the area to which I'm going to add an image. So you can see, here's the style, the CSS setup, to give element with an ID of content this background color, and now I'm going to add a background image and the way this works is you actually have a reference, a URL reference to an external file, an image, although theoretically you could put any kind of file back there.
In practice, you really can only add rest images, that the format of the browser understands like GIF, or JPEG or PNG or something like that. So, I'm going to add a reference to image curl-gray.gif. Now, this URL is a, is a relative URL, which you may be familiar with in turn relative URLs in hyperlinks. You can also do an absolute URL if you wanted to. We're going to use a relative URL.
Image URLs in URLs in general in CSS are relative to the location of the style sheet, not the location of the HTML document, or the XHTML document. So, if I had a URL reference in my external style sheet, then the URL reference to an image from an external style sheet would be relative to the location of that external style sheet. Here, since the style sheet is embedded into the HTML document, basically it's taken from where the style sheet is, the subject just happens to live inside this XHTML document. So, what this is going to do is, from the location of the style sheet, the browser is going to go to an images subdirectory from the directory that the style sheet is living in and then it's going to look for the image curl-gray.gif, which if you look here, here's images and there's curl-gray.gif. So, having done that and hit save, if we hit Reload in Firefox, tadaa! the image has shown up, is being repeated through out the entire background of the content, the element with ID of content.
It's just one image is just one instance of the scroll, which is just been repeated again and again and again and we don't see that background color anymore, because it's completely obscured by this repeated image, this tiles image. In fact, if we scroll down you can see that it goes as far as the end of the content area. So we can also do this on the body if we particularly felt like it instead of having content, have this background color, which we can shift it to the body and then that would go throughout the entire body, not just the content area.
Of course we wouldn't be able to see it here, where the masthead and the navlinks are, because those are basically in front of the body quote, unquote. They're drawn over top of the body and so their background is obscure, the body background behind them. If we were to take this background away, then we would see this repeated graphic throughout the masthead and the navlinks here. So that's how you add an image to an element and its really pretty darned easy. What we're going to see in the next few videos is how to do more than just sort of simple tiling and affect the direction of the tiling, even the placement of the image and other fun stuff like that.
There are currently no FAQs about CSS Web Site Design.
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.