Updating CSS Colours

Using CSS files to apply text and background colour styles to your exercise web pages and your home page.

Learning Goals

At the end of this Tutorial you will be able to:

  • Apply the CSS properties of color and background-color to web page elements.

Your finished web pages should look as shown below.

Adding colours to your four sample CSS files

In previous Tutorials, you created four sample web pages with these file names:

index.html
exercises/page-1.html
exercises/page-2.html
exercises/page-3.html

Later, you linked your sample web pages to these four stylesheet files:

assets/css/global.css
exercises/assets/css/style-1.css
exercises/assets/css/style-2.css
exercises/assets/css/style-3.css

Now you will add colour style rules to the four CSS files (style-1.css, style-2.css, style-3.css, and global.css) and view the effect on the linked sample web pages.

Updating style-1.css with colours

Follow these steps to add colours to your first sample web page page-1.html by updating its linked style-1.css stylesheet.

  1. In VS Code, open the stylesheet file named style-1.css in your exercises/assets/css folder.
  2. Near the top of the file just after the RESETS block, add the following:
    body { background-color: antiquewhite; }
  3. To the h1, h2 and h3 style declaration blocks, add this new style rule inside the curly braces:
    color: brown;
    
  4. At the end of the file, add this for the hyperlink colour.
    a { color: brown; }
    
  5. Save the style-1.css file.

You can close your style-1.css file in VS Code.

Updating style-2.css with colours

Follow these steps to add colours to your second sample web page page-2.html by updating its linked style-2.css stylesheet.

  1. In VS Code, open the stylesheet file named style-2.css in your exercises/assets/css folder.
  2. Near the top of the file just after the RESETS block, add the following:
    body { background-color: purple; }
  3. To the h1, h2 and p style declaration blocks, add this new style rule inside the curly braces:
    color: white;
    
  4. At the end of the file, add this for the hyperlink colour.
    a { color: white; }
  5. Save the style-2.css file.

You can close your style-2.css file in VS Code.

Updating style-3.css with colours

Follow these steps to add colours to your third sample web page page-3.html by updating its linked style-3.css stylesheet.

  1. In VS Code, open the stylesheet file named style-3.css in your exercises/assets/css folder.
  2. Near the top of the file just after the RESETS block, add the following:
    body { background-color: lightblue; }
  3. To the h2 style declaration block, add this new style rule inside the curly braces:
    color: blue;
    
  4. At the end of the file, add this for the hyperlink colour.
    a { color: blue; }
  5. Save the style-3.css file.

You can close your style-3.css file in VS Code.

Updating global.css with colours

Follow these steps to add colours to your home web page index.html by updating its linked global.css stylesheet.

  1. In VS Code, open the stylesheet file named global.css in your main assets/css folder.
  2. Near the top of the file just after the RESETS block, add the following:
    body { background-color: lightgreen; }
  3. At the end of the file, add this for the hyperlink colour.
    a { color: darkgreen; }
  4. Save the global.css file.

You can close your global.css file in VS Code.

Uploading your files to GitHub

Your final task is to upload your web pages and stylesheets to your account on GitHub.

  1. Open a new tab in your web browser and go to GitHub.com. If you are not already signed in to your GitHub account, sign in now. github-signin
  2. On your GitHub home page, click the ‘repo’ that holds your web pages. Its name will look as follows, where username is your chosen username on GitHub.   username.github.io github-signin
  3. On the next GitHub screen displayed, near the right of the screen, you can see a button named Add file. Click on it. github-upload-portfolio
  4. From the dropdown list displayed, choose the option Upload files. Project Animation Google Fonts
  5. In File Explorer (Windows) or Finder (Apple Mac), drag-and-drop your 📁 assets and 📁 exercises folders and the index.html file to upload them to your repository on GitHub. Introduction to HTML
  6. Scroll down to the bottom of the GitHub screen, and accept or edit the short message (Add files via upload) in the Commit changes box.
  7. Finally, click the green Commit changes button to upload your files. Project Animation Google Fonts

Your web pages are now published on GitHub at web addresses similar to the following, where username is the username you have chosen for your GitHub account:

https://username.github.io/index.html
– or simply –
https://username.github.io
https://username.github.io/exercises/page-1.html
https://username.github.io/exercises/page-2.html
https://username.github.io/exercises/page-3.html