Lesson 4: Introduction to CSS Layout


In this lesson, you will learn the fundamentals of how to create a two column, fixed-width CSS layout.

What you’ll learn in this lesson:

  • Understanding CSS reset files
  • An overview of CSS layout options
  • How to use margins and padding to add space to your pages
  • Working with the float and clear properties

Starting up

You will work with several files from the HTML5_04lessons folder in this lesson. Make sure you have loaded the HTML5lessons folder onto your hard drive from www.digitalclassroombooks.com/HTML5. See “Loading lesson files” in the Starting Up section of this book.

4139.jpg The examples in this lesson use the TextWrangler text editor to create the HTML markup, but you can use any text editor and achieve the same results.

Working with a CSS reset file

Before you start building your page layout, you will learn to use a CSS reset file. In Lesson 3, you learned that virtually all HTML elements (such as paragraphs and headings) have default styles rendered by the browser. For example, the heading 1 default style has top and bottom margins of 10 pixels. If you want to style a heading so there is no margin, you must explicitly set the style rules to zero.

On the left is a heading 1 with default margins of 10 pixels. On the right is a heading ...

Get HTML5 Digital Classroom now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.