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)
- (b)
- (c)
- (d)
β Answer: None of these (All are correct HTML tags)πΉ Explanation:
All four options (,,,) are valid HTML tags.andare used for structuring and styling,contains metadata, andrepresents 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?
πΉ Explanation:
The(anchor) tag is used to create hyperlinks in HTML. Thehrefattribute inside thetag specifies the linkβs destination.π‘ Tip: Use the
target="_blank"attribute to open links in a new tab, like this:Click Here.
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:
Thebackground-colorproperty is used to set the background color of an element in CSS.π‘ Tip: Use
colorfor text color andbackground-colorfor 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:
Thestyleattribute allows inline CSS styling directly in an HTML tag.π‘ Tip: Avoid excessive use of inline styles; instead, use external CSS for better maintainability.
Example:This is a red text.
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)
- (b)
- (c)
- (d)
β Answer: (a)
πΉ Explanation:
JavaScript is included in HTML using thetag, either inline or by linking an external file.π‘ Tip: Place
before the closingtag to improve page load speed.
9. Which HTML tag is used to create an unordered list?
- (a)
- (b)
- (c)
- (d)
β Answer: (b)
πΉ Explanation:
Thetag is used for unordered (bulleted) lists, whereasis for ordered (numbered) lists.π‘ Tip: Use
insideorto define list items.
Example:- Item 1
- Item 2
10. Which tag is used to display a horizontal line in HTML?
- (a)
- (b)
- (c)
- (d)
β Answer: (b)
πΉ Explanation:
The(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
tag in HTML?The
tag contains important information about the web page that is not visible to users. It includes:- The title of the page (
) - Links to CSS files (
) - Meta information (
) - JavaScript files (
)
2. Explain the difference between an ordered list and an unordered list in HTML.
- Ordered List (
): It shows items in a numbered format (1, 2, 3β¦). - Unordered List (
): It shows items with bullet points (β, β , β).
Example:
- First Item
- Second Item
- First Item
- Second Item
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:
- Inline CSS β Written inside the HTML tag using the
styleattribute.Hello
- Internal CSS β Written inside the
tag in thesection. - External CSS β Written in a separate
.cssfile and linked using.
5. How can you include JavaScript in an HTML file?
We can include JavaScript in two ways:
- Inline JavaScript: Inside the
tag in the HTML file. - External JavaScript: Linking a separate JavaScript file (
.js).
6. Describe the syntax for creating a hyperlink in HTML.
A hyperlink is created using the
tag with thehrefattribute.
Example:Visit GoogleThis will create a clickable link that opens Google.
7. What is the function of the
tag in HTML?The
tag is used to group other HTML elements together. It helps in styling and layout design.Example:
This is inside a 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
tag inside thesection.Example:
This connects an external
style.cssfile to the HTML page.
9. What is the use of the
tag in HTML?
The
tag is used to create tables to display data in rows and columns.
Example:
Name Age Ali 15 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:
- Content β The main text or image inside the box.
- Padding β Space inside the box, around the content.
- Border β The outer edge of the box.
- 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:
Feature HTML CSS JavaScript Purpose Structure of a webpage Styling and design Makes the webpage interactive What it does Defines headings, paragraphs, images, tables, etc. Changes colors, fonts, layout, and animations Adds buttons, forms, and real-time interactions Example Heading
h1 { color: red; }document.write("Hello!");πΉ Simple Example:
Welcome to Web Development
β 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
- Install VS Code and a web browser.
- Open VS Code and create an
index.htmlfile. - Write a basic HTML page and save it.
- Open the file in a web browser to see your webpage.
π‘ Tip: Always save your file with
.htmlextension before testing.
3. Create a basic HTML page that includes a header, a paragraph, an image, and a hyperlink.
β Code for a simple webpage:
My First Webpage Welcome to My Website
This is my first webpage. I am learning HTML!
Click here to visit Googleπ‘ Save this as
index.htmland 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
Student Marks
Name Marks Ali 85 Sara 90 π‘ Tip: Use
border-collapse: collapse;to remove space between table borders.
5. Describe the different CSS selectors and provide examples of each.
Selector Type Example Description Element Selector p { color: red; }Styles all tags.Class Selector .highlight { color: blue; }Styles elements with class="highlight".ID Selector #title { font-size: 20px; }Styles an element with id="title".Group Selector h1, 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:
πΉ Explanation:
- The
onclickevent runs thechangeColor()function when the button is clicked. document.body.style.backgroundColor = "lightblue";changes the background color.
π‘ Tip: You can use
"random"colors usingMath.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-outfor smoother effects.
π₯ Conclusion: Learning HTML, CSS, and JavaScript step by step helps in building amazing websites. Keep practicing and experimenting with code! π
One Reply to “Chapter 8: Web Development with HTML, CSS, and JavaScript β Solved Exercise”
Leave a Reply
- (b)

Thanks for the good writeup. It if truth be told was once a leisure account it.
Look complicated to far added agreeable from
you! However, how can we be in contact?