Web Tech Aman Sinha
Web Tech Aman Sinha
To create a simple static home page for an online book store using basic HTML elements.
Tools Required:
Steps to Follow:
Create a folder named OnlineBookStore on your computer. Inside this folder, create an
HTML file named index.html.
2. HTML Structure:
Begin by creating the basic structure of the HTML file. This includes the DOCTYPE
declaration, HTML, head, and body tags.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Online Book Store</title>
</head>
<body>
</body>
</html>
In the header, include the name of the bookstore, a simple navigation bar, and a logo
placeholder.
<header>
<h1>Welcome to the Online Book Store</h1>
<nav>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">Books</a></li>
<li><a href="#">Categories</a></li>
<li><a href="#">Contact Us</a></li>
</ul>
</nav>
</header>
<hr>
4. Main Content:
In the main content section, create a welcome message, a featured books section, and
categories of books.
<main>
<section id="welcome">
<h2>Discover Your Next Favorite Book</h2>
<p>Browse through our wide collection of books across different
genres.</p>
</section>
<section id="featured-books">
<h3>Featured Books</h3>
<ul>
<li>The Great Gatsby</li>
<li>1984 by George Orwell</li>
<li>To Kill a Mockingbird</li>
<li>The Catcher in the Rye</li>
</ul>
</section>
<section id="categories">
<h3>Book Categories</h3>
<ul>
<li>Fiction</li>
<li>Non-Fiction</li>
<li>Science Fiction</li>
<li>Fantasy</li>
<li>Biographies</li>
<li>Children's Books</li>
</ul>
</section>
</main>
5. Footer Section:
Create a footer section with some basic details such as copyright, social media links, and
contact info.
<hr>
<footer>
<p>© 2024 Online Book Store. All Rights Reserved.</p>
<p>Follow us on:
<a href="#">Facebook</a> |
<a href="#">Twitter</a> |
<a href="#">Instagram</a>
</p>
<p>Email us at: [email protected]</p>
</footer>
<section id="featured-books">
<h3>Featured Books</h3>
<ul>
<li>The Great Gatsby</li>
<li>1984 by George Orwell</li>
<li>To Kill a Mockingbird</li>
<li>The Catcher in the Rye</li>
</ul>
</section>
<section id="categories">
<h3>Book Categories</h3>
<ul>
<li>Fiction</li>
<li>Non-Fiction</li>
<li>Science Fiction</li>
<li>Fantasy</li>
<li>Biographies</li>
<li>Children's Books</li>
</ul>
</section>
</main>
<hr>
<footer>
<p>© 2024 Online Book Store. All Rights Reserved.</p>
<p>Follow us on:
<a href="#">Facebook</a> |
<a href="#">Twitter</a> |
<a href="#">Instagram</a>
</p>
<p>Email us at: [email protected]</p>
</footer>
</body>
</html>
Output:
This static page will display a simple homepage for an online book store, featuring the
bookstore's name, navigation links, featured books, book categories, and a footer with
social media links and contact details.
Practical Conclusion:
This exercise demonstrates how to create a simple static homepage for an online book store
using only HTML. This is a good starting point for building more complex web pages with
the addition of CSS and JavaScript for enhanced interactivity and design.
Practical : 2
Practical: Simple Calculator Using JavaScript for Basic
Operations (Sum, Product, Difference, and Quotient)
Objective:
To design a simple calculator using JavaScript that performs the following operations: sum,
product, difference, and quotient.
Tools Required:
Steps to Follow:
Create a folder named SimpleCalculator. Inside this folder, create an HTML file named
calculator.html.
2. HTML Structure:
Create a simple HTML page that contains input fields for numbers, buttons for each
operation, and a display area for the result.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Simple Calculator</title>
<style>
body {
font-family: Arial, sans-serif;
text-align: center;
margin-top: 50px;
}
input {
padding: 5px;
font-size: 16px;
}
button {
padding: 10px 20px;
font-size: 16px;
margin: 10px;
}
#result {
font-size: 18px;
margin-top: 20px;
}
</style>
</head>
<body>
<h1>Simple Calculator</h1>
<button onclick="calculate('add')">Sum</button>
<button onclick="calculate('subtract')">Difference</button>
<button onclick="calculate('multiply')">Product</button>
<button onclick="calculate('divide')">Quotient</button>
<div id="result"></div>
<script src="script.js"></script>
</body>
</html>
Create a file named script.js in the same folder. This script will contain the logic for
performing the four operations: sum, product, difference, and quotient.
calculator.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Simple Calculator</title>
<style>
body {
font-family: Arial, sans-serif;
text-align: center;
margin-top: 50px;
}
input {
padding: 5px;
font-size: 16px;
}
button {
padding: 10px 20px;
font-size: 16px;
margin: 10px;
}
#result {
font-size: 18px;
margin-top: 20px;
}
</style>
</head>
<body>
<h1>Simple Calculator</h1>
<button onclick="calculate('add')">Sum</button>
<button onclick="calculate('subtract')">Difference</button>
<button onclick="calculate('multiply')">Product</button>
<button onclick="calculate('divide')">Quotient</button>
<div id="result"></div>
<script src="script.js"></script>
</body>
</html>
script.js:
javascript
Copy code
// Function to perform the calculation
function calculate(operation) {
// Get the values of the input fields
var num1 = parseFloat(document.getElementById("num1").value);
var num2 = parseFloat(document.getElementById("num2").value);
var result;
Output:
When the user enters two numbers and clicks a button for one of the operations (Sum,
Difference, Product, or Quotient), the result will be displayed on the screen.
Practical Conclusion:
This practical demonstrates how to design a simple calculator using JavaScript to perform
basic arithmetic operations (addition, subtraction, multiplication, and division). The
calculator validates inputs, checks for special conditions like division by zero, and displays
the result in real-time.
Practical : 3
Practical: PHP Program to Display a Digital Clock
Showing the Server's Current Time
Objective:
To write a PHP program that displays the current time of the server in a digital clock format.
Tools Required:
Steps to Follow:
You need to have a local or remote server with PHP installed. You can use tools like XAMPP
or WAMP to set up a local server on your machine.
Create a folder named DigitalClockPHP. Inside this folder, create a PHP file named
clock.php.
To display the server's current time, use the PHP date() function, which can retrieve the
current server time.
In the clock.php file, write the following code. The PHP code will be embedded within
HTML to render the time dynamically.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Digital Clock - Server Time</title>
<style>
body {
font-family: Arial, sans-serif;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
background-color: #333;
color: white;
}
.clock {
font-size: 50px;
padding: 20px;
background-color: #444;
border-radius: 10px;
box-shadow: 0px 0px 15px rgba(0,0,0,0.5);
}
</style>
<script>
// JavaScript to reload the page every second
function refreshTime() {
setTimeout(function () {
window.location.reload(1);
}, 1000);
}
</script>
</head>
<body onload="refreshTime()">
<div class="clock">
<?php
// Display current server time in 'H:i:s' format (hours,
minutes, seconds)
echo date('H:i:s');
?>
</div>
</body>
</html>
HTML Structure:
The HTML structure includes a div with the class clock, where the current server
time will be displayed.
CSS Styling:
The clock is styled with CSS to have a digital appearance. The font-size,
background color, and box-shadow properties are used to make the clock visually
appealing.
PHP Code: The <?php echo date('H:i:s'); ?> tag is used to display the current
server time in the format hours:minutes:seconds.
JavaScript for Auto Refresh: The JavaScript refreshTime() function is used to
reload the page every second so that the clock updates in real-time. It uses the
setTimeout() function to trigger a page refresh every 1000 milliseconds (1 second).
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Digital Clock - Server Time</title>
<style>
body {
font-family: Arial, sans-serif;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
background-color: #333;
color: white;
}
.clock {
font-size: 50px;
padding: 20px;
background-color: #444;
border-radius: 10px;
box-shadow: 0px 0px 15px rgba(0,0,0,0.5);
}
</style>
<script>
function refreshTime() {
setTimeout(function () {
window.location.reload(1);
}, 1000);
}
</script>
</head>
<body onload="refreshTime()">
<div class="clock">
<?php
echo date('H:i:s');
?>
</div>
</body>
</html>
1. Start your local server (using XAMPP, WAMP, or other PHP-supported platforms).
2. Place the DigitalClockPHP folder in the server's htdocs directory.
3. Open your browser and navigate to
http://localhost/DigitalClockPHP/clock.php.
Output:
The page will display a digital clock with the current server time in HH:MM:SS format
(24-hour format).
The clock will automatically update every second due to the JavaScript refresh
mechanism.
Practical Conclusion:
This practical demonstrates how to build a simple digital clock using PHP and JavaScript that
displays the server's current time. The page auto-refreshes every second to ensure the
displayed time is always accurate.
Practical : 4
Practical: Create a CV Using HTML to Display on a Web
Page
Objective:
To write an HTML code that displays your CV (Curriculum Vitae) on a web page with
appropriate sections such as personal information, education, work experience, skills, and
contact details.
Tools Required:
Steps to Follow:
Create a folder named MyCV. Inside this folder, create an HTML file named cv.html.
Begin by creating the basic structure of the HTML file. This includes the DOCTYPE
declaration, HTML, head, and body tags.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>My CV</title>
<style>
body {
line-height: 1.6;
margin: 0;
padding: 0;
background-color: #f4f4f4;
color: #333;
.container {
max-width: 900px;
margin: auto;
padding: 20px;
background-color: white;
h1, h2 {
color: #0056b3;
h2 {
padding-bottom: 5px;
ul {
list-style-type: none;
li {
margin-bottom: 10px;
.contact-info {
background-color: #e6f7ff;
padding: 10px;
border-radius: 5px;
margin-bottom: 20px;
.section {
margin-bottom: 30px;
}
</style>
</head>
<body>
<div class="container">
<header>
<h1>John Doe</h1>
</header>
<section class="contact-info">
<p>Email: [email protected]</p>
<p>Phone: +123-456-7890</p>
</section>
<section class="section">
<h2>Professional Summary</h2>
<p>A highly motivated software developer with over 3 years of experience in web
development. Skilled in HTML, CSS, JavaScript, and backend technologies like PHP and Node.js.
Seeking to leverage technical expertise to grow in a dynamic organization.</p>
</section>
<section class="section">
<h2>Education</h2>
<ul>
</ul>
</section>
<section class="section">
<h2>Work Experience</h2>
<ul>
<ul>
<li>Developed and maintained company websites using HTML, CSS, and JavaScript.</li>
</ul>
</li>
<ul>
</ul>
</li>
</ul>
</section>
<section class="section">
<h2>Skills</h2>
<ul>
</ul>
</section>
<section class="section">
<h2>Projects</h2>
<ul>
<li><strong>Weather App</strong> - Built a weather app using JavaScript and APIs to show
live weather data.</li>
</ul>
</section>
<footer>
</footer>
</div>
</body>
</html>
Header:
This contains the name of the person (John Doe) styled with h1.
Contact Information Section:
The contact information (email, phone number, and address) is placed inside a
section and styled for visibility.
Professional Summary:
A brief summary describing the professional profile of the candidate.
Education Section:
This section lists the educational background, including degrees and institutions, in an
unordered list.
Work Experience Section:
Lists job roles, companies, and responsibilities in another unordered list. Nested lists
are used to describe job duties.
Skills Section:
This section lists relevant technical skills in bullet points.
Projects Section:
Includes a list of projects the person has worked on, along with brief descriptions.
Footer:
The footer contains additional contact details.
4. Output:
When the HTML file (cv.html) is opened in a web browser, the CV will be displayed as a
structured and well-organized web page. The sections will be visually separated, and the
contact details, education, skills, and experience will be clearly visible.
Practical Conclusion:
This practical demonstrates how to create a web page that showcases a CV using basic
HTML and CSS. You can further enhance this CV with advanced styling techniques using
CSS or add interactivity with JavaScript. This is a great exercise for beginners to learn how to
structure content on a web page using semantic HTML elements.
Practical : 5
Practical: Write an XML Program to Display Products
Objective:
To write an XML file that contains information about products (such as product name, price,
description, and category) and demonstrate how the data can be structured using XML.
Tools Required:
Steps to Follow:
Create a folder named ProductCatalog. Inside this folder, create an XML file named
products.xml.
We will create an XML file that holds details about various products, including their name,
price, description, and category.
<products>
<product>
<name>Wireless Mouse</name>
<category>Electronics</category>
<price currency="USD">25.99</price>
</product>
<product>
<name>Coffee Maker</name>
<category>Appliances</category>
<price currency="USD">45.50</price>
</product>
<product>
<name>Notebook</name>
<category>Stationery</category>
<price currency="USD">3.99</price>
</product>
<product>
<name>Bluetooth Speaker</name>
<category>Electronics</category>
<price currency="USD">35.00</price>
</product>
<product>
<name>Running Shoes</name>
<category>Sports</category>
<price currency="USD">79.99</price>
</product>
</products>
3. Explanation of the XML Structure:
XML Declaration:
xml
Copy code
<?xml version="1.0" encoding="UTF-8"?>
This line specifies that the XML version is 1.0 and that it uses UTF-8 character
encoding.
Root Element: The root element of this XML document is <products>, which
contains all the product entries.
Product Element: Each individual product is represented by a <product> element.
Inside each product element, we have:
o <name>: The name of the product.
o <category>: The category or type of the product.
o <price>: The price of the product, including an attribute currency to specify the
currency type.
o <description>: A brief description of the product.
XML can be viewed in a web browser or in any XML viewer, but it is most commonly used
as a data format. In practical applications, XML data can be parsed and processed using
programming languages such as JavaScript, PHP, Python, etc.
If you want to display the XML data in a web-friendly format, you can use XSLT (Extensible
Stylesheet Language Transformations) to transform XML into HTML.
To apply this XSLT, include a reference to the XSL file in the products.xml file like this:
5. Output:
When the XML file is opened in a web browser (with the XSLT file included), it will display
the product data in a neatly formatted table.
Practical Conclusion:
This practical demonstrates how to create an XML document to structure product data and,
optionally, display it on a web page using XSLT. XML is commonly used for data storage
and sharing in web applications, making it an essential tool for developers working with
structured data.
Practical : 6
Practical: Create a Web Page with All Types of Cascading
Style Sheets (CSS)
Objective:
To create a web page that demonstrates the three types of CSS: Inline CSS, Internal
(Embedded) CSS, and External CSS.
Tools Required:
Steps to Follow:
The HTML page will include examples of all three types of CSS: Inline, Internal, and
External.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>CSS Types Demonstration</title>
</body>
</html>
section {
margin: 20px;
padding: 20px;
border-radius: 5px;
}
h2 {
color: #00796b;
}
p {
font-size: 18px;
color: #333;
}
header h1 {
font-size: 36px;
}
External CSS:
In the HTML <head> section, the <link> tag is used to include the external stylesheet
(styles.css). This is applied to style elements globally.
html
Copy code
<link rel="stylesheet" href="styles.css">
<style>
body {
font-family: Arial, sans-serif;
}
/* Other internal CSS rules */
</style>
Inline CSS:
Inline CSS is applied directly to individual HTML elements using the style attribute
within the element tag itself. This is typically used for quick styling, but it's not
recommended for large projects.
html
Copy code
<p style="color: blue; font-size: 20px; font-weight: bold;">This
paragraph is styled using inline CSS.</p>
CSSDemo/
├── index.html # HTML file with inline and internal CSS
├── styles.css # External CSS file
6. Output:
The external CSS will apply styles such as background color and text styling globally.
The internal CSS will style the specific section (like the color of headings and the
design of one specific section).
Inline CSS will directly apply styles (like font size, weight, and color) to individual
elements within the body of the HTML.
Practical Conclusion:
This practical demonstrates how to create a web page using all three types of CSS: External,
Internal (Embedded), and Inline. It shows how each type is implemented and the effects they
have on the presentation of an HTML page. For better maintainability and scalability,
external CSS is preferred, while inline CSS is used sparingly.
Practical : 7
Practical: Write a JavaScript to Calculate Squares and
Cubes of Numbers from 0 to 10 and Display in an HTML
Table
Objective:
To write a JavaScript program that calculates the squares and cubes of numbers from 0 to 10,
and displays the results in an HTML table.
Tools Required:
Steps to Follow:
Create a folder named SquaresAndCubes. Inside this folder, create an HTML file named
index.html.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Squares and Cubes Table</title>
<style>
body {
font-family: Arial, sans-serif;
text-align: center;
background-color: #f0f0f0;
margin: 0;
padding: 0;
}
table {
margin: 20px auto;
border-collapse: collapse;
width: 50%;
background-color: #fff;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
th, td {
border: 1px solid #ddd;
padding: 10px;
text-align: center;
}
th {
background-color: #4CAF50;
color: white;
}
tr:nth-child(even) {
background-color: #f2f2f2;
}
</style>
</head>
<body>
<table id="resultTable">
<tr>
<th>Number</th>
<th>Square</th>
<th>Cube</th>
</tr>
</table>
<script>
// JavaScript to calculate squares and cubes and insert into the
HTML table
const table = document.getElementById('resultTable');
// Create table data cells for the number, its square, and its
cube
const numberCell = document.createElement('td');
numberCell.textContent = num;
</body>
</html>
HTML Structure:
o The table is created using standard HTML <table>, <tr>, <th>, and <td>
tags. Initially, only the table header row is present in the HTML (Number,
Square, and Cube).
CSS Styling:
o The table is styled to be centered, with alternating row colors for readability. It
uses border-collapse for clean borders, and box-shadow for subtle depth.
JavaScript Logic:
o The JavaScript function runs a for loop from 0 to 10, calculating the square
and cube for each number.
o For each iteration of the loop:
A new row (<tr>) is created.
Three cells (<td>) are created for the number, its square, and its cube.
The cells are appended to the row, and the row is appended to the
table.
o The final table dynamically shows numbers 0 to 10, their squares, and cubes.
4. Final Output:
When the index.html file is opened in a browser, the web page will display a table with
three columns:
5. Expected Output:
6. Explanation of Logic:
This practical demonstrates how to use JavaScript to calculate squares and cubes of numbers,
and dynamically generate an HTML table to display the results. It also integrates basic
HTML, CSS, and JavaScript to enhance understanding of dynamic table generation on the
web.
Practical: 8
Practical: PHP Program to Display a Digital Clock
Showing the Current Server Time
Objective:
To write a PHP program that displays the current server time in the form of a digital clock
that updates every second.
Tools Required:
Steps to Follow:
Ensure you have a local server installed (such as XAMPP, WAMP, or MAMP). For XAMPP
users:
Create a folder named DigitalClockPHP in the htdocs directory. Inside this folder, create a
PHP file named clock.php.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Digital Clock</title>
<style>
body {
background-color: #f0f0f0;
margin: 0;
padding: 0;
.clock-container {
margin-top: 20%;
.clock {
font-size: 60px;
font-weight: bold;
background-color: #333;
color: white;
display: inline-block;
padding: 20px;
border-radius: 10px;
</style>
</head>
<body>
<div class="clock-container">
<?php
echo date("h:i:s A"); // Display the initial server time in 'Hour:Minute:Second AM/PM'
format
?>
</div>
</div>
<script>
function updateClock() {
xhr.onreadystatechange = function() {
document.getElementById('clock').innerHTML = xhr.responseText;
xhr.send();
</script>
</body>
</html>
In the same folder (DigitalClockPHP), create a new file named time.php to dynamically
update the time.
<?php
echo date("h:i:s A"); // Output the current time in 'Hour:Minute:Second AM/PM' format
?>
http://localhost/DigitalClockPHP/clock.php
3. See the Output: The current server time will be displayed in the form of a digital
clock, and it will automatically update every second.
7. Output Example:
Practical Conclusion:
This practical demonstrates how to use PHP to display a digital clock that shows the current
server time. By integrating PHP and JavaScript (with AJAX), the time updates every second
without reloading the entire page, providing a real-time clock functionality. This exercise
showcases the combination of server-side and client-side technologies for dynamic content
rendering.