HTML Webpage Design and CSS Techniques
HTML Webpage Design and CSS Techniques
Aim :
To design and develop a structured webpage that demonstrates the use of fundamental and
advanced HTML elements, including headings, paragraphs, lists, tables, forms, multimedia,
hyperlinks, semantic tags, and layout components, in order to understand the structure and
presentation of web content.
Algorithm:
• Plan a layout for your web page.
• Create a HTML page with all necessary elements
• Create Style sheet and add styling to web page
• Link the style sheet and HTML and run in browser.
Program:
[Link]
<html>
<head>
<Title>HOME PAGE</title>
</head>
<frame src="[Link]"name="right"/>
</frameset>
</html>
[Link]
<html>
<head>
</head>
<center>
</center>
<br/><br/>
<br/>
<center>
</center>
</body>
</html>
[Link]
html>
<head>
</head>
<center>
established in the year 2011, with 6 UG courses (B.E. – CSE, ECE, EEE & Mech. Engg.,
[Link]. IT & [Link] Artificial Intelligence and Data Science is offered from the year 2021.
MBA is offered from the year 2022.
The courses offered from the inception (B.E. – CSE, ECE & Mech. Engg. & [Link]. IT) have
been accredited by NBA in 2017 in the shortest span of 6 years since inception,
and granted Autonomous status by UGC in 2022 which ascertains our quality.
</div></div><div id="bottom">
</div>
</body>
</html>
[Link]
<html>
<head>
</head>
<center>
<center>
<div id="right"><br><br><br/>
<div id="wrap">
<div id="top">
To set a standard in education by developing the intellectual strength of students and guiding
them to have a sound and
</div></div><div id="bottom">
</div>
</center>
</body>
</html>
[Link]
<html>
<head>
</head>
<body>
<center>
<table>
</tr>
<table>
</tr>
<table>
</tr>
<table>
</tr>
<table>
</tr>
</tr>
</table>
</form>
</center>
</body>
</html>
[Link]
<html>
<head>
</head>
<body>
<center>
<br/><br/><br/><br/>
</center><br/><br/><br/><br/>
<br/><br/><br/><br/>
<table>
<tr>
</tr>
<tr>
</tr>
</table>
</body>
</html>
Output :
Result:
The webpage was successfully designed and implemented using various HTML elements.
[Link] : 2 Create a Web Page with all types of Cascading Style Sheets and CSS Selectors
Aim :
To create a fully styled web page that demonstrates the use of all three methods of applying
Cascading Style Sheets (inline, internal, and external) and showcases a comprehensive set of CSS
selectors .
Algorithm:
• Plan a layout for your Web page by applying all type of CSS and CSS selectors.
• Create a HTML page with all necessary elements
• Create Style sheet and add styling to web page
Program
[Link]
<html> <head>
<style type="text/css">
p{
background-color:pink;
text-align:justify;
margin:2 em 7em;
</style> </head>
<body id="body">
takes you anywhere on the internet, letting you see text, images and video from anywhere in the
world. Common used Web browsers are
<div class="div">
<ul>
[Link]
h1,h2 {
text-decoration: Underline;
font-style: italic;
text-aligh:center;}
#body{
background-color:tan;
border: red dotted;
text-align:center;
}
.div
{ border:peru solid; }
*{ letter-spacing: 1px; }
a:link
{ color:black; }
a:visited
{ color:yellow; }
a:hover
{color: green; }
a:active
{ colot:blue; }
ul li
{ font-size:small;}
Output:
Result:
The webpage was successfully designed and implemented using CSS and Selectors.
[Link]: 3 Write an HTML page that contains a selection box with a list of 5 countries.
When the user selects a country, its capital should be printed next in the list. Add CSS
to customize the properties of the font of the capital (color, bold and font size).
Aim:
To develop an interactive HTML page featuring a dropdown list of five countries that, upon
selection, dynamically displays the corresponding capital city immediately beside the list, with
the capital’s name styled using CSS to be bold, colored, and sized appropriately, thereby
demonstrating basic DOM manipulation and CSS styling techniques.
Algorithm:
• Create a HTML page with all necessary elements
Program:
<html>
<head>
<title>Capitals of countries</title>
<center>
<h1> Select the Country Name to find its Captial </h1> </center>
<body bgcolor="violet">
<style>
p{
color:red;
font-weight:bold;
font-size:50;
}
</style>
<script language="javascript">
function capital()
{
var cunt=[Link]["frm1"].[Link];
var capital=" Select a country ";
if( cunt=="india")
{ capital="NEW DELHI"; }
if( cunt=="china")
capital="BEIJING";
if( cunt=="pakistan")
{ capital="ISLAMABAD"; }
if( cunt=="bangladesh")
{ capital="DHAKA"; }
if( cunt=="japan")
{ capital="TOKYO"; }
if( cunt=="select")
capital="Select a country";
[Link]("capt").innerHTML=capital;
</script> </head>
<body>
<form name="frm1">
<br/> <center>
<font color="gray" size="6">
<option value="india">INDIA</option>
<option value="china">CHINA</option>
<option value="pakistan">PAKISTAN</option>
<option value="bangladesh">BANGLADESH</option>
<option value="japan">JAPAN</option>
</select>
<br/>
<br/>
</center>
</form>
</body>
</html>
Output
Result: Thus, the JavaScript event listener and CSS rules successfully work together to
dynamically update and style the content
[Link] :4 Write client-side scripts for validating web form control using DHTML
Aim :
Algorithm:
• Create a HTML form and set-up CSS
• Add event listeners using Java Script.
• Define and run the validation.
• Verify that correct inputs allow form submission and incorrect ones block it until fixed.
Program:
[Link]
function ValidateEmail(input) {
if ([Link](validRegex)) {
alert("Valid email address!");
[Link]();
return true;
} else {
[Link]
<!DOCTYPE html>
<html lang="en">
<body onload="[Link]()">
<div class="mail">
<ul>
<li> </li>
<li class="validate">
<input
type="submit"
name="validate"
value="Validate"
onclick="ValidateEmail(document.form1.text1)"
/> </li>
<li> </li> </ul>
</form> </div>
<script src="[Link]"></script>
</body> </html>
[Link]
li {
list-style-type: none;
font-size: 16pt;
}
.mail {
margin: auto;
padding-top: 10px;
padding-bottom: 10px;
width:400px;
background:teal;
border: 1px soild silver;
}
.mail h2 {
margin-left: 38px;
color: white;
}
.rq {
color: #ff0000;
font-size: 10pt;
}
OUTPUT:
Result:
Aim: To design and implement a responsive image slider component using HTML, CSS, and
JavaScript that automatically cycles through a series of images, supports manual navigation
controls.
Algorithm :
• Create a responsive image slider component using HTML, CSS and Java Script.
• Activate the cycle through a series of images.
• Design the code to support manual navigation controls.
Program:
[Link]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
</head>
<body>
<div class="container">
<a class="btn btn-left"><i class="fa-solid fa-caret-left"></i></a>
</div>
</body>
</html>
[Link]
let index = 0;
[Link](index);
[Link]((button) => {
[Link]('click', () => {
if ([Link]('btn-left')) {
index--;
if (index < 0) { \
index = [Link] - 1;
} else {
index++;
});
});
// Usage example:
body{
margin:0;
padding:0;
box-sizing: border-box;
background-color: salmon;
.container{
min-height: 80vh;
width:60%;
border-radius: 5px;
box-shadow: 10px 10px 35px rgba(0,0,0,0.6);
position:relative;
background: url("img/[Link]") center/cover fixed no-repeat;
transition:background 1s ease-in-out;
.btn-left{
position:absolute;
top:50%;
left:-2%;
background-color: white;
padding:.4em .6em;
border-radius: 2em;
transform:translateY(calc(-50%));
cursor: pointer;
.btn-right{
position:absolute;
top:50%;
right:-2%;
background-color: white;
padding:.4em .6em;
border-radius: 2em;
transform:translateY(calc(-50%));
cursor: pointer; }
Output
b. Design a Digital Clock
Aim : To create an interactive HTML page named [Link] that displays a real-time digital
clock using JavaScript and DHTML, updating every second to reflect the user’s local time and
styled with CSS for clear, visually appealing typography and layout.
Algorithm :
• Create an interactive HTML page to display real-time digital Clock using JavaScript and
DHTML .
• Update the seconds to reflect the user’s local time using CSS.
[Link]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Digital Clock</title>
</head>
<body>
<div id="clock">8:10:45</div>
<script src="[Link]"></script>
</body> </html>
[Link]
#clock {
font-size: 175px;
width: 900px;
margin: 200px;
text-align: center;
border: 2px solid black;
border-radius: 20px;
}
[Link]
function showTime() {
// Getting current time and date
let time = new Date();
min = min < 10 ? "0" + min : min;sec = sec < 10 ? "0" + sec : sec;
let currentTime =
hour +
":" +
min +
":" +
sec +
am_pm;
"clock"
).innerHTML = currentTime;
showTime()
Output :
Result: Thus, the design of HTML page using java script and DHTML was successfully
executed.
Ex: 6 Design a shopping cart application using React. You Shopping webpage a should
have the provisions for selecting the list of items from different category. Once the items
are selected on clicking the submit button the items in the cart with its price should be
displayed.
Aim :
Design a shopping cart application using React. Shopping webpage a should have the
provisions for selecting the list of items from different category. Once the items are selected
on clicking the submit button the items in the cart with its price should be displayed.
Algorithm :
• Plan the layout to design shopping cart application using React.
• .Design the shopping cart webpage such that it should have provisions for selecting
the list of items from different category.
• Activate the items by clicking submit button.
Program.
import React, { useState } from 'react';
const items = [
{ id: 1, name: 'Apple', price: 10 },
{ id: 2, name: 'Banana', price: 5 },
{ id: 3, name: 'Orange' , price:20 },
{ id: 4, name: 'Papaya' , price:15}
];
function App() {
const [cart, setCart] = useState([]);
const [totalPrice, setTotalPrice] = useState(0);
const handleAddToCart = (item) => setCart([...cart, item]);
const handleSubmit = () => {
const total = [Link]((sum, item) => sum + [Link], 0);
setTotalPrice(total);
};
return (
<div>
<h2>Shopping Cart</h2>
{[Link](item => (
<div key={[Link]}> {[Link]} - ${[Link]}
<button onClick={() => handleAddToCart(item)}>Add to Cart</button>
</div>
))}
<h3>Cart:</h3>
{[Link]((item, index) => (
<div key={index}>{[Link]} - ${[Link]}</div>
))}
<button onClick={handleSubmit}>Submit</button>
{totalPrice > 0 && <h3>Total Price: ${totalPrice}</h3>}
</div>
);
}
export default App;
Output:
Result:
Thus, the React shopping cart application was successfully implemented.
Ex: 7 Design an Online super market using ExpressJs and MongoDB database a) Perform
a search based on product id or name b) On retrieving the results , display the product
details of different brands in table format with the price field in stored order using React.
Aim :
To develop a full-stack online supermarket application using [Link] and MongoDB that
allows users to search for products by ID or name, retrieves matching items across different
brands from the database, and presents the results in a React-powered table sorted by price,
thereby demonstrating end-to-end data retrieval, API design, and dynamic front-end rendering.
Algorithm :
• Create a responsive image slider component using HTML, CSS and Java Script.
• Activate the cycle through a series of images.
• Design the code to support manual navigation controls.
Express code
const express = require('express');
const mongoose = require('mongoose');
const cors = require('cors'); // Import cors
// Connect to MongoDB
[Link]('mongodb://localhost:27017/online_supermarket', {
useNewUrlParser: true,
useUnifiedTopology: true
})
.then(() => [Link]('MongoDB connected'))
.catch(err => [Link](err));
// API endpoints
[Link]('/products', async (req, res) => {
try {
const products = await [Link]();
[Link](products);
} catch (err) {
[Link](500).json({ message: [Link] });
}
});
React Code:
function App() {
const [products, setProducts] = useState([]);
const [filteredProducts, setFilteredProducts] = useState([]);
const [searchTerm, setSearchTerm] = useState('');
const [error, setError] = useState(null);
useEffect(() => {
const fetchProducts = async () => {
try {
const response = await [Link]('[Link]
[Link]('Products data:', [Link]);
setProducts([Link]);
setFilteredProducts([Link]); } catch (error) {
[Link]("There was an error fetching the products!", error);
setError("Failed to fetch products.");
}
};
fetchProducts();
}, []);
useEffect(() => {
// Filter and sort products whenever searchTerm changes
const filtered = [Link](product =>
[Link]().includes([Link]()) ||
[Link]().includes(searchTerm)
);
setFilteredProducts(sorted);
}, [searchTerm, products]);
return (
<div className="app-container">
<h1>Online Supermarket</h1>
{error && <p className="error">{error}</p>}
<input
type="text"
placeholder="Search by product ID or name"
value={searchTerm}
onChange={(e) => setSearchTerm([Link])}
className="search-bar"
/>
{[Link](productsByBrand).length > 0 ? (
[Link](productsByBrand).map(brand => (
<div key={brand} className="brand-section">
<h2 className="brand-name">{brand}</h2>
<table className="product-table">
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Price</th>
</tr>
</thead>
<tbody>
{productsByBrand[brand].map(product => (
<tr key={product._id}>
<td>{[Link]}</td>
<td>{[Link]}</td>
<td>${[Link](2)}</td>
</tr>
))}
</tbody>
</table>
</div>
))
):(
<p>No products found</p>
)}
</div>
);
}
{
"_id": "ObjectId",
"id": "Number",
"name": "String",
"brand": "String",
"price": "Number"
}
OUTPUT:
Result:
Thus, the application meets the aim by delivering a seamless, end-to-end search experience for
an online supermarket, demonstrating integration of [Link], MongoDB, and React for real-
time data querying and display.
Ex: 8. Create a <TodoItem> component in React and reuse it inside a <TodoList>
component.
Aim :
To develop a reusable <TodoItem> React component that encapsulates the display and
behavior of a single to-do task, and integrate it within a <TodoList> component to dynamically
render and manage a list of tasks, demonstrating component composition, props passing, and
React’s declarative rendering.
Algorithm:
Program:
React Code:
[Link]:
// src/components/[Link]
import React, { useState } from 'react';
import TodoItem from '../components/[Link]';
function TodoList() {
const [todos, setTodos] = useState([
{ id: 1, text: 'Learn React', completed: false },
{ id: 2, text: 'Build a to-do app', completed: false },
{ id: 3, text: 'Master JavaScript', completed: false },
]);
[Link]:
import React from 'react';
import '../src/[Link]'
import TodoList from './components/TodoList';
function App() {
return (
<div className="app-container">
<h1 className="app-title">My To-Do List</h1>
<TodoList />
</div>
);
}
export default App;
Project Structure:
Output:
Result:
Thus, the implementation meets the aim by delivering a clean, interactive to-do list interface
powered by reusable React components and unidirectional data flow.
Ex: 10 Create a basic CRUD operation API by following API following REST syntax for
a given model student with the following fields [ field names].
Aim:
To design and implement a RESTful API that performs basic Create, Read, Update, and Delete
(CRUD) operations on a Student model.
Code:
Set Up Your API in Postman
1. Open Postman and create a new request collection for your Student API to keep
everything organized.
2. Ensure your server is running (i.e., node [Link] or npx nodemon [Link]).
3. Use the base URL for your requests: [Link]
2. CRUD Operations Using Postman
1. Create a Student (POST Request)
• Endpoint: POST [Link]
• Headers:
o Content-Type: application/json
• Body: Select "raw" and set the type to JSON. Use the following JSON structure
{
"name": "John Doe",
"age": 21,
"email": "johndoe@[Link]",
"grade": "A"
}
• Send the request: You should receive a response with the newly created student object
and a 201 Created status.
2. Get All Students (GET Request)
• Endpoint: GET [Link]
• Headers: None required.
• Send the request: This will return an array of all students currently in the database.
3. Get a Single Student by ID (GET Request)
• Endpoint: GET [Link]
• Example: Replace :id with the actual ID of a student (you can get this from the list of
students you retrieved in the previous step).
o E.g., GET [Link]
• Send the request: This will return the details of the specified student.
4. Update a Student (PUT Request)
• Endpoint: PUT [Link]
• Headers:
o Content-Type: application/json
• Body: Use JSON format to specify the fields you want to update
{
"name": "Jane Doe",
"age": 22,
"email": "janedoe@[Link]",
"grade": "B"
}
• Send the request: You should receive a response with the updated student data.
5. Delete a Student (DELETE Request)
• Endpoint: DELETE [Link]
• Example: Replace :id with the ID of the student you want to delete.
o E.g., DELETE [Link]
• Send the request: You should receive a confirmation message that the student has been
deleted.
POST (Create):
json
{
"_id": "64f9082399995d0f1a7c8abc",
"name": "John Doe",
"age": 21,
"email": "johndoe@[Link]",
"grade": "A",
"__v": 0
}
json
{
"_id": "64f9082399995d0f1a7c8abc",
"name": "John Doe",
"age": 21,
"email": "johndoe@[Link]",
"grade": "A",
"__v": 0
}
json
{
"_id": "64f9082399995d0f1a7c8abc",
"name": "John Doe",
"age": 21,
"email": "johndoe@[Link]",
"grade": "A",
"__v": 0
}
PUT (Update):
json
{
"_id": "64f9082399995d0f1a7c8abc",
"name": "Jane Doe",
"age": 22,
"email": "janedoe@[Link]",
"grade": "B",
"__v": 0
}
DELETE (Remove):
json
{
"message": "Student deleted successfully"
}
Result:
Thus, the design of RESTful API was implemented successfully.
Ex no:10 To build an AJAX Application
Aim:
To develop a web application using Asynchronous JavaScript and XML (AJAX) techniques
that retrieves data from a server endpoint without reloading the page, dynamically updates the
DOM with the fetched data, and handles loading states and errors to provide a seamless user
experience.
Algorithm
• Design the project structure
• Build the HTML Skeleton and Style the Page
• Implement Ajax Logic , wait for the DOM to load and select your element.
• Set the server Endpoint and test the application
[Link]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>AJAX User Data</title>
<style>
body {
font-family: Arial, sans-serif;
}
#userData {
margin-top: 20px;
}
</style>
</head>
<body>
<h1>Get User Data</h1>
<button onclick="fetchUserData()">Get Data</button>
<div id="userData"></div>
<script>
function fetchUserData() {
const xhr = new XMLHttpRequest();
[Link]('GET', '[Link]', true);
[Link] = function () {
if ([Link] === 200) {
const user = [Link]([Link]);
[Link]('userData').innerHTML = `
<p><strong>Name:</strong> ${[Link]}</p>
<p><strong>Email:</strong> ${[Link]}</p>
<p><strong>Age:</strong> ${[Link]}</p>
`;
} else {
[Link]('userData').innerHTML = 'Error fetching data.';
}
};
[Link]();
}
</script>
</body>
</html>
[Link]
{
"name": "basker",
"email": "basker@[Link]",
"age": 30
}
Output
Result
Thus, the AJAX application successfully fetched data from the server without reloading the page when
the Load Data button was clicked.