Web Design and Internet Programming Lab Manual (2)
Web Design and Internet Programming Lab Manual (2)
MANUAL
Client-side development (front-end)
Lab 1. HTML (Hypertext Markup Language): Defines the structure of the webpage
<html>
<head>
<itle >
</title>
</head>
<body>
<>me to
<p>this is my first html document I created </p></html>
AITS, TATI...
HTML document structure: An HTML document starts and ends with and
Tags. These tags tell the browser that the entire document is composed in HTML.
Inside these two tags the document is split into 2 sections:
1. The <head> ……</head> elements contain information about the
document such as title of the document etc.
2. The <body>…. </body>Elements contains the real content of the
document that you see on your screen.
ATTRIBUTES:
B. An attribute is used to define the characteristics of an element and is placed inside the
element’s opening tag. All attributes are made up of parts: a name and a value. -The name
is the property you want to set. -The value is what you want the value of the property to
be.
</html>
<header>
<marquee direction="right"><h1>Welcome to My HTML Lab</h1></marquee>
</header>
<main>
<section>
<h2 class="section-title" style="background-color: lightgrey;">1.
Introduction</h2>
<p>This is a simple HTML page used to demonstrate basic elements of HTML.
We will show headings, paragraphs, links, images, lists, and tables in this practical.</p>
</section>
<section>
<h2 class="section-title">2. Basic HTML Elements</h2>
<p>This is a <strong>paragraph</strong> element. You can make text
<em>italic</em> or <u>underline</u> as needed.</p>
<p>Visit <a href="https://www.w3schools.com" target="_blank">W3Schools</a>
for more information on HTML.</p>
</section>
<section>
<h2 class="section-title">3. Images</h2>
<p>Here’s an example of an image:</p>
<img src="https://www.example.com/sample-image.jpg" alt="Sample Image"
width="300">
</section>
<section>
<h2 class="section-title">4. Unordered List</h2>
<ul>
<li>HTML Basics</li>
<li>CSS Styling</li>
<li>JavaScript Basics</li>
</ul>
</section>
<section>
<h2 class="section-title">5. Table Example</h2>
<table>
<tr>
<th>Name</th>
<th>Age</th>
<th>City</th>
</tr>
<tr>
<td>John Doe</td>
<td>25</td>
<td>New York</td>
</tr>
<tr>
<td>Jane Smith</td>
<td>30</td>
<td>London</td>
</tr>
<tr>
<td>Michael Johnson</td>
<td>35</td>
<td>Paris</td>
</tr>
</table>
</section>
</main>
</body>
</html>
1. Inline CSS
Inline CSS is applied directly within an HTML element using the style attribute.
html
Copy code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Inline CSS Example</title>
</head>
<body>
<h1 style="color: blue; text-align: center;">This is a Heading with Inline CSS</h1>
<p style="font-size: 20px; color: green;">This paragraph has inline styling.</p>
</body>
</html>
2. Internal CSS
Internal CSS is placed within the <style> tag inside the <head> section of the HTML document.
html
Copy code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Internal CSS Example</title>
<style>
body {
background-color: lightgray;
}
h1 {
color: darkblue;
text-align: center;
}
p{
font-size: 18px;
color: darkgreen;
}
</style>
</head>
<body>
<h1>This is a Heading with Internal CSS</h1>
<p>This paragraph has internal CSS styling.</p>
</body>
</html>
3. External CSS
External CSS is defined in a separate .css file, and that file is linked to the HTML document
using the <link> tag in the <head> section.
/* styles.css */
body {
background-color: #f4f4f4;
}
h1 {
color: purple;
text-align: center;
}
p{
font-size: 16px;
color: orange;
}
Link
<html>
<head>
<title>
</title>
<link rln=”stylesheet” type=”text/css”href=”style.css”>
</head>
<body>
</body>
</html>
<h1>Contact Us</h1>
<label for="email">Email:</label>
<input type="email" id="email" name="email" required><br><br>
<label for="message">Message:</label><br>
<textarea id="message" name="message" rows="4" cols="50"
required></textarea><br><br>
<button type="submit">Submit</button>
</form>
</body>
</html>
Explanation of the Code:
<form> tag: The form uses POST as the method to submit the data to the server at the
URL /submit_form.
<label> tag: Each input field has a corresponding label to help users understand what
information is required.
<input type="text">: Two text input fields for the first and last names.
<input type="email">: An input field for the email address that validates the email
format.
<textarea>: A larger text area for the user to write a message.
<input type="checkbox">: A checkbox for subscribing to a newsletter.
<button>: A submit button to send the form data when clicked.
How It Works:
1. The user fills in their information in the form fields.
2. When the "Submit" button is clicked, the form data is sent to the server (in this case, to
/submit form using the POST method).
3. The server processes the data (e.g., storing it in a database, sending an email) and may
provide a response, such as a confirmation message or redirecting the user to another
page.
This basic form structure can be expanded with additional input types and functionality, such as
file uploads, date pickers, or more complex validation.
Form can be modified using css using html div or eatch elements as a target to css or simply by
othr html elemente like table
/* Header */
.form-container h1 {
text-align: center;
margin-bottom: 20px;
font-size: 24px;
color: #333;
}
.form-group label {
display: block;
margin-bottom: 5px;
font-size: 14px;
color: #555;
}
.form-group input,
.form-group select,
.form-group textarea {
width: 100%;
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
font-size: 14px;
box-sizing: border-box;
}
.form-group textarea {
resize: none;
height: 80px;
}
/* Button styling */
.form-group button {
width: 100%;
padding: 10px;
background-color: #007bff;
color: #fff;
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 16px;
}
.form-group button:hover {
background-color: #0056b3;
}
</style>
</head>
<body>
<div class="form-container">
<h1>Contact Us</h1>
<form action="#" method="post">
<!-- Name Field -->
<div class="form-group">
<label for="name">Full Name:</label>
<input type="text" id="name" name="name" placeholder="Enter your full name"
required>
</div>
<!-- Email Field -->
<div class="form-group">
<label for="email">Email Address:</label>
<input type="email" id="email" name="email" placeholder="Enter your email"
required>
</div>
<!-- Subject Field -->
<div class="form-group">
<label for="subject">Subject:</label>
<input type="text" id="subject" name="subject" placeholder="Enter the subject"
required>
</div>
<!-- Message Field -->
<div class="form-group">
<label for="message">Message:</label>
<textarea id="message" name="message" placeholder="Write your message"
required></textarea>
</div>
<! -- Submit Button -->
<div class="form-group">
<button type="submit">Submit</button>
</div>
</form>
</div>
</body>
</html>
Explanation
Responsive Design: The form is centered and scales well on different screen sizes.
Modern Styling: Uses a clean and minimalistic CSS design with box shadows, rounded
corners, and a hover effect on the button.
Semantic Structure: Labels and inputs are properly associated using for and id.
Custom Layout with Divs: All elements are grouped and styled using div for layout control.
Example
using table to create well indented form
</head>
<body>
<form method="post" action="apply-now.php">
<input name="subject" type="hidden" value="Class" />
<fieldset style="width:300px"><legend>Personal Details</legend>
<table>
<tr>
<td><label for="fname">First Name</label></td>
<td><input type="text" name="fname" id="fname" /></td>
</tr>
<tr>
<td><label for="lname">Last Name</label></td>
<td><input type="text" name="lname" id="lname" /></td>
</tr>
<tr>
<td><label for="degree">Degree</label></td>
<td><select name="degree" id="degree">
<option value="BA">cs</option>
<option value="BS">SE</option>
<option value="MBA"
selected="selected">IT</option>
</select></td>
</tr>
<tr>
<td>Student ID</td>
<td><input type="text" name="s" /></td>
</tr>
<tr>
<td><label for="degree">Degree</label></td>
<td><select name="degree" id="degree">
<option value="BA">cs</option>
<option value="BS">SE</option>
<option value="MBA"
selected="selected">IT</option>
</select></td>
</tr>
<tr>
<td>Student ID</td>
<td><input type="text" name="s" /></td>
</tr>
<tr>
<td>Password</td>
<td><input type="Password" placeholder="Enter Password"
name="s" /></td>
</tr>
<tr>
<td>Gender:</td>
<td>
<input name="gender" type="radio" id="gm" value="m" />
<label for="gm">Male</label>
<input name="gender" type="radio" id="gf" value="f" />
<label for="gf">Female</label></td>
</tr>
<tr>
<label for="email">your email </label>
<input type="email" id="email">
</tr>
<td></td>
<td><button type="submit">send</button> <input type="reset" value="clear">
</td>
</tr>
</fieldset>
</form><br><br><br><br>
</body>
</html>