Start learning with our library of video tutorials taught by experts. Get started

Exploring CSS Positioning
Watching:

Positioning with CSS


From:

Exploring CSS Positioning

with Candyce Mairs

Video: Positioning with CSS

What I want to talk about now is CSS Positioning and CSS Properties. So you use CSS Properties to define the positioning for elements within your page. And you'll see what I mean by that once we move into adding some of these CSS Properties. But lets take a look at where the page is at at this point. I have header.html open. And within this page, I have a single Div tag with an ID of Header. In other words I have a single box of content named Header. Within that box I have an image, and my image right now is 850 pixels wide. So let's take a look at this in the browser to see what it looks like. Here is my image.
Expand all | Collapse all
  1. 1m 13s
    1. Welcome
      1m 13s
  2. 33m 20s
    1. Why CSS positioning?
      5m 50s
    2. HTML editors
      3m 18s
    3. Getting set up
      3m 39s
    4. Previewing pages in browsers
      3m 51s
    5. Customizing the HTML editor
      5m 32s
    6. Exploring browser variances
      5m 16s
    7. Browser extensions
      5m 54s
  3. 30m 33s
    1. HTML vs. CSS: Which does what?
      9m 55s
    2. HTML div tags
      4m 57s
    3. CSS properties
      6m 21s
    4. The CSS box model
      9m 20s
  4. 28m 46s
    1. Planning the page layout
      3m 47s
    2. Building the header box
      6m 23s
    3. Positioning with HTML
      3m 36s
    4. Positioning with CSS
      8m 21s
    5. Foreground vs. background content
      6m 39s
  5. 25m 44s
    1. Building the menu box
      5m 7s
    2. Adding the menu links
      4m 58s
    3. Formatting the menu with CSS
      6m 43s
    4. Positioning the menu with CSS
      8m 56s
  6. 21m 42s
    1. Adding the middle column
      6m 29s
    2. Creating a CSS rule for the column
      6m 20s
    3. Adding CSS rules for the column
      8m 53s
  7. 19m 49s
    1. Adding the right column and inserting images
      7m 33s
    2. Completing the right-column content
      4m 18s
    3. Formatting the right column using CSS
      7m 58s
  8. 26m 14s
    1. Understanding the float property
      6m 5s
    2. Applying the floats
      6m 1s
    3. Finishing the floats
      6m 24s
    4. Adding CSS properties to the right column
      7m 44s
  9. 30m 59s
    1. Setting up for background colors
      5m 49s
    2. Adding a footer
      8m 50s
    3. Adding the background colors
      7m 20s
    4. Positioning the footer
      9m 0s
  10. 16m 38s
    1. Comparing the web page to the graphic design
      6m 50s
    2. Adjusting the web page as needed
      4m 25s
    3. Adding the final touches
      5m 23s
  11. 2m 43s
    1. Closing thoughts
      2m 43s

Watch this entire course now—plus get access to every course in the library. Each course includes high-quality videos taught by expert instructors.

Become a member
Please wait...
Exploring CSS Positioning
3h 57m Beginner May 24, 2012

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.

Topics include:
  • Previewing pages in browsers
  • Customizing the HTML editor
  • HTML vs. CSS: which does what?
  • Building the header area
  • Adding the navigation menu
  • Positioning using a float
  • Adding background colors and images
  • Comparing the web page to the graphic design
Subjects:
Web Web Design video2brain
Software:
CSS
Author:
Candyce Mairs

Positioning with CSS

What I want to talk about now is CSS Positioning and CSS Properties. So you use CSS Properties to define the positioning for elements within your page. And you'll see what I mean by that once we move into adding some of these CSS Properties. But lets take a look at where the page is at at this point. I have header.html open. And within this page, I have a single Div tag with an ID of Header. In other words I have a single box of content named Header. Within that box I have an image, and my image right now is 850 pixels wide. So let's take a look at this in the browser to see what it looks like. Here is my image.

Now what you see open at the bottom of the screen, and you can see as I kind of move things around it changes up top, this is Firebug, which is an extension you can add on to Firefox. And it comes in very handy when working in CSS. So I simply have it opened. And I installed Firebug and placed an icon up here. And what that icon does is simply open and close Firebug. I want it opened right now so I'll go ahead and do that.

What you see on the left here, is HTML coding for the page. So, I'm going to open up the Body tag, and I'm also going to open up the Div tag. Now, notice how I hover over these elements, things change up in the Top panel. So when I hover over the Body tag, you can see it shows the blue area up top surrounding or covering up my image itself. And notice it extends all the way across the width of the webpage.

If I hover over the Div tag, that yellow border is removed. And you can see that box extends all the way out across the pages well. But notice what happens when I hover over the Image tag. The blue area is only covering the image itself. This is what Firebug allows you to do. Is kind of view how the browser understands each piece of code within your page. Now when I hover over the Div, it extends all the way across the page. I want to contain this Div.

I want it to be the same width as my image. So it doesn't take up anymore space than the image itself. So I'm going to go back to my page and add some CSS Properties to take care of that. So I'll align this left and within the code area I'm going to move out to the CSS 2 piece. CSS 2 is supported by all browsers. CSS 3, there are properties that vary across browsers, at least at this point in time. So I'm going to remain in CSS 2 and these are all of the CSS Properties that are available.

So if I scroll down you can see there is one called Widths. Now what I need to do in order to add the widths is move out to the HTML tags because it's actually a HTML tag we place those properties inside. So I will drag out the style tag and this is an HTML tag. Within that HTML tag, the CSS interpreter in the browser reads the rules.

So whatever is contained within those style tags, the browser is going to have the CSS piece read. So I'll go back to my CSS Properties. And the first thing I want to set is the Width. So, I'll drag the width up here, as a property. Notice the colon and semi colon are added by coffee cup. If you're typing these out in any other type of editor, you will need to add those. And the width I'm going to choose is 850 pixels because that's the width of my image.

Now you can have space on either side of this colon. But you cannot have a space between the unit of measure and the actual number. So if you put a space between these two, your width won't work. Now I added a width, but I didn't really add a width to anything, any particular content on the page. So what I need to do is finish this up with my style rule. So I need to do a pound Header.

So it's the Header ID I want to make 850 pixels in width. So this is how CSS references the Header ID. The pound sign tells CSS it is an ID. Then I'm going to add a curly bracket here. And notice the program adds it for me. So I can just drag this up. Now I have added a Width between the style tags.

But I have not assigned an element to that width. And I'll show you what I mean. What I need to do is tell CSS what part of the page, what piece of the page, is going to be a width of 850 pixels. So I added a property and a value, but I didn't assign it to any selector. So what I'm going to do is tell CSS the Header ID is what I want to set to 850 pixels in width, and I'm going to place the property in value within those curly brackets.

So here is a selector, in other words, I need to tell CSS, what part of the page is it that I want to make 850 pixels. So that should take care of this div. It should limit it now to 850 pixels. And that's exactly what I wanted to do. So let's take a look in the browser. I will go back to Firebug. Open up the body. And now notice when I hover over the Div, it's 850 pixels. It covers the image perfectly.

If I hover over the image, it remains the same. So I have just set my div property, the width specifically, to the same as my image. And you want to usually assign properties to divs within your page. There's no reason to have this extend all the way out to he right at some point I may want to put some other content up here. So I'll pull this in nice and tight so that my image fits perfectly within that Div tag, so that is how you can control your boxes using CSS Properties.

Now I'm just working with the width at this point. I don't really need to position at all because it is in the top left corner which is exactly where I want it. So the Width property is the only property I need to assign to the Header div. But if I needed to assign more, I just put it between those two curly brackets, add another property. So I can assign as many properties and values as I want to any type of selector. As I move further down the page and I"m not working in the top left corner any longer, I will need more properties and values assigned specifically for the positing piece, but that is how you can add CSS Properties. To any content within the web page its just a matter of what is the content and what are the properties and values you want to assign.

There are currently no FAQs about Exploring CSS Positioning.

Share a link to this course
Please wait... Please wait...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.
Upgrade now


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Upgrade now

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed Exploring CSS Positioning.

Return to your organization's learning portal to continue training, or close this page.


OK

Course retiring soon

Exploring CSS Positioning will be retired from the lynda.com library on April 24, 2014. Training videos and exercise files will no longer be available, but the course will still appear in your course history and certificates of completion. For updated training, check out CSS: Page Layouts in the lynda.com Online Training Library.


Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Welcome to the redesigned course page.

We’ve moved some things around, and now you can



Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

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.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked