The following file is required for this lesson:

Introduction

This lesson builds on the form concepts taught in COMP1017.

Demo Instructions

You can follow along with your instructor to complete this build and/or you can use this document as a guide in completing the demo build.

Steps

  1. Download the demo-form-styling.zip file and extract its contents to a folder named demo-form-styling.
  2. The output of this lesson should look like:
    style-forms-01.jpg
  3. The first steps are to build the web page and add the form elements. Open your index.html file and add the following code:
    1. Create the starting web page:
      index-01
    2. Add the <header> block complete with a navigation menu:
      index-02
    3. Add a search form after the closing div and before the closing header:
      index-03
    4. Add a <section> inside the main <form> block:
      index-04
  4. Refresh your browser to see:
    style-forms-02.jpg
    Question: What are the next steps?
  5. You will need to add the reset.css file and create a styles.css file to your css folder.
  6. Modify your styles.css file by adding the following rules:
    1. Add the :root style rule:
      css-styles-01
    2. Add some basic styling:
      css-styles-02
    3. Style the .header-top class:
      css-styles-03
    4. Style the .sr-only class:
      css-styles-04
    5. Style the submit buttons for uppercase letters and rounded corners:
      css-styles-05
    6. Style the search form:
      css-styles-06
    7. Add some padding to the <section>:
      css-styles-07
  7. Refresh your browser to see something like:
    style-forms-03.jpg
    Question: What needs to be done now?
  8. It is time to start styling the login form. Add the following style rules:
    1. Add the .login-form class rule:
      css-styles-08
    2. Style the labels:
      css-styles-09
    3. Style the div elements:
      css-styles-10
    4. Style the input fields:
      css-styles-11
  9. Refresh your browser to see something like:
    style-forms-04.jpg
    Question: What are the next steps?
  10. Add more style rules to your styles.css file:
    1. Style the submit buttons and add a hover effect:
      css-styles-12
    2. Add :focus style rule:
      css-styles-13
      css-styles-14
      Reference: https://developer.mozilla.org/en-US/docs/Web/CSS/:focus
    3. Add some error checking to the input fields:
      css-styles-15
  11. Refresh your browser and try the form:
    1. Hover over an input field:
      stlye-forms-05
    2. No data entered:
      stlye-forms-06
    3. Form fields filled out:
      stlye-forms-07

Module Home

DMIT1530 Home