CSC329 · 2082 · 10 marks
Define CSS. What is the use of CSS shadow effects? Write an HTML script with proper CSS as per the following description. Display a text content "CSIT Exam" in a div with id div1. The text should have a horizontal shadow of 3px and a vertical shadow of 2px. The shadow color should be green. Also set
Define CSS. What is the use of CSS shadow effects? Write an HTML script with proper CSS as per the following description. Display a text content "CSIT Exam" in a div with id div1. The text should have a horizontal shadow of 3px and a vertical shadow of 2px. The shadow color should be green. Also set the horizontal and vertical shadow of the div to 10px respectively with the shadow color of div to blue.[10]
Quick answer
CSS (Cascading Style Sheets) is a style sheet language used to describe the presentation and formatting of HTML documents. It controls the layout, colors, fonts, spacing, and overall visual appearance of web pages.
CSS: Definition, Shadow Effects, and HTML Script
1. Definition of CSS
CSS separates content (HTML) from design (styling), making web pages more attractive, consistent, and easier to maintain across multiple pages.
2. Use of CSS Shadow Effects
CSS Shadow Effects are used to add visual depth and dimension to web page elements. They make text and boxes stand out from the background, improving the overall visual appeal of a webpage.
CSS provides two main shadow properties:
| Property | Purpose |
|---|---|
text-shadow | Adds shadow to text content |
box-shadow | Adds shadow to HTML elements (div, p, etc.) |
Syntax:
text-shadow: h-shadow v-shadow color;
box-shadow: h-shadow v-shadow color;
Where:
h-shadow-- Horizontal offset of the shadow (in px)v-shadow-- Vertical offset of the shadow (in px)color-- Color of the shadow
3. HTML Script with CSS Shadow Effects
Requirements:
- A
divwithid="div1"containing the text "CSIT Exam" - Text shadow: horizontal = 3px, vertical = 2px, color = green
- Box shadow: horizontal = 10px, vertical = 10px, color = blue
<!DOCTYPE html>
<html>
<head>
<title>CSS Shadow Effects</title>
<style>
#div1 {
font-size: 30px;
padding: 20px;
margin: 50px;
text-shadow: 3px 2px green;
box-shadow: 10px 10px blue;
}
</style>
</head>
<body>
<div id="div1">
CSIT Exam
</div>
</body>
</html>
4. Explanation of Properties Used
| Property | Value | Meaning |
|---|---|---|
text-shadow | 3px 2px green | 3px horizontal, 2px vertical, green colored shadow on the text |
box-shadow | 10px 10px blue | 10px horizontal, 10px vertical, blue colored shadow on the div |
font-size | 30px | Sets text size for visibility |
padding | 20px | Adds inner spacing inside the div |
margin | 50px | Adds outer spacing around the div |
Conclusion
CSS shadow effects enhance the visual appearance of web pages by adding depth to both text and box elements. The text-shadow property applies shadow to text content, while the box-shadow property applies shadow to block-level elements such as div. Both properties accept horizontal offset, vertical offset, and color as values.
Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.