NATIONAL DIGITAL LITERACY COMPETITIONSubject: Stage 3 Computer Science & Web Technologies
Grade Level: Senior Stage 3 (Ages 16–18 / Pre-University)
Instructional Design Focus: Experiential Learning, Computational Thinking, and Applied Web Architecture
Welcome to the foundation of modern digital infrastructure. Almost every service we interact with today—from streaming platforms and social networks to financial systems and smart city dashboards—relies on web technologies and programming logic. This section unpacks how these technologies work from the ground up, starting with web infrastructure and moving through structural HTML5, expressive CSS3, and dynamic JavaScript execution.
To build software for the web, we must first understand the medium through which it travels. The World Wide Web operates primarily on a Client-Server Architecture. This model describes how two distinct computing entities communicate to share resources and display information.
+------------------+ HTTP Request +------------------+
| | -----------------------------------------------> | |
| Client Browser | | Web Server |
| (Chrome, Firefox)| |
+------------------+
|
+-------------+-------------+
| |
+------------------+ +------------------+
| | | |
+------------------+ +------------------+
| Contains meta- | | Contains visible |
| data, title, & | | content: headers,|
| linked assets | | paragraphs, divs |
+------------------+ +------------------+
Early versions of HTML relied heavily on generic container tags like and. While functional, these tags carry no structural meaning. Semantic HTML5 introduced descriptive tags that communicate the role of the content to browsers, search engines, and screen readers (used by visually impaired users).
Using semantic elements improves SEO (Search Engine Optimization) and guarantees digital Accessibility (a11y), making web applications accessible to everyone.
Cascading Style Sheets (CSS) control the visual presentation of HTML elements. CSS targets HTML elements using selectors and applies style declarations (consisting of properties and values).
/* Selector targeting a class */ .profile-card { background-color: #f4f4f4; /* Property: Value */ border-radius: 8px; padding: 20px; }
Every element on a webpage is treated as a rectangular box. Understanding the CSS Box Model is essential for controlling layout spacing, alignment, and sizing.
+---------------------------------------------+
| Margin (Clears area outside border) |
| +---------------------------------------+ |
| | Border (Line around padding & content)| |
| | +---------------------------------+ | |
| | | Padding (Clears area around) | | |
| | | (the content inside) | | |
| | | +---------------------------+ | | |
| | | | Content (Text/Image) | | | |
| | | +---------------------------+ | | |
| | +---------------------------------+ | |
| +---------------------------------------+ |
+---------------------------------------------+
The box model consists of four layers:
By default, an element's total width is calculated as:
To prevent these calculations from complicating layouts, developers often use the CSS rule box-sizing: border-box;, which forces the padding and border to fit within the defined width and height of the element.
CSS Flexible Box Layout (Flexbox) is a one-dimensional layout model designed to distribute space and align items within a container, even when their sizes are dynamic or unknown.
Key properties applied to a flex container:
display: flex; activates the flex context.flex-direction: row | column; defines the orientation of the layout axis.justify-content: flex-start | flex-end | center | space-between | space-around; aligns items along the primary axis (horizontally by default).align-items: flex-start | flex-end | center | stretch; aligns items along the cross axis (vertically by default).If HTML is the skeleton and CSS is the skin, JavaScript (JS) is the muscular and nervous system. JavaScript is an interpreted, high-level programming language that executes in the user's browser, allowing pages to respond to user actions without reloading.
When a browser loads an HTML document, it constructs a tree-like representation of the page called the Document Object Model (DOM).
Document (Root)
│
│
┌─────────┴─────────┐
│ │
┌───────┴───────┐
JavaScript interacts with the DOM to dynamically manipulate the webpage. This allows JS to read, add, remove, or modify HTML tags and CSS styles on the fly.
JavaScript functions are often triggered by events—specific actions that occur on the webpage, such as a user clicking a button, hovering over an element, pressing a key, or resizing the window.
To respond to an event, we attach an Event Listener to a DOM node. This listener waits for the specified event to fire, then executes a callback function in response.
// Selecting the DOM node const themeButton = document.querySelector('#toggle-btn'); // Attaching the event listener themeButton.addEventListener('click', function() { // Logic that runs when button is clicked document.body.classList.toggle('dark-mode'); });
To see how these technologies work together outside of textbook definitions, let’s explore three practical scenarios where coding fundamentals and web architecture solve real problems.
Sourdough Bread), pricing text ($8.50), and user input fields for quantities.const menuItems = [ { id: "sourdough", name: "Sourdough Bread", price: 8.50, stock: 15 }, { id: "croissant", name: "Almond Croissant", price: 4.50, stock: 24 } ];
When a customer changes the quantity input, a JS function recalculates the subtotal, adds local sales tax, and dynamically updates the order total in the DOM without requiring a page reload.
let ambientTemp = getSensorReading(); // Reads current room temperature if (ambientTemp > 24) { triggerAirConditioner("ON"); updateDashboardUI("Cooling active...", "blue-text"); } else if (ambientTemp ` containers and applying descriptive `alt` tags to images (e.g., `alt="Minimalist brand design for coffee shop"`), the designer helps search engines correctly index their work, driving organic traffic. * **Interactivity & UX:** A JavaScript-powered filter dynamically updates the display. When a visitor clicks a "Branding" tag, JS hides non-branding elements from the DOM with a smooth CSS transition effect: ```javascript function filterPortfolio(category) { const items = document.querySelectorAll('.portfolio-item'); items.forEach(item => { if (item.dataset.category === category || category === 'all') { item.style.display = 'block'; // Show matched projects } else { item.style.display = 'none'; // Hide unmatched projects } }); }
This section walks you through building a real, interactive web page: an Interactive Personal Finance Budgeting Calculator. This application allows users to log income and expenses, calculate their net balance, and receive dynamic financial health tips based on logical thresholds.
+-------------------------------------------------------------+
| PERSONAL FINANCE CALCULATOR |
+-------------------------------------------------------------+
| [ Income Input ] $ [5000] [ Expense Input ] $ [3200] |
| |
| ( CALCULATE BALANCE ) |
| |
| Net Balance: $1800.00 |
| Status Alert: Healthy Savings Rate! Keep it up. |
+-------------------------------------------------------------+
Create a file named index.html and add the following code. This sets up the structural elements of your calculator using semantic HTML.
Interactive Budget Tracker Budget Tracker & Planner Manage your monthly cash flow and savings goals. Total Monthly Income ($): Total Monthly Expenses ($): Calculate Net Balance Financial Overview Net Monthly Savings: $0.00 Savings Percentage: 0%
Next, create a stylesheet named style.css in the same directory. This stylesheet structures the app using a responsive Flexbox layout and applies variables, clean spacing, and modern typography.
/* Custom CSS Variables for styling consistency */ :root { --primary-color: #2b6cb0; --success-color: #2f855a; --warning-color: #c05621; --danger-color: #9b2c2c; --bg-light: #f7fafc; --card-bg: #ffffff; --text-dark: #2d3748; } * { box-sizing: border-box; margin: 0; padding: 0; } body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background-color: var(--bg-light); color: var(--text-dark); display: flex; justify-content: center; align-items: center; min-height: 100vh; } .app-container { width: 100%; max-width: 500px; padding: 24px; } header { text-align: center; margin-bottom: 24px; } header h1 { color: var(--primary-color); font-size: 1.8rem; margin-bottom: 8px; } header p { color: #718096; font-size: 0.95rem; } .calculator-card, .results-card { background-color: var(--card-bg); border-radius: 12px; padding: 24px; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05), 0 1px 3px rgba(0, 0, 0, 0.1); margin-bottom: 20px; } .input-group { display: flex; flex-direction: column; margin-bottom: 16px; } .input-group label { font-size: 0.9rem; font-weight: 600; margin-bottom: 6px; color: #4a5568; } .input-group input { padding: 10px 14px; font-size: 1rem; border: 1.5px solid #cbd5e0; border-radius: 6px; outline: none; transition: border-color 0.2s ease; } .input-group input:focus { border-color: var(--primary-color); } button { width: 100%; background-color: var(--primary-color); color: white; font-size: 1rem; font-weight: 600; padding: 12px; border: none; border-radius: 6px; cursor: pointer; transition: background-color 0.2s ease; } button:hover { background-color: #2c5282; } /* Dynamic Classes */ .hidden { display: none; } .result-item { display: flex; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid #e2e8f0; font-size: 1.1rem; } .feedback-msg { margin-top: 16px; padding: 12px; border-radius: 6px; font-size: 0.95rem; font-weight: 500; line-height: 1.4; } /* Feedback Theme Classes */ .savings-good { background-color: #c6f6d5; color: var(--success-color); } .savings-warning { background-color: #feebc8; color: var(--warning-color); } .savings-danger { background-color: #fed7d7; color: var(--danger-color); }
Now create app.js. This script reads user input, converts it to numbers, runs conditional safety logic, calculates percentages, and dynamically displays the result.
// Select DOM elements const calculateBtn = document.getElementById('calculate-btn'); const incomeInput = document.getElementById('monthly-income'); const expensesInput = document.getElementById('monthly-expenses'); const resultsSection = document.getElementById('results-section'); const netSavingsDisplay = document.getElementById('net-savings-display'); const savingsRatioDisplay = document.getElementById('savings-ratio-display'); const financialFeedback = document.getElementById('financial-feedback'); // Define calculation and rendering function function processBudget() { // 1. Retrieve and parse input values const income = parseFloat(incomeInput.value); const expenses = parseFloat(expensesInput.value); // 2. Data Validation // Check if the values entered are actual numbers and are not negative if (isNaN(income) || isNaN(expenses) || income 0) { savingsRatio = (netSavings / income) * 100; } // 4. Render calculations to screen (Format numbers to two decimal places) netSavingsDisplay.textContent = `$${netSavings.toFixed(2)}`; savingsRatioDisplay.textContent = `${savingsRatio.toFixed(1)}%`; // 5. Structural Conditional Logic to generate financial health context // Clear previous feedback classes financialFeedback.className = "feedback-msg"; if (netSavings | | .container { | | [Inputs: kWh / Days] | ---> | | ---> | display: flex; | | [Calculate Button] | | | | padding: 20px; | | [Results Dashboard] | | | | } | +-----------------------+ +-----------------------+ +-----------------------+ │ ▼ Phase 4: JS Logical Engine +-----------------------+ | const kwh = parse(); | | if(kwh > limit) { ...}| | showResults(); | +-----------------------+
resource-tracker.index.html.container, a section for numeric inputs, a to trigger calculations, and placeholder tags (such as and ``) to display results.style.css.display: flex) to align input elements cleanly. Keep the interface layout responsive so it adjusts to both mobile and desktop screen sizes.app.js.document.getElementById().const dailyPerCapitaConsumption = totalKwh / (occupants * billingDays); let ecoRating = ""; if (dailyPerCapitaConsumption Irrigation Check Field Size (Acres): Run Report
/* THE BROKEN CSS SNIPPET */ .card { width: 500px; padding: 10px; margin: 15px; /* Visual components overflow on narrow mobile screens. How can we make it more responsive? */ }
// THE BROKEN JAVASCRIPT SNIPPET const btn = document.getElementById("calc-btn"); btn.addEventListener('click', function() { // BUG WARNING: The values below are parsed as strings rather than numbers, // which leads to calculation errors when multiplying. let acres = document.getElementById("acres").value; let litersNeeded = acres * 1500; // 1500 liters recommended per acre // LOGICAL ERROR: This comparison does not work because it evaluates strings instead of numbers. if (litersNeeded = "10000") { // Check if this assignment operator is correct document.getElementById("alert").textContent = "Danger! Overconsumption limits reached."; } else { document.getElementById("alert").textContent = "Water volume approved."; } });
Imagine you are hired as a technical consultant to design a system for a local Community Food Bank. They need a web portal to coordinate food donations.
+-------------------------------------------------------------+
| DESIGN PROPOSAL |
+-------------------------------------------------------------+
| 1. Semantic Wireframe 2. Dynamic State Planning |
| [Header] - User logs donation quantity |
| [Main Content Grid] - Logic computes total weight |
| [Footer] - DOM updates progress bars |
| |
| 3. Layout Architecture 4. Technical Stack Choice |
| - Flexbox container alignment |
| - Media queries for responsive volunteer usage |
+-------------------------------------------------------------+
Write a structured Design Proposal Document addressing the following points: