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.
Now that my HTML content has been added for the header region on my page, the menu region on my page, and the left column content, what I want to do is fine-tune this left area here. And add some additional CSS properties for my left column. I'm also going to add some additional CSS style rules for HTML tags within the left column. So ultimately, we're going to be looking at adding some CSS rules for both the div itself, as well as HTML tags within that div.
So, let's take a look at it. Right now, this left column, and this is purely my design concept, the left column has a header, and this will become my header on the page. Within that content area, I have two paragraphs under that header that will both be paragraphs. Down below that, I have some additional information here about the different destinations that ScubaBlu provides tours to, and the destinations is a bit of a header, as well. And then I have four different paragraphs of text. So if I go down into my content area for the left, you can see right now it just says, ScubaBlu is a specialist in dive travel.
I do not have a header one that says, dive with ScubaBlu, so I'll go ahead and add that. Within this area, if I go down to code for HTML 5 within CoffeeCup specifically, I have all of my tags. So, I'm going to drag out a header one tag and within this, I'm going to say, dive with ScubaBlu. There we are. Dive with ScubaBlu. And I'll put an exclamation mark there.
So I now have my header one and my p tags. This destinations right now, is inside its own p tag that also includes the Australia area, because you can see, here's my closing p, her's my opening. So what I want to do, is I'm going to take this p and move it down below, so that the Australia line is within the p, and my destinations here is going to get an h2. I'll just type it out this time, since I already have this bracket here. And this break tag or br tag is a break.
And so, it's a way to create a line return. Destinations would go directly above Australia without any space between it. So here is my header two. And let me make sure that it's a closing right there. Now I also have this little issue of the single space, so I'll make sure those two line up. It just makes it cleaner and easier moving forward when you come back to modify. Now that I've created the header one, a p and an h2, I need to go up to my style rules here, because I do not have a selector for those.
So what I'm going to do underneath left. Why am I choosing it here? I tend to place my id rules, which is the rules with the pound sign in front of them, up at the very top within my style rules. I actually find I tend to modify these a lot more than my other rules. So because of that, I place them at the top, just because they're easier to find. So I'll go down here, and underneath those ids, I'll start with my h1 tag.
And my h1 is just a tag, so it does not get a pound sign, then I'll create my rule. Now what should I do with this rule? Well, I think it should probably be the same font-family as the rest of my text. So my font-family, and I can just select this and double-click, is going to be Georgia, or whatever the default Serif font is, if Georgia's not on the system. Under font size, I will make this let's say, 1.4m for a header one. I'll keep it black colored.
By default, it ends up black so I don't need to modify that. And then, I'm going to copy this header one, the entire piece, and I'll paste it down here, just changing it to a header two. Now, my header two, I'll make a fair amount smaller. I'll make it a 1.1m. If I save my page and take a look at it in the browser now, I should have my content set up. And you can see my header one and header two are all set with the Georgia font.
These paragraphs are not however, so I need to add those. And I could just paste the same thing I did for the header one. I still have it on my clipboard. So I can paste it down below here, and just change that to a p tag. And my p tag I think I'll make, let me say, 0.85ms. I'll start there. Now an m represents the width of the letter m and whatever font you're working in.
Here is the Georgia font, and it's the width of that letter m. The default width would be 1.0. This is actually going to end up a little bit smaller than the default size that it was in straight HTML. So let me go look at my page, now. And that looks much better. So there's my font. Now I do have a space between destinations and Australia, which I did not have in my original design.
Anytime you make something a header tag, it adds extra space down below here. And I can modify that. Once I get to a few more of the positioning pieces for this column, I'll go ahead and modify it then. So for now, I'm just getting this information set up. Now there's one piece I haven't mentioned yet, and that is what I've done is created header one, header two, and p tag properties. Now I may not want these properties to apply to every column or every area within my page. In other words, if I use a p tag in the left column, I may want it Georgia, but in the right column, I may want it something else. The way I could specify to only use these properties if it's inside the left column, is to put the left id in front of the tag. So I will put #left.
Space, h1, #left, space, h2. And you can think of that space as representing the word and. So I'll finish this off. What I'm saying is, if it's inside the left id and it's a header one, do this. Same thing here. If it's inside the left id and it's a header two and it's a paragraph. What this does, is limit these properties to only apply within that particular part of the page.
So I'll save this and let's take a look. It should not look really any different to us, now. But what this is going to do, is prevent me from having to come back and modify this once I add my right column of content. It just limits it to this particular box. As long as it's within this box, it's going to look this particular way. So what I did, was use CSS properties to format my text with an only this box on the page.
And that is how you add those CSS properties for within a specific div on your web page.
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.