HTML + CSS Beginner Worksheets — 4
Program 1 — Colorful Heading Page
Purpose: Learn how to style headings, text color, font, and alignment.
Code (copy into [Link]):
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Colorful Heading</title>
<style>
body {
background-color: #f9f9f9;
text-align: center;
font-family: Arial, sans-serif;
}
h1 {
color: #0b76ef;
text-transform: uppercase;
letter-spacing: 2px;
}
p{
color: #555;
font-size: 18px;
}
</style>
</head>
<body>
<h1>Welcome to HTML & CSS Learning</h1>
<p>Practice styling headings and text easily!</p>
</body>
</html>
Exercises:
• Change heading color to green.
• Make the paragraph font-size 20px.
• Center the paragraph and add a top margin.
Program 2 — Simple Quote Box
Purpose: Create a styled box using borders, padding, rounded corners, and shadow.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Quote Box</title>
<style>
body {
font-family: 'Trebuchet MS', sans-serif;
background-color: #eef4fa;
text-align: center;
margin-top: 100px;
}
.quote-box {
background-color: #fff;
border: 2px solid #0b76ef;
padding: 20px;
border-radius: 10px;
display: inline-block;
box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}
.quote {
color: #333;
font-style: italic;
}
.author {
color: #0b76ef;
font-weight: bold;
margin-top: 10px;
}
</style>
</head>
<body>
<div class="quote-box">
<p class="quote">"The best way to learn coding is by doing it!"</p>
<p class="author">– Anonymous</p>
</div>
</body>
</html>
Exercises:
• Change the border color to #ff6347 (tomato).
• Increase border-radius to 20px.
• Replace quote text with your favorite quote.
Program 3 — Navigation Bar
Purpose: Build a simple navigation menu with hover effects.
Code (copy into [Link]):
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Navigation Bar</title>
<style>
body {
margin: 0;
font-family: Arial, sans-serif;
}
.navbar {
background-color: #0b76ef;
overflow: hidden;
text-align: center;
}
.navbar a {
color: white;
text-decoration: none;
padding: 14px 20px;
display: inline-block;
transition: 0.3s;
}
.navbar a:hover {
background-color: white;
color: #0b76ef;
}
</style>
</head>
<body>
<div class="navbar">
<a href="#">Home</a>
<a href="#">About</a>
<a href="#">Courses</a>
<a href="#">Contact</a>
</div>
</body>
</html>
Exercises:
• Add an 'Apply' link at the end of the navbar.
• Change the navbar height to 60px and center links vertically.
• Make the hover effect change text to bold as well.
Program 4 — Feedback Form Design
Purpose: Style a small form with inputs and a submit button.
Code (copy into [Link]):
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Feedback Form</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f8fc;
text-align: center;
margin-top: 50px;
}
.form-box {
background-color: #fff;
padding: 25px;
width: 300px;
margin: auto;
border-radius: 10px;
box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}
input, textarea {
width: 90%;
padding: 8px;
margin: 8px 0;
border: 1px solid #ccc;
border-radius: 5px;
}
button {
background-color: #0b76ef;
color: white;
border: none;
padding: 10px 20px;
border-radius: 5px;
cursor: pointer;
}
button:hover {
background-color: #085cc0;
}
</style>
</head>
<body>
<div class="form-box">
<h2>Feedback Form</h2>
<input type="text" placeholder="Your Name"><br>
<textarea rows="3" placeholder="Your Feedback"></textarea><br>
<button>Submit</button>
</div>
</body>
</html>
Exercises:
• Make the form-box width 350px.
• Change the submit button color to green.
• Add a 'Email' input field above the feedback textarea.