Solved Exercise
Chapter 8 – Cascading Style Sheets
Q1. Fill in the blanks
a) To apply a background color to an element, you can use the background-color property
in CSS.
b) In the CSS box model, the padding property defines the space between the content of
an element and its border.
c) The font-size property sets the font size for text in CSS.
d) External type of stylesheet is used to make a separate .css file.
e) An external style sheet is used to define the style for many HTML pages.
Q2. TRUE / FALSE
1. CSS can be used to change the font of text on a webpage. → True
2. CSS can be used to set the color of an element’s text using the color property. → True
3. The margin property in CSS controls the space between the border of an element and its
content. → False
4. CSS can only be applied to HTML documents. → True
5. The background-image property can be used to add a background color to an element. →
False
Q3. What is the difference between HTML and CSS?
HTML CSS
CSS stands for Cascading Style
HTML stands for HyperText Markup Language.
Sheets.
It is used to control the design
It is used to create the structure and content of a web page.
and appearance of a web page.
It adds elements like headings, paragraphs, images, tables, It adds colors, fonts, spacing,
etc. layout, background, etc.
Example: <h1>Welcome</h1> Example: h1 { color: blue; }
Q4. What is CSS?
CSS (Cascading Style Sheets) is a stylesheet language used to describe how HTML elements
are displayed on the screen.
It is used to:
Change text color and size
Set background colors or images
Control layout and spacing
Improve the look of a website
Example
p{
color: red;
font-size: 16px;
Q5. Difference between Cell Padding and Cell Spacing.
Q6. Explain different types of CSS with example
There are three types of CSS:
1. Inline CSS
Used to apply style to one single HTML element.
Example:
<h1 style="color: blue;">Hello World</h1>
2. Internal CSS
Used to apply style to one HTML page. Written inside the <style> tag in the <head> section.
Example:
<head>
<style>
p { color: red; }
</style>
</head>
3. External CSS
Used to apply style to many HTML pages using a separate .css file.
HTML file:
<link rel="stylesheet" href="[Link]">
[Link] file:
p{
color: green;