Coding Ireland STEM Report 2024 Have Your Say
HTML CSS
Advanced
40 mins
205 points
What you need:
  • Computer/laptop

CSS Website Layout

In this lesson we learn about how websites are commonly laid out and how we can use CSS to code it.

1 - Introduction

Websites can come in hundreds of different layouts and in this lesson we will take a look at some of the most common layouts and how to code them in CSS.

A website is normally broken into the following areas:

  • Header - that contains the logo or branding of the website and the navigation menu. This normally stays the same on each page in the website.
  • Content - that contains the main content of the web page. This changes from page to page on the website.
  • Footer - this normally contains some secondary links such as for social media channels or contact us information.
Header





Content




Footer

2 - Header

The header appears at the top of the web page and would normally contain:

  1. The logo or branding of the website. This usually acts as a link to the "homepage" of the website.
  2. The navigation for the website. This will have links to the main areas of the website.

Here is an example of HTML and CSS that creates a simple header for a website. Take a look at the HTML and CSS code and see how we have used CSS to style the header, brand and menu a.

3 - Content

The layout of content on a website can vary from page to page. For example the layout for a page that has a list of products is going to be different from a page an "About Us" page that has text and images.

Usually though the content area will be broken into one of the following layouts:

1 column layout
Header




Footer
2 column layout
Header




Footer
3 column layout
Header




Footer

4 - Columns

We can use CSS to set the width of the columns to lay them out the way we want. In the following example we have 2 columns laid out with widths of 31% and 65% (and a 2% padding all around).

We use float: left property to specify that the <div></div> column elements float to the left, otherwise they would appear stacked on top of each other.

Try changing the values in the width and the padding properties and see how it affects the columns. Note that if the total of the width and padding for both of the columns goes over 100%, then the right column will move down under the left column as they are greater than the 100% screen width.

E.g. (1% + 31% + 1%) + (1% + 65% + 1%) = 100%

5 - Footer

The footer appears as the bottom of the web page and would normally contain some information about the company/website and some secondary links.

Here is an example of HTML and CSS that creates a simple footer for a website. Take a look at the HTML and CSS code and see how we have used CSS to style the footer, info and links a.

Join our club 😃

To view the remaining 1 steps and access hundreds of other coding projects please login or create an account.

Copyright Notice
This lesson is copyright of Coding Ireland. Unauthorised use, copying or distribution is not allowed.
🍪 Our website uses cookies to make your browsing experience better. By using our website you agree to our use of cookies. Learn more