At the end of this Tutorial you will be able to:
You can view finished versions of the four sample web pages you style with four sample CSS files in this Tutorial by clicking the links below. The finished samples will each open in a new tab of your web browser.
Downloading your four CSS files
Styling your first sample web page
Updating the CSS style rules: sample page one
Styling your second sample web page
Updating the CSS style rules: sample page two
Styling your third sample web page
Updating the CSS style rules: sample page three
Styling your fourth sample web page
In the previous Introduction to CSS tutorial you were introduced the CSS properties most commonly used by web designers to format the content of web pages.
In this Tutorial you will apply these CSS properties to the four web pages you created in the Introduction to HTML Tutorial.
Your first task is to download four stylesheet files, one for each of your four sample HTML pages. Here are the steps.
In the remainder of this Tutorial you will work with these four CSS files along with the four corresponding HTML web page files.
You will use the style-1.css stylesheet file to style the sample page-1.html web page.
Your page-1.html web page is now linked to your style-1.css stylesheet file.
In your web browser, display the page-1.html web page.
It should look like the web page at the following web address:
page-1.html (before CSS style updates).
You can close your page-1.html web page in VS Code.
Note that the link from a web page to a stylesheet has two parts: a ref part and a href part.
Either is allowed.
So, this is correct HTML code:
<link rel="stylesheet" href="dark-theme-style.css">
And so too is this.
<link href="dark-theme-style.css" rel="stylesheet">
Let’s update the linked style-1.css stylesheet file and see the effect on your web page.
text-align: center; font-weight: normal; letter-spacing: -2px; margin-top: 0; margin-bottom: 32px;Your h1 selector and its six style rules should now look as shown below.
font-family: sans-serif; line-height: 1.6; margin-top: 0;Your p selector and its four style rules should now look as shown below.
Display your page-1.html web page in your web browser.
It should now look like the web page at the following web address:
page-1.html (after CSS style updates).
You can now close your style-1.css file in VS Code.
Next, you will apply the style-2.css stylesheet file to the sample page-2.html web page.
<link rel="stylesheet" href="style-2.css">The <head> section of your web page should now look as shown below.
Your page-2.html web page is now linked to your style-2.css stylesheet file.
In your web browser, display the page-2.html web page.
It should look like the web page at the following web address:
page-2.html (before CSS style updates).
You can close your page-2.html web page in VS Code.
Let’s update the linked style-2.css stylesheet file and see the effect on your web page.
text-align: center; letter-spacing: 4px; font-family: sans-serif;Your h1 selector and its six style rules should now look as shown below.
font-family: sans-serif; text-align: center; line-height: 1.4; text-transform: uppercase; font-weight: normal;Your h2 selector and its seven style rules should now look as shown below.
line-height: 1.6;Your p selector and its three style rules should now look as shown below.
Display your page-2.html web page in your web browser.
It should now look like the web page at the following web address:
page-2.html (after CSS style updates).
You can close your style-2.css file in VS Code.
Next, you will apply the style-3.css stylesheet file to the sample page-3.html web page.
<link rel="stylesheet" href="style-3.css">The <head> of your web page should now look as shown below.
Your page-3.html web page is now linked to your style-3.css stylesheet file.
In your web browser, display the page-3.html web page.
It should look like the web page at the following web address:
page-3.html (before CSS style updates).
You can close your page-3.html web page in VS Code.
Let’s update the linked style-3.css stylesheet file and see the effect on your web page.
text-align: center; font-weight: normal; letter-spacing: 4px;Your h1 selector and its five style rules should now look as shown below.
text-transform: uppercase;Your h2 selector and its four style rules should now look as shown below.
font-family: sans-serif; line-height: 1.6;Your p selector and its four style rules should now look as shown below.
Display your page-3.html web page in your web browser.
It should now look like the web page at the following web address:
page-3.html (after CSS style updates).
You can close your style-3.css file in VS Code.
Next, you will apply the style-4.css stylesheet file to the sample page-4.html web page.
<link rel="stylesheet" href="style-4.css">The <head> of your web page should now look as shown below.
Your page-4.html web page is now linked to your style-4.css stylesheet file.
In your web browser, display the page-4.html web page.
It should look like the web page at the following web address:
page-4.html (before CSS style updates).
You can close your page-4.html web page in VS Code.
Let’s update the linked style-4.css stylesheet file and see the effect on your web page.
font-family: sans-serif;But because all the styles on the web page are to have the same font-family value, a quicker option is to add just one new rule to the body selector at top of the stylesheet file.
body { font-family: sans-serif; }
Display your page-4.html web page in your web browser.
It should now look like the web page at the following web address:
page-4.html (after CSS style updates).
You can now close your style-4.css file in VS Code.
Below are four typical examples of modern web pages that have all their content – both text and images – laid out in a single column.
As you can see, all have lots of spacing at the left and right edges of the content. This is called ‘white space’ or ‘negative space’. Its purpose is to make the text more inviting and easier to read.
By default, web browsers add a small amount of ‘white space’ at the left and right edges of the web browser window.
You can see this in the four sample web pages you have created and styled. One example is shown below.
Let’s add some wider, more user-friendly left and right spacing to your four sample web pages.
/* ==== PAGE WIDTH ==== */ body { padding-left: 20%; padding-right: 20% }
Display your four web pages, one after the other, in your web browser.
They should look similar to the web pages at the following web addresses:
page-1.html (after left/right spacing added).
page-2.html (after left/right spacing added).
page-3.html (after left/right spacing added).
page-4.html (after left/right spacing added).
In every case, you can see that:
After completing your web pages and stylesheets, your next step is to upload them to your account on GitHub.
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/page-1.html
https://username.github.io/page-2.html
https://username.github.io/page-3.html
https://username.github.io/page-4.html
It may take a few minutes for your uploaded files to appear on GitHub.
Return to Contents.