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
# Just open index.html in your browser
open index.html
# or double-click the file
./setup.sh
npm start
# Open http://localhost:8080
When you open index.html, you'll immediately see:
<body> tagLocation: index.html - After the Favorite Food section (after line 40)
Success Criteria:
<h1> heading with text "My Hobby"<ul>) with 3 items:
Hints:
<ol> to <ul> for unordered (bullet) listExpected Output:
My Hobby (gold heading)
The list below is showing my hobby when I am free (white on purple background)
• Reading books (bold)
• Playing games (bold)
• Watching movies (bold)
Why It Works Automatically:
h1 { color: gold; } applies to ALL h1 elementsli { font-weight: bold; } applies to ALL list itemsstyle.css applies to ALL paragraphs| 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, whitestyle="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, whiteblack, red, blue, green, yellow#FF5733, #00AA00Before 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