CS101: Computing Technology and You
CS101: Computing Technology and You

Lab 7: Programming Lab 3: Manage The Style of Web Pages Using Cascading Style Sheets

There are 5 parts to this lab:

Part 1: Boot computer into MacOS, run Ubuntu virtually, open lab directions, download folder, rename, download and look over grade sheet, and set up screen.

Part 2: Learn how Cascading Style Sheets (CSS) work.

Part 3: Group work / extra credit / feel like a programmer.

Part 4: Print out HTML and CSS documents, fill out grade sheet, and print out grade sheet.

Part 5: Check that all tasks are complete, email assignment to instructor and self, shut down computer, and turn in printouts.

Prior to lab discussion topics:

How do Cascading Style Sheets work?

Group Skills Discussion

Algorithm Skills

Lab Directions:

Part 1: Boot computer into MacOS, run Ubuntu virtually, open lab directions, download folder, rename, download and look over grade sheet, and set up screen.

When you first start your computer it will be running the MacOS operating system.

For our project we will be using the Ubuntu operating system running in a virtualization environment called VMware Fusion.  In a moment we will be starting the VMware Fusion software.  Once VMware Fusion starts your screen will look like this:

Ubuntu in pause mode.

To start VMFusionware running double-click on the desktop icon titled Double click on Ubuntu 18.04.3 icon shown below:

Fusion Icon

Once your computer is running Ubuntu double-click on the icon called 2Clicks For Lab Directions on the desktop as shown below to open up the Firefox web browser so you can get to today's lab directions:

Double click the 2Clicks for lab directions icon

When Firefox opens click on the link for today's lab directions. Your screen should look similar to the one below:

Drag the                    lab directions window to the right side of the                    Desktop.

For today's lab it will be helpful to have the directions on the other side of the screen.  Drag the directions to other side of the screen as shown below:

Drag dirrections to other side of screen.

We will now download a file that will uncompress into a folder with the files we need for today's project inside.  We will then rename the folder and files and then open them up to be worked on.

It is very important you download, uncompress, rename, and open the files correctly or today's lab will not work.  If in doubt call your instructor over to help.

Click on the link below to download the files:

Download needed files

When the files start to download the following message will appear...

Click OK

... click OK.

When the following window appears click just once on the folder called rename as shown below...

select the rename folder

...and then click the Extract button.

When the following window appears click once on the Desktop button...

click on desktop button

... and then click once on the Extract button.

When the following window appears...

click on close

... click on Close.

Now close the following window by clicking the close window button as shown below:

click close window button

We now need to rename the folder and two files inside the folder.

Right-click on the new folder on your Desktop and select rename as shown below:

select rename

Rename your folder using the following naming strategy...

lastname_firstinitial_prog3
(example santana_c_prog3)

... by typing in the new name and clicking on Rename as shown below:

type new name and click on rename

We will now rename the two HTML files inside the folder.  Double click on the folder to open the following window:

double click on folder

Now right click on the filed current called lastname_firstintial_webpage1.html and select Rename as shown below:

Select rename

Rename the file lastname_firstInitial_webpage1.html using the technique shown below:

rename your file

Repeat the process with the file called: lastname_firstintial_webpage2.html

Your folder shown now be similar to the the one shown below:

newly named files

It is very important your folder is saved correctly, named correctly, and contains the above files correctly renamed.  If it does not, today's lab will be very difficult at best and need to be repeated at worst.  If in doubt call your instructor over to help.

You are about to download, open, and save the Programming Project 3 Grade Sheet file using LibreOffice.  When it opens your screen will look like the one shown below:

click middle button

Drag the grade sheet to the other side of the window so you can see these directions as shown below:

direction on right side

To download today's grade sheet click on the following link:


Now click the Edit Document button as shown below:

click edit button

Look over the grade sheet to familiarize yourself with today's requirements.  If you have any questions ask your lab instructor.  Later we will need to add to the grade sheet and print it out.  For those reasons we will now save the grade sheet into our new folder.

Select File menu > Save As... as shown below:

select file menu save

Click once on the Desktop button...

click the Desktop button

... and then double click your folder to make sure you are saving the grade sheet into your folder as shown below...

double click on folder

Now name your grade sheet the following by typing using the following format ...

lastname_firstinitial_gradesheet3

(i.e. Carlos Santana would call his folder santana_c_gradesheet3)

... as shown below:

type neme into name box


If your Save dialog box looks similar to the one above then click on Save button.

The grade sheet informs you of the tasks you are required to complete in that day's lab and how many points each of the tasks are worth towards the total points available for today's lab project.  Look over the grade sheet to see how you will be graded today.  You can refer to the grade sheet as you work through the project.

When you are done looking over the grade sheet click on the Minimize button in the upper right corner of the grade sheet...

click the minimize button

... to create desktop space for today's project.

To work most efficiently in today's lab your screen should look similar to the one below, if not please call over your instructor to help you set it up correctly:

Drag dirrections to other side of screen.

Part 2: Learn how Cascading Style Sheets (CSS) work.

In today's lab we are going to learn how to control the style of a web page (or entire website) using Cascading Style Sheets (CSS).

In order to do that we need to set up our computer in a very particular way in order to work efficiently during a somewhat complicated process.

We will do that now.

Display two downloaded HTML files in web browser and open in Text Editor.

To make lab easier make sure you set up your Desktop as follows.

Your screen should currently look like this:

Drag dirrections to other side of screen.

Read the three step process below to open webpage1.html in Firefox and then return to these directions:

Double click on html1 file

Repeat the process for webpage2.html.

You should now have these three tabs displayed in the Firefox web browser:

Three current tabs

We will now open both web pages in Text Editor so that we can edit the HTML code.

To open your HTML documents in Text Editor we will need to use a different method.  Right click on your webpage1.html document and select Open With Other Application as shown below:

select open with other application

When the following window appears click on View All Applications:

Click on View All Applications

When the following window appears complete the two step process below:

select text edior and the click select

Your webpage1.html document should now be open in Text Editor as shown below:

webpag1 open in text editor

We must now open webpage2.html with a different method so it becomes a tab in Text Editor.  In Text Editor click on the Open button as shown below:

click open
Then select Other Documents button at bottom of window:

click other documents

In the new window follow the steps below:

follow the 3 step process

Double click on your webpage2.html document as shown below:

double click webpage2.html

It is very important your screen looks like the one below.  If it does not, today's lab will be very difficult at best and need to be repeated at worst.  If in doubt call your instructor over to help.

Your screen should now look like this:

current screen

We will now edit our second web page and display the edit in Firefox like we did in our last programming lab.

Select webpage2.html tab in Text Editor and and follow the two step process shown below:

replace your name

Now click on the tab in the Firefox web browser that contains webpage2.html and hit the reload button to see if your changes show up in Firefox as shown below:

reload webpage

Now in Text Editor click back on the webpage1.html tab as shown below:

select first tab

Change both name areas in webpage1.html and save your HTML document.  Reload in Firefox to see if correct.

Your screen should now look like this:

current screen

We are now ready to create our first CSS sheet!

Creating an external style sheet.

In today's lab we are going to learn how to control the style of a web page (or entire website) using Cascading Style Sheets (CSS).

What is CSS?

HTML was NEVER intended to contain tags for formatting a web page.

HTML was created to describe the content of a web page, like:

<h1>This is a heading</h1>

<p>This is a paragraph.</p>

When tags like <font>, and color attributes were added to the HTML 3.2 specification, it started a nightmare for web developers. Development of large websites, where fonts and color information were added to every single page, became a long and expensive process.

To solve this problem, the World Wide Web Consortium (W3C) created CSS.

CSS removed the style formatting from the HTML page.

CSS is a language that describes the style of an HTML document.

CSS describes how HTML elements should be displayed.

CSS makes it so that a whole website can be styled by editing one document.

Why is it called Cascading Style Sheets?

There are three ways of inserting a style onto a web page:
  1. External CSS
  2. Internal CSS
  3. Inline CSS

There is an order to which a style will be used.  As a web browser tries to figure out which style will be used on a web page it will cascade down the order to figure out which style has priority.

The easiest way to see how it works is to put all three styles on one web page and see which one wins.  

We will do that now.

Creating and applying an External Style Sheet.

An external style sheet is a just a text file, like a HTML document is, so we can create one right in Text Editor.

Click on the new document button as shown below:

click Create new document button
Click the save button as shown below:

Click the save button

When the following window appears do the following two steps:

save your document

In your new document type the following style tag:

type the tag
Click the Save button:

click the save button

We just created an external style sheet and put in a style that should turn all paragraph tags the color green.  We now need to tell our web page to refer to the external style sheet for style information.

Click on your webpage1.html tab in Text Editor and follow the 3 step process below:

follow two steps
Click on the Firefox tab displaying webpage1.html and click the refresh button:

paragraphs should now be green

Congratulations! You just created an external style sheet and told your first web page to get the style for your paragraphs from the style sheet.  Notice all three paragraphs changed and you only had to type one style tag.

How the tags work:

how tag works

How the style sheet tag works:

how tags work

How do I put an Internal Style Sheet tag into an HTML document and how does it relate to an External Style Sheet?

An Internal Style goes right into the HTML document instead of being a separate CSS style sheet. 

Select your webpage1.html document and add the following style tag:

add internal style tag

Save your HTML document and reload in the web browser:

turns yellow from green

Why do the paragraphs turn from green to yellow?

This demonstrates why it is called Cascading Style Sheets.  Because the new style tag is located in the HTML document after the External Style Sheet tag it takes precedence over the first tag.  The style cascades to the new tag!

tags explained

How does the third CSS style, Inline Style, work?

There is a third type of CSS called Inline Style.  Inline Style gets put directly into the body of a HTML document.  Let's give it a try and see how it relates to the other two styles in terms of cascading.

We will add an Inline Style tag to our Paragraph 1 tag as follows:

edit paragraph 1 tag

Now save your HTML document and reload in Firefox.  Your Paragraph 1 tag just changed to the color red as shown below:

Paragraph 1 is now red.

How does that work?  The External Style sheet tells the paragraphs to be green. However, this cascades down to the Internal Style which tells the paragraphs to be orange. However, this cascades down to the Inline style which tells it to red.  Most local style wins.  Hence, Cascading Style Sheets (CSS)!

What is the point of an External Style Sheet?  Why have an External Style sheet if local styles overrun it?

External Style sheets can allow you to quickly change an entire web site.  To demo this we will now add the style sheet to our second web page.

Select your webpage2.html file in Text Editor and add the following tag:

complete two steps
Save your HTML document and reload in Firefox. 

Notice your paragraphs have changed to green because they are getting the style from the cascading style sheet you made earlier:

Paragraphs are green

Imagine how useful this would be if you had to change the paragraph color on a 200 page web site.  You could edit all paragraph tags on all 200 pages, or update one external style sheet.

What how do style tags work?

A CSS rule-set consists of a selector and a declaration block:

css tag

The selector points to the HTML element you want to style. In this case we are going to put a style on our heading 1 tag.

The declaration block contains one or more declarations separated by semicolons.  In this case we are going to turn the heading blue with a font size of 12.

Each declaration includes a CSS property name and a value, separated by a colon.

A CSS declaration always ends with a semicolon, and declaration blocks are surrounded by curly brackets.

Here is how one of your styles worked:

style tag

Return to webpage1.html in Text Editor and add the following style to the inline style sheet:

add following tag

Save HTML document and reload in Firefox.  Notice that the heading 1 tag is now pink and 12 pixels in size:

now pink

What other types of style tags are there?


Lot's of them.  They can be quite useful.  We don't have time to learn them all today. To learn more CSS tags you can use this tutorial:  w3schools.com

Element Selector

The tags we have learned so far define the style of an element, such as, a paragraph tag <p> or a heading 1 tag <h1>.

Let's learn a new type of style tag.

Grouping Selector

You can define a style for a group of tags.  Let's define a style for all heading tags.  Add the following tag to your external style sheet.  Select your .css tab in Text Editor and add the following style:

add the following style
Now save your cascading style sheet and reload webpage1.html in Firefox:

heading changed color

Select webpage2.html in Firefox and reload.  Notice that all the heading changed color on this web page:

all headings changed color

The power of Cascading Style Sheets!

To learn more about CSS you can use this tutorial:  w3schools.com

Part 3: Group work / extra credit / feel like a programmer

We will now enter the group portion of today's lab.  For each group:
  1. In your external CSS document add a style tag that would change the background color for the body of your web pages to the color of your choice. (5 points)
  2. In your external CSS document add a style tag that would change the background color of all your headers to a color different from the color you set for the rest of the web page. (10 points)
  3. In your webpage1.html document set an inline style tag that would change the style of your heading 2 tag <h2> to a different background color than the two background colors you set for the above tasks. (15 points)

Part 4: Print out HTML and CSS documents, fill out grade sheet, and print out grade sheet.

When you are done with the extra credit you will need to print out a copy of your webpage1.html document, your CSS sheet, and complete the grade sheet.

Before you print out your webpage1.html document click the Save button Click the Save button to save your most recent changes. 

Then select from the menu the print icon as shown below:

Select the print icon.

When the Print dialog box shows up select the printer you want to use and click the Print button as shown below:

Chose printer and select print.

We now repeat the process to print out your CSS document.


Once you have retrieved your printout of your webpage1.html and CSS documents, close Text Editor by clicking the red button in the upper right corner of the window as shown below (if it asks to save do so):

Close your HTML document.



We now need to fill out and print out the grade sheet.  On the Ubuntu launcher click on the LibreOffice icon to bring the Grade Sheet back to full window status as shown below:

Click on the LibreOffice icon to activate the grade sheet.

Drag the document to the left side of your screen to set up your Desktop as shown below:

Move grade sheet to left side of screen.

Now in the header of the document, type your name and lab section number as shown below:
type name and lab section number in header

Now answer the three reaction questions on the grade sheet by typing in your answers and making sure to stay only one page in length.


Once you have completed your grade sheet you will need to save it by selecting File menu > Save shown below:

Select File menu Save.

To print out a copy of your grade sheet select File menu > Print as shown below...

select file menu print

... to open the following dialog box,

Select either the By_Cabinet or the By_Door printer and then click on the OK button.

print box

Now walk up to the printer you selected and retrieve your printout of the grade sheet.

Close the grade sheet by clicking the red close window button in the upper right corner of the window as shown below...

Click Red Button

If the Save dialog box appears...

Save dialog box.

... click on Save.

Your screen should now look like this:

current desktop

Look over grade sheet printout to complete the requirements for today's lab.  If you have any questions about the grading ask your instructor.

Part 5: Check that all tasks are complete, email assignment to instructor and self, shut down computer, and turn in grade sheet.

Your screen should now look like this:

current desktop

Make sure the following 5 items are in your folder on the Desktop by double clicking on the folder and opening the following window:

check for items in folder

Close the open window containing the five items.

Next we will compress a copy of your folder so that we can email it to both yourself as a backup and to your instructor for grading. Right click on our folder and select Compress... as shown below:

select compress

Make sure that the dialog box that appears is set up like the one shown below...

Setup dialog box as is

... and then click on Create.

A compressed version of your folder and files will show up on the desktop as shown below:

your folder with .zip

Follow the steps below to send the new compressed folder to yourself and your instructor:

Step 1) Click the following link to open the SSU login page in a new tab, to log in to your online SSU email account (or other online email account).

Step 2) Create a new email.

Step 3) Fill in the subject for the email as:

lastname_firstinitial_prog3
(example: santana_c_prog3)

Step 4) Attach the compressed folder to the new email.

Step 5) Address the email to your instructor's email address (highlight and copy the email address for your instructor from the list below):

Mr. Carter's lab section's use this email address = glenn.carter@sonoma.edu

Step 6) CC the email to yourself.

Step 7) Send the email.

Once you have emailed in your assignment make sure you staple the grade sheet onto the top of your HTML document and turn them in to your instructor.

Lastly, to exit out of Ubuntu running in VMware Fusion and shut down the computer, place your mouse at the top of the screen and wait until the VMware Fusion menus appears and then select Apple menu > Shut Down... as shown below...

Select shut down.

... and when the following dialog box appears select Shut Down as shown below:

Select Shut Down

End of Lab.