9th Class Computer Science Unit 8 Web Development with HTML, CSS and JavaScript – Notes, MCQs and Questions (New Syllabus)

Last updated: 4 December 2026 · Punjab Board 9th Class Computer Science and Entrepreneurship (new syllabus 2025-26) · Unit 8

Easy, exam-focused notes for Unit 8: Web Development with HTML, CSS and JavaScript of the new Punjab Board 9th class Computer Science book. Short answers are written to fit the board e-sheet answer space. All exercise MCQs are checked against the textbook answer key.

In this unit

  1. Web development: front-end, back-end, full-stack
  2. HTML: history, structure and tags
  3. Headings, paragraphs, links, images, lists, tables, comments
  4. CSS: syntax, 3 ways, fonts, backgrounds, layouts
  5. CSS animations and transitions
  6. JavaScript: variables, data types, functions, events
  7. Debugging and testing
  8. Exercise: MCQs, short and long questions
  9. FAQs

8.1–8.2 Web development

Web development is the process of creating websites and web applications using programming languages and tools. Why learn it: digital literacy, career opportunities, problem solving, creativity and entrepreneurship (e.g. a website to sell your crafts).

TypeDeals withTechnologies
Front-endWhat users see and interact withHTML (structure/skeleton), CSS (style/look), JavaScript (interactivity)
Back-endBehind the scenes: servers, databases, logicWeb servers, databases, PHP, Python, Ruby
Full-stackBoth front-end and back-endExample: a login page (front) + checking the password in a database (back)

8.3–8.4 HTML basics

HTML (HyperText Markup Language) is the standard language for creating web pages; its tags are like LEGO blocks. Created by Tim Berners-Lee in 1991. Versions: HTML 1.0 (1991), 2.0 (1995), 3.2 (1997, tables/scripts), 4.0 (1997, multimedia), 4.01 (1999), HTML5 (2014).

Tools: a text editor (Notepad, Notepad++, Sublime Text, VS Code) to write code, and a browser (Chrome, Firefox, Edge) to view it. Save the file with the .html extension (e.g. my_first_website.html) and open it in a browser; refresh after every change.

<!DOCTYPE html>
<html>
  <head>
    <title>My First Web Page</title>
  </head>
  <body>
    <h1>Welcome to My Website</h1>
    <p>This is my first web page.</p>
  </body>
</html>
PartPurpose
<!DOCTYPE html>Tells the browser this is an HTML5 document
<html>Root element of the page
<head>Information about the page (title, CSS links, meta)
<title>Text shown in the browser tab
<body>Everything visible on the page
<h1>Main heading
<p>Paragraph

Paired tags have an opening and closing tag: <p>…</p>. Unpaired (self-closing) tags have no closing tag: <img>, <br>, <hr>.

8.5 Creating content with HTML

ElementCodeNote
Headings<h1> … <h6>h1 = main title, h2–h6 smaller subheadings; help organisation, SEO and consistent formatting
Paragraph<p>Text</p>Block of text with space above and below
Link<a href="https://www.example.com">Visit</a>href gives the address; mailto: opens email
Image<img src="image.jpg" alt="description">alt text helps visually impaired users
Unordered list<ul><li>Item</li></ul>Bullets
Ordered list<ol><li>Item</li></ol>Numbers
Table<table><tr><th>Name</th></tr><tr><td>Ali</td></tr></table>tr = row, th = header cell, td = data cell
Horizontal line<hr>Unpaired tag
Comment<!– This is a comment –>Not shown by the browser; used for notes or disabling code
Division<div> … </div>Groups elements so they can be styled together

8.6 Styling with CSS

CSS (Cascading Style Sheets) controls colours, fonts, layout and design, keeping content (HTML) separate from presentation. A CSS rule has a selector and declarations: selector { property: value; }

h1 {
  color: red;
  font-size: 24px;
}
WayHowUse
Inline<h1 style="color: blue;">Hello</h1>Quick change to one element; gets messy
Internal<style> h1 { color: yellow; } </style> in the headStyles one whole page
External<link rel="stylesheet" href="styles.css"> in the headBest for big sites; one file styles many pages
  • Fonts: font-family (Arial, sans-serif), font-size (16px), font-weight (bold), font-style (italic).
  • Backgrounds: background-color, background-image: url(“pic.jpg”), background-repeat, background-position: center, background-size: cover.
  • Layouts: group content with div and section; CSS Grid (display: grid; rows and columns); Flexbox (display: flex; items in a row or column); positioning (position: absolute; top; left).
  • Box model: every element is a box – content, then padding (space inside the border), border, then margin (space outside the border).

Selectors: element selector (p), class selector (.box), id selector (#main), and pseudo-classes like :hover.

8.6.5 Animations and transitions

@keyframes example {
  from { background-color: red; }
  to   { background-color: yellow; }
}
.animated-box {
  width: 100px; height: 100px;
  animation-name: example;
  animation-duration: 4s;
  animation-iteration-count: infinite;
}
.box { width: 100px; background-color: red;
       transition: background-color 2s, width 2s; }
.box:hover { background-color: yellow; width: 200px; }

Animation uses @keyframes to change styles over time (can loop). Transition changes a property smoothly when its state changes, e.g. on hover.

8.7 JavaScript

JavaScript makes web pages interactive (pop-ups, buttons, games). Created by Brendan Eich in 1995 in 10 days (first called Mocha, then LiveScript). It is written inside <script> tags or in a separate file linked with <script src="script.js"></script>.

<script>
  var name = "Athar";
  var age = 15;
  alert("Name: " + name + ", Age: " + age);
</script>

Variables are declared with var, let or const. Comments: // single line and /* multi-line */.

Data typeExample
String (text, in quotes)var name = “Athar”;
Numbervar age = 15;
Booleanvar isStudent = true;
Arrayvar scores = [90, 85, 88];
function addNumbers(a, b) {
  var sum = a + b;
  alert("The sum is: " + sum);
}
addNumbers(5, 3);   // shows "The sum is: 8"
EventHappens when
onclickAn element is clicked
onloadPage or image finishes loading
onmouseoverMouse moves over an element
onmouseoutMouse leaves an element
onkeyupA key is released
<button onclick="showMessage()">Click Me!</button>
<script>
  function showMessage() { alert("Button was clicked!"); }
</script>

8.8 Debugging and testing

  • Browser developer tools: use the console (console.log) to see values and errors.
  • Read error messages and check code line by line for missing semicolons, unmatched braces, wrong names.
  • Common issues: broken links, wrongly nested or unclosed tags, CSS typos.
  • Testing: cross-browser testing (Chrome, Firefox, Edge), responsive testing (phone, tablet, desktop) and user testing.

Unit 8 exercise (solved)

A. Multiple choice questions

1. Which of the following is not a correct HTML tag?
(a) <div>   (b) <span>   (c) <head>   (d) <footer>
Answer: (d) <footer> – Answer as per the textbook key. Note: