CSS – A Simple Page Using Float

The previous exercise asked to create a page with the following layout:

Header section
Large image goes here.
Smaller image
Smaller image
Smaller image
Footer section

The purpose being to try and use floating elements in a design.


  1. An Example Using float
  2. Source Code
  3. Notes
  4. Image Credits

An Example Using float

You can see how the page I styled and structured using float looks here.

Source Code

    <title>Floating on Dreams</title>
    <meta charset="utf-8"  />


      #title {
        font-size: 48px;
        text-align: center;

      #subtitle {
        font-size: 24px;
        text-align: center;

      .main {
        font-family: sans-serif;
        box-sizing: border-box;
        width: 960px;
        margin: auto;

      .header {


      .images {

      .large-image {
          margin: auto;

      .small-image-container {


      .small-image {
          float: left;
          margin: 50px 10px 0 10px;

      .footer {
          text-align: center;

      .clearfix::after {
        clear: both;
        display: block;
        content: "";



    <div class="main">
      <div class="header">
        <p id="title">Floating on Dreams</p>
        <p id="subtitle">A simple page using floats</p>

      <div class="images">
        <div class="large-image">
          <img src="28-big-image.jpg">

        <div class="small-image-container clearfix">
          <div class="small-image">
            <img src="28-small-1.jpg">
          <div class="small-image">
            <img src="28-small-2.jpg">
          <div class="small-image">
            <img src="28-small-3.jpg">

      <div class="footer">
        <p>Copyright 2018</p>




  1. The first thing that needs to be done is to divide the document into nesting and stacking HTML blocks.
  2. This is one possible way to section the document: 
  3. There is always a Main container which contains all the content. It was set to have a width of 960 pixels.
  4. The Header and Footer blocks are nested inside the main container.
  5. Between the header and footer there is some content. The content (in this case) is images and is contained within an Images container.
  6. Nested inside the images container is a stacking of large and small images.
  7. The large image has its own container
  8. The small floating images are wrapped in their own container so they act like a single block. The small images block has .clearfix applied to it.
  9. Not all the sectioning divs have styling applied since their sole purpose is to provide structure.
  10. While styling could have been applied directly to the img tags, I chose to wrap them in a div because it allows for greater flexibility in the future.
    • Imagine turning those small floating images into a “card”:

      A Pensive Cat

Image Credits

The images I used are courtesy of:

  1. charloisporto : Tranquil nature scene
  2. silviarita : Fruit salad
  3. Ataner007 : Woman meditating
  4. susannp4 : Cat