Start learning with our library of video tutorials taught by experts. Get started
Viewers: in countries Watching now:
CSS enables you to control the look and layout of a web page much more precisely than you could with HTML alone, but it can be time-consuming to learn. In this workshop, expert developer Candyce Mairs makes styling a quick and easy process, walking you through the process of adding content to a web page and using CSS to position that content. Candyce explains CSS positioning concepts like the CSS box model, floats, and clears and demonstrates how HTML and CSS work together to create the look of your web page. By speaking the same language as the browser, you can learn to work with the browser to place content accurately and easily.
My web page now has three divs attached to the page, and it's fairly obvious to see them once I've put this page in the browser. And what I'm going to do, is continue to build the divs with content inside of them,and once that's completed, I go ahead and add the positioning piece. So what I'm going to do next is, I have a menu here, I have a left column. And what I want to do, is add a right column that will ultimately end up on this right-hand side underneath the header.
So I'm going to build the right column div. I'll go back to CoffeeCup to do that. Here is my header div, my menu div, and my left div, and my right div is going to go directly below that. So let me make a space down here in order to add that, and I'll go ahead and copy the header div, just because it's easy to do.
There's only a single image inside of it, so it makes it simple to copy and paste it. I pasted it right there. Now that I have that all set up, it's a matter of removing the image itself, or this particular image, and placing the real content that I want inside of this area. Let me rename this area first, so I don't get confused about what I'm doing. Now you can see this little box pops up as I'm inside the id area.
This is a CoffeeCup feature. Quite a few HTML editors do this, as well. What's happening is, I'm adding a new id, so I'm ignoring this. What this little box is doing, and it's usually referred to as a code hint, it's showing me the ids that I have created in CSS already. So if I want to use one of those, I can just double-click it here. Since I don't have an id created for right, it's not showing up inside this box.
I'm just typing it in and ignoring the box. As soon as I click out of that id area, the box goes away automatically. Now within this right-hand column, I have three images and some text I'm going to display. So instead of removing this image tag, what I'm actually going to do, is copy it twice more. And then it's just a matter of pasting in the actual images I want to use. So I'll go ahead and copy this, and I'll paste it right here. I want to make sure that this image that I just pasted is inside my div tag. All content to go inside this column must be located inside my div. I'll go ahead and paste the next one, and I'll do it so you can see what I'm doing. And it's just a matter of, what images am I going to place in this area? So within the right column, the first thing I have are three images. Those three images I'm going to place inside here, are orange clam, and if I move this up, you'll be able to see it.
Let me try and get this in the right spot. There we go. It's the orange clam, the sea horse, and the yellow fish. Now the yellow fish is going to be the first image, so I'll just change this to yellow fish. The next image is going to be orange clam, and I can always change this if I need to in terms of the sequence. So I'll put these in and if they're not quite right, I can just swap them around. And the seahorse.
So I'll put in my seahorse, and there will be some text underneath these images that I'll be placing in here, as well. But let me take a look at my images first. Now I do need to change the Alt text for these images, as well. But let me take a look at this page at this point, before I change anything else. Let's see how our page is doing. Oh my goodness, that looks very interesting, don't you think? (LAUGH) My images are all being stretched.
The reason they're being stretched, is because I used this particular dimension for those images. I need to correct the width and height for these specific images. And if I just remove this, the browser will figure out the width and height automatically. This isn't exactly the way I want to go about doing things. So how else can I do it, so I don't have to figure out the width and height? Well, I can also just drag them out from here.
So if I drag out yellow fish, you can see how it automatically gives me the correct width and height. So what I'm going to do, is put these in the same order, but just drag them out from here. So if you're going to use a previously displayed image, you do have to watch that the width and height are correct for your specific images. I can now delete these three that have the wrong width and height, and I don't have to go back and try to figure out what these correct widths and heights are.
And in this Alt Text, let me see, the yellow fish. It's just a matter of describing it. So for now, I'll just say, fish swimming within coral. And the next one, will be orange clam. And the last one, I'll just say, seahorse. Now normally, I would expand upon these a little bit further, but for the sake of time, I'll just drop that in for now. Now it's a matter of putting my content below this, so let's take a look at the page.
I'll go out to Firefox, once again. Scroll down, and that looks much better. So what I've done, is added the images inside of the div for the right column. It doesn't look at all like it's going to become a right column, but I have the images on the page in the box that I need, and that's what I was trying to do. Get the content into the box, and get the HTML added. Now it's a matter of dropping in whatever else I want within that right column, and we can take it from there. I like to get all of the HTML onto the page prior to adding the CSS piece, just like I've done with all of the other divs on the page. This is the same process I do for every div, no matter where it's located. So that is the right div that will become the right column, with three images located inside of it.
There are currently no FAQs about Exploring CSS Positioning.
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.