HTML Layouts

HTML Iframes

HTML Layouts

A well-structured website layout improves its user-friendliness by making it easy for visitors to read and navigate through its content. The majority of developers use columns and rows to structure their websites in a way that is similar to newspapers and magazines. <table>, <div>, and <span> are some of the elements that are used to structure the layout of websites. There are three major ways of dividing a webpage into columns and rows. Each one of them will be reviewed separately.

Website layout using tables

This is perhaps, the simplest way of creating a layout in HTML by dividing a webpage into columns and rows. The example below uses the table element to create a simple website layout.

Website layout using div and span

Developers use the <div> element in HTML is used to mark out blocks of content. A <div> element can be nested in another but it cannot be enclosed in an inline element. If you need to mark out sections within a block element or other inline statements, use the span element. The example below will illustrate how you can use <div> elements to create a layout.

Website layouts using HTML 5 structural elements

The most recent release of HTML comes with structural elements like <footer>, <header>, <nav>, and <section> to separate various sections of a webpage in a semantic way. Below is an example that uses HTML 5 structural elements to create a webpage layout.

<!DOCTYPE html>
<html lang="en">
<title>CSS Template</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
* {
  box-sizing: border-box;

body {
  font-family: Arial, Helvetica, sans-serif;

/* Style the header */
header {
  background-color: #666;
  padding: 30px;
  text-align: center;
  font-size: 35px;
  color: white;

/* Create two columns/boxes that floats next to each other */
nav {
  float: left;
  width: 30%;
  height: 300px; /* only for demonstration, should be removed */
  background: #ccc;
  padding: 20px;

/* Style the list inside the menu */
nav ul {
  list-style-type: none;
  padding: 0;

article {
  float: left;
  padding: 20px;
  width: 70%;
  background-color: #f1f1f1;
  height: 300px; /* only for demonstration, should be removed */

/* Clear floats after the columns */
section:after {
  content: "";
  display: table;
  clear: both;

/* Style the footer */
footer {
  background-color: #777;
  padding: 10px;
  text-align: center;
  color: white;

/* Responsive layout - makes the two columns/boxes stack on top of each other instead of next to each other, on small screens */
@media (max-width: 600px) {
  nav, article {
    width: 100%;
    height: auto;

<h2>CSS Layout Float</h2>
<p>In this example, we have created a header, two columns/boxes and a footer. On smaller screens, the columns will stack on top of each other.</p>
<p>Resize the browser window to see the responsive effect (you will learn more about this in our next chapter - HTML Responsive.)</p>


      <li><a href="#">London</a></li>
      <li><a href="#">Paris</a></li>
      <li><a href="#">Tokyo</a></li>
    <p>London is the capital city of England. It is the most populous city in the  United Kingdom, with a metropolitan area of over 13 million inhabitants.</p>
    <p>Standing on the River Thames, London has been a major settlement for two millennia, its history going back to its founding by the Romans, who named it Londinium.</p>