Student starter code (30% baseline)
index.html
- Main HTML pagescript.js
- JavaScript logicstyles.css
- Styling and layoutpackage.json
- Dependenciessetup.sh
- Setup scriptREADME.md
- Instructions (below)💡 Download the ZIP, extract it, and follow the instructions below to get started!
Learn three powerful methods to style your webpages: inline, internal, and external CSS.
In this activity, you will:
Estimated Time: 30-40 minutes
Create a styled webpage about Favorite Food and Hobbies using all three CSS methods to demonstrate how they work together and their priority order.
# Run the setup script
./setup.sh
# Start the development server
npm start
# Open http://localhost:8080 in your browser
Simply open index.html
in your web browser. No setup required!
Section One: Favorite Food
Section 2: Hobbies
Inline CSS (in HTML <body>
tag):
darkcyan
Internal CSS (in <style>
tag):
color: gold
font-weight: bold
External CSS (in style.css
file):
color: white
, background-color: purple
Method | Location | Priority | Syntax |
---|---|---|---|
Inline | HTML element | Highest | <tag style="property: value;"> |
Internal | <style> in <head> |
Medium | selector { property: value; } |
External | Separate .css file |
Lowest | selector { property: value; } |
When styles conflict: Inline > Internal > External
Example: If body background is set in all three places, the inline style wins!
<link>
tag in <head>
sectionstyle.css
filestyle
attribute to <body>
tag<style>
tag in <head>
style.css
fileYour webpage should display:
Visual Design:
Structure:
My Favourite Food (gold, large)
The list below is showing my favourite food (white on purple)
1. Nasi lemak (bold)
2. Curry puff (bold)
3. Fried mee (bold)
My Hobby (gold, large)
The list below is showing my hobby when I am free (white on purple)
• Reading books (bold)
• Playing games (bold)
• Watching movies (bold)
[All on dark cyan background]
<link>
tag has correct filename (style.css
)<link>
tag is in <head>
sectiondarkcyan
, gold
, purple
, white
style="property: value;"
format<body style="background-color: darkcyan;">
<style>
tag in wrong place<head>
section</style>
tag exists<link rel="stylesheet" href="style.css">
in <head>
li { font-weight: bold; }
exactlycolor: white; /* Text color */
background-color: purple; /* Background color */
font-weight: bold; /* Make text bold */
font-size: 20px; /* Text size (optional) */
darkcyan
, gold
, purple
, white
black
, red
, blue
, green
, yellow
#FF5733
, #00AA00
Before submitting:
Try adding the same style in multiple places:
Example - Body Background:
<!-- Inline (highest priority) -->
<body style="background-color: darkcyan;">
<!-- Internal (medium priority) -->
<style>
body { background-color: red; }
</style>
<!-- External (lowest priority) -->
body { background-color: blue; }
Result: Background will be darkcyan (inline wins!)
Best Practice: Use external CSS for most styles, internal for page-specific tweaks, inline sparingly.
After completing the base activity:
Add More Sections
Experiment with Colors
Add More CSS Properties
font-family
: Change fontspadding
: Add spacing inside elementsmargin
: Add spacing between elementsborder
: Add borders to elementsOverride Exercise
Activity 03 - Introduction to CSS W1: Front-end Design & User Experience Telebort Engineering Time: 30-40 minutes