Chapter 8: Web Development with HTML, CSS, and JavaScript – Solved Exercise

Solved Multiple Choice Questions with Explanations & Tips

1. Which of the following tag is not a correct HTML tag?

  • (a) <div>
  • (b) <span>
  • (c) <head>
  • (d) <footer>
    βœ… Answer: None of these (All are correct HTML tags)

πŸ”Ή Explanation:
All four options (<div>, <span>, <head>, <footer>) are valid HTML tags. <div> and <span> are used for structuring and styling, <head> contains metadata, and <footer> represents the footer section of a webpage.

πŸ’‘ Tip: Always check the latest HTML specifications for valid tags. You can refer to MDN Web Docs for updated information.


2. What does CSS stand for?

  • (a) Cascading Style Sheets
  • (b) Computer Style Sheets
  • (c) Creative Style Sheets
  • (d) Colorful Style Sheets
    βœ… Answer: (a) Cascading Style Sheets

πŸ”Ή Explanation:
CSS stands for Cascading Style Sheets, which is used to define the presentation of HTML documents, including layout, colors, and fonts.

πŸ’‘ Tip: The word “Cascading” refers to how styles are applied in a hierarchy, from external stylesheets to inline styles.


3. Which of the following tag is used to create a hyperlink in HTML?

  • (a) <link>
  • (b) <a>
  • (c) <href>
  • (d) <nav>
    βœ… Answer: (b) <a>

πŸ”Ή Explanation:
The <a> (anchor) tag is used to create hyperlinks in HTML. The href attribute inside the <a> tag specifies the link’s destination.

πŸ’‘ Tip: Use the target="_blank" attribute to open links in a new tab, like this: <a href="https://example.com" target="_blank">Click Here</a>.


4. Which property is used to change the background color in CSS?

  • (a) color
  • (b) background-color
  • (c) bgcolor
  • (d) background
    βœ… Answer: (b) background-color

πŸ”Ή Explanation:
The background-color property is used to set the background color of an element in CSS.

πŸ’‘ Tip: Use color for text color and background-color for background color. Example:

body {
  background-color: lightblue;
}

5. Which HTML attribute is used to define inline styles?

  • (a) class
  • (b) style
  • (c) font
  • (d) styles
    βœ… Answer: (b) style

πŸ”Ή Explanation:
The style attribute allows inline CSS styling directly in an HTML tag.

πŸ’‘ Tip: Avoid excessive use of inline styles; instead, use external CSS for better maintainability.
Example:

<p style="color: red;">This is a red text.</p>

6. Which of the following is the correct syntax for a CSS rule?

  • (a) selector {property: value;}
  • (b) selector: {property=value;}
  • (c) selector {property=value}
  • (d) selector: {property: value;}
    βœ… Answer: (a) selector {property: value;}

πŸ”Ή Explanation:
CSS rules follow the syntax:

selector {
  property: value;
}

πŸ’‘ Tip: Always end CSS statements with a semicolon (;) to avoid errors.


7. In JavaScript, which markup is used for comments?

  • (a) /* */
  • (b) //
  • (c) <–
  • (d) /* */
    βœ… Answer: Both (a) and (b)

πŸ”Ή Explanation:

  • Single-line comments: // This is a comment
  • Multi-line comments: /* This is a multi-line comment */

πŸ’‘ Tip: Use comments to explain code but avoid excessive commenting in obvious cases.


8. How do you include JavaScript in an HTML document?

  • (a) <script src="script.js"></script>
  • (b) <java src="script.js"></java>
  • (c) <js src="script.js"></js>
  • (d) <code src="script.js"></code>
    βœ… Answer: (a) <script src="script.js"></script>

πŸ”Ή Explanation:
JavaScript is included in HTML using the <script> tag, either inline or by linking an external file.

πŸ’‘ Tip: Place <script> before the closing </body> tag to improve page load speed.


9. Which HTML tag is used to create an unordered list?

  • (a) <ol>
  • (b) <ul>
  • (c) <li>
  • (d) <list>
    βœ… Answer: (b) <ul>

πŸ”Ή Explanation:
The <ul> tag is used for unordered (bulleted) lists, whereas <ol> is for ordered (numbered) lists.

πŸ’‘ Tip: Use <li> inside <ul> or <ol> to define list items.
Example:

<ul>
  <li>Item 1</li>
  <li>Item 2</li>
</ul>

10. Which tag is used to display a horizontal line in HTML?

  • (a) <br>
  • (b) <hr>
  • (c) <line>
  • (d) <hline>
    βœ… Answer: (b) <hr>

πŸ”Ή Explanation:
The <hr> (horizontal rule) tag creates a horizontal line in HTML, typically used to separate content.

πŸ’‘ Tip: Customize the appearance using CSS, e.g.:

hr {
  border: 2px solid black;
}

Solved Short Questions (Simple & Easy Language)

1. What is the purpose of the <head> tag in HTML?

The <head> tag contains important information about the web page that is not visible to users. It includes:

  • The title of the page (<title>)
  • Links to CSS files (<link>)
  • Meta information (<meta>)
  • JavaScript files (<script>)

2. Explain the difference between an ordered list and an unordered list in HTML.

  • Ordered List (<ol>): It shows items in a numbered format (1, 2, 3…).
  • Unordered List (<ul>): It shows items with bullet points (●, β– , β—‹).

Example:

<ol>
  <li>First Item</li>
  <li>Second Item</li>
</ol>

<ul>
  <li>First Item</li>
  <li>Second Item</li>
</ul>

3. How do you add a comment in CSS?

In CSS, we use /* */ for comments.
Example:

/* This is a comment */
p {
  color: blue; /* This line changes text color to blue */
}

Comments are ignored by the browser and are used to explain code.


4. What are the different ways to apply CSS to an HTML document?

There are three ways to apply CSS:

  1. Inline CSS – Written inside the HTML tag using the style attribute. <p style="color: red;">Hello</p>
  2. Internal CSS – Written inside the <style> tag in the <head> section. <style> p { color: blue; } </style>
  3. External CSS – Written in a separate .css file and linked using <link>. <link rel="stylesheet" href="style.css">

5. How can you include JavaScript in an HTML file?

We can include JavaScript in two ways:

  1. Inline JavaScript: Inside the <script> tag in the HTML file. <script> alert("Hello World!"); </script>
  2. External JavaScript: Linking a separate JavaScript file (.js). <script src="script.js"></script>

6. Describe the syntax for creating a hyperlink in HTML.

A hyperlink is created using the <a> tag with the href attribute.
Example:

<a href="https://www.google.com">Visit Google</a>

This will create a clickable link that opens Google.


7. What is the function of the <div> tag in HTML?

The <div> tag is used to group other HTML elements together. It helps in styling and layout design.

Example:

<div style="background-color: lightgray; padding: 10px;">
  <p>This is inside a div.</p>
</div>

It is like a container for other elements.


8. How do you link an external CSS file to an HTML document?

We use the <link> tag inside the <head> section.

Example:

<link rel="stylesheet" href="style.css">

This connects an external style.css file to the HTML page.


9. What is the use of the <table> tag in HTML?

The <table> tag is used to create tables to display data in rows and columns.

Example:

<table border="1">
  <tr>
    <th>Name</th>
    <th>Age</th>
  </tr>
  <tr>
    <td>Ali</td>
    <td>15</td>
  </tr>
</table>

This will create a simple table with a border.


10. Explain the box model in CSS.

The CSS box model explains how elements are displayed on a webpage. It includes:

  1. Content – The main text or image inside the box.
  2. Padding – Space inside the box, around the content.
  3. Border – The outer edge of the box.
  4. Margin – Space outside the box, separating it from other elements.

Example:

div {
  width: 200px;
  padding: 10px;
  border: 5px solid black;
  margin: 20px;
}

This defines a box with content, padding, border, and margin.


πŸ’‘ Tip for Students: Keep practicing with small HTML and CSS examples to understand better. πŸš€

Solved Long Questions (Simple & Easy for Class 9)


1. Discuss the fundamental differences between HTML, CSS, and JavaScript in the context of web development.

In web development, HTML, CSS, and JavaScript work together to create a complete website. Here’s how they differ:

FeatureHTMLCSSJavaScript
PurposeStructure of a webpageStyling and designMakes the webpage interactive
What it doesDefines headings, paragraphs, images, tables, etc.Changes colors, fonts, layout, and animationsAdds buttons, forms, and real-time interactions
Example<h1>Heading</h1>h1 { color: red; }document.write("Hello!");

πŸ”Ή Simple Example:

<!DOCTYPE html>
<html>
<head>
    <style>
        h1 { color: blue; }
    </style>
    <script>
        function showMessage() {
            alert("Hello, this is JavaScript!");
        }
    </script>
</head>
<body>
    <h1>Welcome to Web Development</h1>
    <button onclick="showMessage()">Click Me</button>
</body>
</html>

βœ… HTML creates the heading and button.
βœ… CSS makes the heading blue.
βœ… JavaScript makes the button show an alert when clicked.


2. Explain the process of setting up a development environment for web development.

To start web development, you need some basic software and tools:

1. Text Editor (for writing code)

  • Notepad++ (Simple and easy)
  • VS Code (Popular among developers)

2. Web Browser (for testing webpages)

  • Google Chrome (Best for development)
  • Mozilla Firefox

3. Local Web Server (for testing advanced web pages)

  • XAMPP (For PHP and databases)

4. Steps to Set Up

  1. Install VS Code and a web browser.
  2. Open VS Code and create an index.html file.
  3. Write a basic HTML page and save it.
  4. Open the file in a web browser to see your webpage.

πŸ’‘ Tip: Always save your file with .html extension before testing.


3. Create a basic HTML page that includes a header, a paragraph, an image, and a hyperlink.

βœ… Code for a simple webpage:

<!DOCTYPE html>
<html>
<head>
    <title>My First Webpage</title>
</head>
<body>
    <h1>Welcome to My Website</h1>
    <p>This is my first webpage. I am learning HTML!</p>
    <img src="image.jpg" alt="A beautiful scenery" width="300">
    <br>
    <a href="https://www.google.com">Click here to visit Google</a>
</body>
</html>

πŸ’‘ Save this as index.html and open it in a browser.


4. How do you style a table using CSS? Create a sample table and apply styles to it.

βœ… HTML Table with CSS Styling

<!DOCTYPE html>
<html>
<head>
    <style>
        table {
            width: 50%;
            border-collapse: collapse;
        }
        th, td {
            border: 1px solid black;
            padding: 10px;
            text-align: center;
        }
        th {
            background-color: lightblue;
        }
        tr:nth-child(even) {
            background-color: lightgray;
        }
    </style>
</head>
<body>
    <h2>Student Marks</h2>
    <table>
        <tr>
            <th>Name</th>
            <th>Marks</th>
        </tr>
        <tr>
            <td>Ali</td>
            <td>85</td>
        </tr>
        <tr>
            <td>Sara</td>
            <td>90</td>
        </tr>
    </table>
</body>
</html>

πŸ’‘ Tip: Use border-collapse: collapse; to remove space between table borders.


5. Describe the different CSS selectors and provide examples of each.

Selector TypeExampleDescription
Element Selectorp { color: red; }Styles all <p> tags.
Class Selector.highlight { color: blue; }Styles elements with class="highlight".
ID Selector#title { font-size: 20px; }Styles an element with id="title".
Group Selectorh1, h2 { text-align: center; }Styles multiple elements together.

βœ… Example:

#main {
    color: green;
}
.highlight {
    background-color: yellow;
}

πŸ’‘ Tip: Use classes when styling multiple elements and IDs for unique elements.


6. Explain the process of creating a responsive web page using CSS.

A responsive webpage adjusts its layout for different screen sizes.

βœ… Example using Media Queries:

body {
    font-size: 16px;
}
@media (max-width: 600px) {
    body {
        font-size: 12px;
    }
}

πŸ”Ή Explanation:

  • The font size is 16px by default.
  • When the screen width is 600px or smaller, the font size reduces to 12px.

πŸ’‘ Tip: Use flexbox and grid for better responsive design.


7. Write a JavaScript function that changes the background color of a web page when a button is clicked.

βœ… HTML + JavaScript Code:

<!DOCTYPE html>
<html>
<head>
    <script>
        function changeColor() {
            document.body.style.backgroundColor = "lightblue";
        }
    </script>
</head>
<body>
    <button onclick="changeColor()">Click to Change Color</button>
</body>
</html>

πŸ”Ή Explanation:

  • The onclick event runs the changeColor() function when the button is clicked.
  • document.body.style.backgroundColor = "lightblue"; changes the background color.

πŸ’‘ Tip: You can use "random" colors using Math.random().


8. How do you add animations and transitions using CSS?

βœ… Example of a simple animation:

@keyframes move {
    from { left: 0px; }
    to { left: 200px; }
}

.box {
    position: relative;
    width: 100px;
    height: 100px;
    background-color: red;
    animation: move 2s linear infinite;
}

βœ… Example of a button with transition:

button {
    background-color: blue;
    color: white;
    padding: 10px;
    transition: background-color 0.5s;
}
button:hover {
    background-color: green;
}

πŸ”Ή Explanation:

  • Animation moves a box from left to right.
  • Transition smoothly changes button color when hovered.

πŸ’‘ Tip: Use ease-in-out for smoother effects.


πŸ”₯ Conclusion: Learning HTML, CSS, and JavaScript step by step helps in building amazing websites. Keep practicing and experimenting with code! πŸš€

Chapter 5 Software System – 9th Class Computer Science | Solved Exercise

Multiple Choice Questions (MCQs) with Answers, Explanations, and Tips


1. What is the primary function of an operating system?

Statement: The operating system is the core software that manages the computer’s hardware and provides an interface for users.
Options:
a) To create documents
b) To manage hardware resources and provide a user interface
c) To perform calculations
d) To design graphics
Answer: b) To manage hardware resources and provide a user interface
Explanation: The Operating System (OS) controls hardware resources, provides a user interface, and manages applications. Examples include Windows, macOS, and Linux.
Tip: Remember, an OS acts as a bridge between the hardware and the user.


2. Which software is used to enhance system performance and security?

Statement: Some specialized software helps in optimizing system performance and protecting it from threats.
Options:
a) Operating system
b) Utility software
c) Application software
d) Device drivers
Answer: b) Utility software
Explanation: Utility software includes tools like antivirus programs, disk cleanup, and system optimization tools, which help in maintaining the system’s efficiency and security.
Tip: Think of utility software as a maintenance tool for your computer.


3. What role do device drivers play in a computer system?

Statement: Device drivers are essential software components that ensure communication between the OS and hardware.
Options:
a) Manage files
b) Facilitate communication between hardware devices and the operating system
c) Create presentations
d) Enhance graphics performance
Answer: b) Facilitate communication between hardware devices and the operating system
Explanation: A device driver enables the OS to recognize and communicate with hardware components like printers, keyboards, and graphics cards. Without drivers, hardware may not function correctly.
Tip: Think of a driver as a translator between hardware and software.


4. Which of the following is an example of application software?

Statement: Application software helps users perform specific tasks.
Options:
a) Microsoft Word
b) BIOS
c) Disk Cleanup
d) Device Manager
Answer: a) Microsoft Word
Explanation: Application software is designed for end-users, such as word processors, web browsers, and media players. Microsoft Word is a word-processing application used to create and edit documents.
Tip: If it helps users perform a task, it’s application software.


5. What is the main purpose of spreadsheet software?

Statement: Spreadsheet software helps users manage and analyze numerical data efficiently.
Options:
a) To edit text documents
b) To organize and analyze data
c) To create visual content
d) To enhance system security
Answer: b) To organize and analyze data
Explanation: Spreadsheet software, like Microsoft Excel and Google Sheets, is used for data management, calculations, and financial analysis.
Tip: Spreadsheets = Numbers + Calculations.


6. How does utility software differ from application software?

Statement: Utility software serves a different purpose than application software in computing.
Options:
a) Utility software manages hardware, while application software performs specific tasks for users.
b) Utility software creates documents, while application software manages hardware.
c) Utility software performs specific tasks for users, while application software manages hardware.
d) Utility software is free, while application software is paid.
Answer: a) Utility software manages hardware, while application software performs specific tasks for users.
Explanation: Utility software focuses on system maintenance, such as antivirus, file management, and disk cleanup, while application software includes tools for document editing, browsing, and media playback.
Tip: Utility = Maintenance, Application = User Tasks.


7. Which type of software would you use to design a logo?

Statement: Graphic design software is commonly used for creating digital artwork, including logos.
Options:
a) Operating system
b) Spreadsheet software
c) Graphic design software
d) Utility software
Answer: c) Graphic design software
Explanation: Graphic design software, like Adobe Photoshop, Illustrator, and CorelDRAW, is specifically designed for creating images, logos, and digital art.
Tip: If it involves image editing or design, it’s graphic design software.


8. What is the function of system software?

Statement: System software plays a crucial role in managing computer hardware and software interactions.
Options:
a) To facilitate communication between hardware and software
b) To perform specific tasks for the user
c) To create visual content
d) To organize and analyze data
Answer: a) To facilitate communication between hardware and software
Explanation: System software includes the operating system, drivers, and utility programs, ensuring the smooth functioning of hardware and applications.
Tip: System software = Foundation of a computer system.


9. Why are operating system updates important?

Statement: Regular OS updates ensure system security, performance improvements, and bug fixes.
Options:
a) They increase screen brightness
b) They add more fonts
c) They enhance security and fix bugs
d) They improve battery life
Answer: c) They enhance security and fix bugs
Explanation: OS updates patch security vulnerabilities, improve software compatibility, and fix system bugs. Ignoring updates can lead to security risks.
Tip: Always update your OS for better security and performance!


Summary of Tips & Tricks

  1. Operating System = Manages hardware & software interactions.
  2. Utility Software = System maintenance tools like antivirus & cleanup.
  3. Device Drivers = Bridge between hardware and the OS.
  4. Application Software = Programs for user tasks (e.g., Word, Excel).
  5. Spreadsheet Software = Deals with numbers & data analysis.
  6. Graphic Design Software = Used for logos, editing, and illustrations.
  7. System Software = Backbone of the computer system.
  8. OS Updates = Improve security & fix issues.

Solved Short Questions

1. Define system software and provide two examples.

Answer: System software is a type of software that manages and controls computer hardware and provides a platform for running application software.
Examples:

  1. Operating System (OS) – Windows, Linux
  2. Utility Software – Antivirus, Disk Cleanup

Key Words: System software, Operating System, Utility Software, Hardware Management


2. Explain the primary functions of an operating system.

Answer: The operating system performs the following key functions:

  1. Hardware Management – Controls CPU, memory, and devices.
  2. User Interface – Provides a way for users to interact (GUI/CLI).
  3. File Management – Organizes, saves, and retrieves files.
  4. Security Management – Protects data through authentication.

Key Words: Hardware, User Interface, File Management, Security


3. What is utility software and why is it important?

Answer: Utility software helps maintain, optimize, and secure a computer system. It is important because it enhances system performance and ensures security.
Examples:

  • Antivirus Software – Protects from viruses.
  • Disk Cleanup – Removes unnecessary files to free space.

Key Words: Maintenance, Optimization, Security, Antivirus, Disk Cleanup


4. Describe the role of device drivers in a computer system.

Answer: A device driver is software that allows the operating system to communicate with hardware devices such as printers, keyboards, and graphics cards.

  • Without drivers, hardware cannot function properly.

Key Words: Communication, Hardware, Operating System, Printer, Keyboard


5. Differentiate between system software and application software with examples.

Answer:

FeatureSystem SoftwareApplication Software
PurposeManages hardware & system functionsHelps users perform specific tasks
ExamplesOperating System, Device DriversMS Word, Adobe Photoshop
User InteractionWorks in the backgroundDirectly used by users

Key Words: System Control, User Task, OS, Application


6. What are the main functions of spreadsheet software?

Answer:

  1. Data Organization – Stores and arranges data in rows/columns.
  2. Mathematical Calculations – Performs functions like addition and averages.
  3. Data Analysis – Creates charts and graphs.
  4. Financial Planning – Used for budgeting and accounting.

Key Words: Excel, Data Analysis, Formulas, Charts


7. How can graphic design software be used in the field of education?

Answer:

  • Helps students create visual presentations.
  • Used for designing educational posters and infographics.
  • Assists in digital art and creative projects.

Examples: Adobe Photoshop, Canva

Key Words: Education, Visual Learning, Creativity, Infographics


8. What is the significance of data backups and how can they be performed?

Answer:
Significance: Protects against data loss due to system crashes, malware, or accidental deletion.
Methods:

  1. Cloud Backup – Google Drive, OneDrive.
  2. External Storage – USB, Hard Disk.
  3. Automated Backup Software – Backup utilities in OS.

Key Words: Data Protection, Cloud Storage, USB, Security


Solved Long Questions

1. Discuss the importance of system software in a computing system.

Answer:
System software is essential because it enables the hardware and software to function together efficiently. Without system software, a computer cannot operate properly.

Importance of System Software:

  1. Hardware Management: Controls CPU, memory, and peripheral devices.
  2. User Interface: Provides GUI (Graphical User Interface) or CLI (Command Line Interface) for user interaction.
  3. File Management: Organizes, retrieves, and manages storage.
  4. Security & Protection: Manages user authentication and system security.
  5. Performance Optimization: Utility software enhances system performance.

Examples:

  • Windows, macOS (Operating Systems)
  • Antivirus, Disk Cleanup (Utility Software)

Key Words: Hardware, Security, Performance, GUI, Operating System


2. Describe the roles of operating systems, utility software, and device drivers, providing examples of each.

Answer:

Software TypeFunctionExamples
Operating SystemManages hardware & software, provides UIWindows, Linux
Utility SoftwareOptimizes system performance & securityAntivirus, Disk Cleanup
Device DriversEnables communication between OS & hardwarePrinter Driver, GPU Driver

1. Operating System:

  • Controls hardware resources.
  • Provides security features like password protection.

2. Utility Software:

  • Maintains system efficiency.
  • Examples: Disk Defragmenter (organizes files), Firewall (prevents cyber threats).

3. Device Drivers:

  • Acts as a bridge between hardware and the operating system.
  • Example: A printer driver allows the OS to send print commands.

Key Words: System Software, Utility, Driver, OS, Hardware


3. Explain the differences between system software and application software.

Answer:
System software is responsible for managing system operations, whereas application software is designed for user tasks.

Differences:

FeatureSystem SoftwareApplication Software
FunctionControls system operationsPerforms specific tasks
User InteractionWorks in the backgroundDirectly used by users
ExamplesOS, Drivers, Utility SoftwareMS Word, Photoshop

Key Words: System Operations, User Task, OS, Applications


4. Describe the process of using utility software to optimize system performance and maintain security.

Answer:
Utility software improves system performance and protects it from threats.

Steps to Optimize Performance:

  1. Run Disk Cleanup – Deletes junk files.
  2. Use Disk Defragmentation – Arranges fragmented files for faster access.
  3. Check for Malware – Use antivirus software for security.
  4. Manage Startup Programs – Reduces system boot time.

Common Utility Software:

  • Antivirus Software – Prevents viruses.
  • Firewall – Protects from cyber threats.

Key Words: Optimization, Security, Antivirus, Firewall, Disk Cleanup


5. Explain how to install, update, and troubleshoot device drivers for hardware components.

Answer:

Steps to Install/Update Drivers:

  1. Manual Installation:
    • Download driver from manufacturer’s website.
    • Install using setup file.
  2. Automatic Update:
    • Use Windows Device Manager to update drivers.
  3. Troubleshooting:
    • If hardware does not work, reinstall the driver.
    • Check for error messages and update accordingly.

Key Words: Drivers, Installation, Update, Troubleshoot, Device Manager


6. Discuss the main functions of commonly used application software.

Answer:

Types of Application Software:

TypePurposeExamples
Word ProcessingCreate/edit documentsMS Word, Google Docs
SpreadsheetOrganize & analyze dataMS Excel, Google Sheets
PresentationCreate slideshowsMS PowerPoint, Canva
Graphic DesignCreate visualsPhotoshop, Illustrator
  • Word Processors are used for writing documents.
  • Spreadsheets handle data calculations.
  • Presentation software is used for making slideshows.
  • Graphic design software creates digital artwork.

Key Words: Word Processing, Spreadsheet, Presentation, Graphic Design