web
web
GROUP ASSIGNMENT
NAME: Tekalgn Kasahun
ID: EU0101/12-0
1. Create a basic HTML page with a title, a header, and two paragraphs. Use a meta
tag to define the character set as UTF-8
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Web Programming</title>
</head>
<body>
<h1>Welcome </h1>
</body>
</html>
2. Add an image to an HTML page using the <img> tag. Include alternate text and
set the image dimensions
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
</head>
<body>
<h2>Ordered List</h2>
<ol>
<li>First </li>
<li>Second </li>
<li>Third </li>
</ol>
<h2>Unordered List</h2>
<li>Apple</li>
<li>Banana</li>
<li>Cherry</li>
</ul>
</body>
</html>
4. Design a web page with hyperlinks. Use the target attribute to open some links
in new tabs and others in the same tab
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Hyperlinks </title>
</head>
<body>
</body>
</html>
5. Create an image map using the <map> tag and define clickable areas within an
image
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Image Map</title>
</head>
<body>
<map name="imagemap">
</map>
</body>
</html>
#header {
color: blue;
.list-item {
font-weight: bold;
*{
margin: 0;
padding: 0;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>CSS</title>
</head>
<body>
<ul>
</ul>
</body>
</html>
body {
background-image: url('background.jpg');
background-color: lightgray;
background-repeat: no-repeat;
background-position: center;
}
8. Use the CSS box model to style a div. Add margins, borders, and padding, and
demonstrate how these properties interact
.box {
width: 200px;
height: 200px;
margin: 20px;
padding: 15px;
9. Write a JavaScript program to validate a form with fields for name and email.
Ensure the name is not empty and the email follows a valid format
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> Validation</title>
</head>
<body>
<label for="name">Name:</label>
<input type="text" id="name" name="name"><br>
<label for="email">Email:</label>
<button type="submit">Submit</button>
</form>
<script>
function validateForm() {
return false;
if (!emailPattern.test(email)) {
return false;
return true;
</script>
</body>
</html>
10. Create a web page where clicking a button toggles the visibility of a paragraph
using JavaScript
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
</head>
<body>
<script>
function toggleVisibility() {
paragraph.style.display = "block";
} else {
paragraph.style.display = "none";
</script>
</body>
</html>
11. Develop a program that changes the background color of a web page based on
a dropdown menu selection
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
</head>
<body>
<select onchange="changeBackground(this.value)">
<option value="white">White</option>
</select>
<script>
function changeBackground(color) {
document.body.style.backgroundColor =
color;
</script>
</body>
</html>
12. Write a PHP script to handle form submissions. Collect user input (name and
email), validate it, and display the data on the same page
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>PHP Form</title>
</head>
<body>
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$name = $_POST['name'];
$email = $_POST['email'];
FILTER_VALIDATE_EMAIL)) {
} else {
?>
<form method="post">
<label for="name">Name:</label>
<label for="email">Email:</label>
<button type="submit">Submit</button>
</form>
</body>
</html>
13. Create a PHP script that uses an associative array to store and display a list of
countries and their capitals
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
</head>
<body>
<?php
$countries = [
];
?>
</body>
</html>
14. Develop a PHP program that connects to a MySQL database, retrieves data
from a table, and displays it in an HTML table
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>MySQL Data</title>
</head>
<body>
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "testdb";
if ($conn->connect_error) {
$result = $conn->query($sql);
if ($result->num_rows > 0) {
echo "</table>";
} else {
$conn->close();
?>
</body>
</html>