Web Lab Manual
Web Lab Manual
LAB MANUAL
LAB 1
Overview
In this lab, we will cover the basics of HTML (HyperText Markup Language), which is used to
create webpages. HTML elements are represented by tags, and we will learn the different types
of tags, their structure, and how to use them to build a simple webpage.
1. HTML Basics
HTML (HyperText Markup Language): The standard language for creating web pages.
File Name: The main file is often named index.html.
Tags: HTML consists of two types of tags:
o Opening Tag: Starts with <tagname>.
o Closing Tag: Starts with </tagname>.
Example:
<p>This is a paragraph.</p>
Common Tags:
HTML Structure
<!DOCTYPE html>
<html>
<head>
<title>Document Title</title>
</head>
<body>
<p>This is a paragraph inside the body.</p>
</body>
</html>
<title>: Sets the title of the webpage (appears in the browser tab).
<body>: Contains all the content of the webpage (text, images, links, etc.).
HTML Tags:
<html>
<head>
</head>
<body>
<h1>Welcome to My Webpage</h1>
</body>
</html>
Additional Tips
1. Type ! and press Enter to get the HTML structure quickly in Visual Studio Code.
LAB 2
Objective:
To understand the basics of HTML tags for images and the process of how servers and DNS
work in web development.
Topics Covered
HTML Image Tag (<img>)
Servers and DNS (Domain Name System)
. HTML Image Tag (<img>)
Explanation:
The <img> tag in HTML is used to embed images on a webpage. It does not have a closing tag
and requires certain attributes to function correctly.
Attributes:
src: This stands for "source" and is used to define the path or URL to the image. The
src attribute tells the browser where to find the image.
Example: src="image_link.jpg"
alt: This stands for "alternative text" and is used when an image cannot be displayed.
The alt attribute provides text that describes the image.
Example: alt="An error loading image"
The alt text is beneficial for:
Accessibility: Screen readers read the alt text for visually impaired users.
SEO: Helps search engines understand the content of the image.
Error Handling: Displays a message if the image fails to load.
<img src="image_link.jpg" alt="Description of image">
OUTPUT
LAB 3
1. Input Tag (<input>)
The <input> tag is used to create interactive controls for forms in HTML. This tag is versatile
because it supports different types of input, like text fields, checkboxes, radio buttons, etc.
Attributes:
type: Specifies the type of input. Common types include:
text: Single-line text input.
password: Hides the text input (usually for passwords).
email: For email addresses.
checkbox: A checkbox input.
radio: A radio button (for single-choice options).
submit: A submit button to send the form data.
reset: A reset button to clear all inputs in the form.
number: Allows only numbers.
color: A color picker input.
url: For entering a URL.
date: For date selection.
Example:
<!-- Text Input Field -->
<input type="text" placeholder="Enter your name" size="30" required>
Attributes:
action: The URL where form data is sent upon submission.
method: Specifies the HTTP method used to send form data (post or get).
required: Ensures fields marked as required must be filled out before submitting.
Example:
<form action="/submit-form" method="post">
<label for="name">Name:</label>
<input type="text" id="name" name="name" required>
Example:
<form>
<input type="text" placeholder="Enter your name">
<input type="reset" value="Reset Form">
</form>
Example:
<form>
<p>Select your preferred language:</p>
<input type="radio" name="language" value="HTML"> HTML<br>
<input type="radio" name="language" value="CSS"> CSS<br>
<input type="radio" name="language" value="JavaScript"> JavaScript<br>
</form>
Example:
<form>
<p>Select your hobbies:</p>
<input type="checkbox" name="hobby" value="Reading"> Reading<br>
<input type="checkbox" name="hobby" value="Traveling"> Traveling<br>
<input type="checkbox" name="hobby" value="Gaming"> Gaming<br>
</form>
Example:
<form action="/submit-form" method="post">
<input type="text" name="username" placeholder="Enter your username">
<input type="submit" value="Submit">
</form>
Example:
<form>
<label for="country">Choose your country:</label>
<select id="country" name="country">
<option value="usa">USA</option>
<option value="canada">Canada</option>
<option value="india">India</option>
</select>
</form>
Example:
<form>
<label for="languages">Select languages you know:</label>
<select id="languages" name="languages" multiple>
<option value="html">HTML</option>
<option value="css">CSS</option>
<option value="js">JavaScript</option>
</select>
</form>
Example:
<form>
<label for="comments">Comments:</label><br>
<textarea id="comments" name="comments" rows="5" cols="30"></textarea>
</form>
Example:
<input type="text" value="This is read-only" readonly>
Example:
<input type="text" value="This is disabled" disabled>
OUTPUT:
LAB 4
OBJECTIVE:
In this lab, we will cover CSS (Cascading Style Sheets) basics, which allow us to style HTML
elements by adding colors, fonts, layouts, and much more. We’ll explore selectors, properties,
and shorthand techniques to help you quickly style your webpage.
1. CSS Selectors
Selectors in CSS are used to select HTML elements to apply styles to.
Types of Selectors:
p{
color: blue;
}
This applies the color blue to all <p> (paragraph) elements.
Class Selector: Selects all elements with a specific class. Classes are defined with a
dot (.) before the class name.
.myClass {
color: green;
}
ID Selector: Selects a single, unique element by ID. IDs are defined with a hash (#) before the
ID name.
#myId {
color: red;
Child Selector: Targets elements that are direct children of a specific element.
div > p {
color: purple;
This applies the color purple to <p> elements that are direct children of a <div>.
2. CSS Properties
Basic Properties:
text-decoration: underline;
3. Button Styling
To style buttons, you can use various properties to control its appearance.
button {
background-color: blue;
color: white;
border-radius: 5px;
4. Text Properties
background-color: yellow;
font-size: 16px;
font-weight: bold;
Text Align: Sets the alignment of the text (e.g., center or justify).
text-align: center;
text-transform: uppercase;
text-decoration: underline;
text-indent: 20px;
Border Style: Defines the style of the border (solid, dashed, dotted, etc.).
border-style: solid;
border-width: 2px;
Border Color: Specifies the color of the border.
border-color: black;
Shorthand Border: Combines width, style, and color into one line.
padding: 20px;
Margin: Adds space outside the border around elements, following the same syntax as
padding.
border-radius: 10px;
7. Image Styling
img {
width: 100px;
height: 100px;
border-radius: 50%;
}
Code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,
initial-scale=1.0">
<link rel="stylesheet" href="css4.css">
<title>Enrollment Form</title>
</head>
<body>
<form action="#" method="post" class="enrollment-
form">
<label for="email">Email:</label>
<input type="email" id="email" name="email"
placeholder="Enter your email" required>
<label for="password">Password:</label>
<input type="password" id="password"
name="password" placeholder="Create a password"
required>
<label for="address">Address:</label>
<textarea id="address" name="address" rows="4"
placeholder="Enter your address"></textarea>
<label for="course">Course:</label>
<select id="course" name="course" required>
<option value="">Select your course</option>
<option value="science">Science</option>
<option value="commerce">Commerce</option>
<option value="arts">Arts</option>
</select>
<p></p>
<label for="agreement">
<input type="checkbox" id="agreement"
name="agreement" required>
I agree to the terms and conditions
</label>
<button type="submit">Submit</button>
</form>
<br>
<img src="https://plus.unsplash.com/premium_photo-
1694819488591-a43907d1c5cc?
q=80&w=2028&auto=format&fit=crop&ixlib=rb-
4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVuf
DB8fHx8fA%3D%3D" alt="" class="small-rounded">
</body>
</html>
Style sheet:
{
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: Arial, sans-serif;
background-color: #f2f2f2;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
h2 {
text-align: center;
margin-bottom: 20px;
color: #333;
}
.enrollment-form {
background-color: #fff;
padding: 20px;
border-radius: 10px;
width: 300px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}
.enrollment-form label {
margin-top: 10px;
display: block;
font-weight: bold;
color: #555;
}
.enrollment-form input[type="text"],
.enrollment-form input[type="email"],
.enrollment-form input[type="password"],
.enrollment-form input[type="tel"],
.enrollment-form input[type="date"],
.enrollment-form select,
.enrollment-form textarea {
width: 100%;
padding: 10px;
margin-top: 1px;
border-radius: 5px;
border: 1px solid #ccc;
}
.enrollment-form textarea {
resize: vertical;
}
.enrollment-form button {
width: 100%;
padding: 10px;
margin-top: 15px;
background-color: #4CAF50;
border: none;
color: white;
font-size: 16px;
border-radius: 5px;
cursor: pointer;
}
.enrollment-form button:hover {
background-color: #45a049;
}
.enrollment-form input[type="checkbox"] {
margin-right: 5px;
}
.small-rounded {
width: 150px;
height: 150px;
border-radius: 50%;
object-fit: cover;
}