Internet and Web Programming Lab
Internet and Web Programming Lab
Teaching
End Semester
Scheme Continuous Internal Assessment (CIA) Total
Examination
(Hrs. /Week)
L T P C CIA-1 CIA-2 CIA-3
CIA- Lab Theory Lab
4
0 0 4 2 -- -- -- -- 25 0 25 50
Max. Time, End Semester Exam (Theory) -00 Hrs. End Semester Exam (Lab) – 03 Hrs.
Prerequisites:
C C++, Basics of Computer Networks and Data Communications
Objectives:
Students are able to:-
1 Gain comprehensive knowledge of HTML, CSS, and JavaScript, and their role in creating
dynamic, responsive web pages.
2 Learn server-side scripting languages like PHP or Node.js, focusing on building robust,
secure back-end functionality for web applications.
3 Master the integration of databases using SQL with web applications, emphasizing data
retrieval, manipulation, and storage techniques.
4 Explore the development and consumption of Web APIs, understanding RESTful services,
and the role of JSON/XML in data interchange.
5 Develop the skills to create full-stack web applications, combining front-end and back-end
technologies to build complete, functional web solutions.
One experiment from the regular practical syllabus will be conducted. (Total 15 Marks).
Complete laboratory journal/records (05 Marks).
Viva-voce (05 Marks).
<html>
<head>
</head>
<body>
<h2>Headings</h2>
<h3>Subheading</h3>
<h2>Emphasis</h2>
<h2>Other Formatting</h2>
<p>This is <code>code</code>.</p>
<p>This is <kbd>keyboard input</kbd>.</p>
</body>
</html>
Explanation of Tags:
2. Design a web page with links to different pages and allow navigation between pages.
<!DOCTYPE html>
<html>
<head>
<title>Navigation Demo</title>
</head>
<body>
<h1>Navigation Demo</h1>
<nav>
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="about.html">About</a></li>
<li><a href="contact.html">Contact</a></li>
</ul>
</nav>
</body>
</html>
Explanation:
<nav> element: This semantic tag is used to define a navigation section on your web page.
<ul> element: An unordered list is used to contain the navigation links.
<li> elements: Each list item represents a single navigation link.
<a> elements: The anchor tags create the actual links.
href attribute: Specifies the destination URL for the link. You'll need to create the
about.html and contact.html files to make these links functional.
Text content: The visible text of the link.
Key points:
File structure: Make sure you have the index.html, about.html, and contact.html files in
the same directory for the navigation to work correctly.
Relative paths: In this example, we're using relative paths for the href attribute, assuming
all the files are in the same folder. If you have a more complex directory structure, you might
need to adjust the paths accordingly.
Styling: You can use CSS to style the navigation bar and links to match your website's
design.
Active link: You can use JavaScript or CSS to highlight the currently active link,
providing visual feedback to the user.
Experiments 3:
<map name="map">
<area shape="rect" coords="0,0,100,100" href="location1.html" alt="Location 1">
<area shape="circle" coords="200,200,50" href="location2.html" alt="Location 2">
<area shape="poly" coords="300,0,350,50,250,100" href="location3.html"
alt="Location 3">
</map>
</body>
</html>
Explanation:
<img> element:
src: Specifies the image file to be used (replace map.jpg with your actual image).
alt: Provides alternative text for screen readers or if the image fails to load.
usemap: Links the image to the map defined below using the #map identifier.
<map> element:
name: Must match the value used in the usemap attribute of the <img> tag.
Contains <area> elements defining the clickable regions on the image.
<area> elements:
shape: Specifies the shape of the clickable area (rect, circle, poly).
coords: Defines the coordinates for the shape:
rect: x1, y1, x2, y2 (top-left and bottom-right corners)
circle: center_x, center_y, radius
poly: x1, y1, x2, y2, ... (vertices of the polygon)
href: Specifies the destination URL for the link when that area is clicked.
alt: Provides alternative text for the area, similar to the <img> tag's alt attribute.
Key points:
Image preparation: You'll need an image file (map.jpg in this example) to use with the
image map.
Coordinate accuracy: Make sure the coordinates in the <area> elements accurately define
the clickable regions on your image. You might need to use an image editor or online tool
to get the exact coordinates.
Fallback links: Consider providing regular text links below the image map for users who
have JavaScript disabled or are using assistive technologies that might not fully support
image maps.
Accessibility: Ensure the alt attributes for the <img> and <area> elements provide
meaningful descriptions for users who cannot see the image.
Experiments 4:
4. Design a web page with different tables. Design a webpage using table so that the
content appears well placed.
<!DOCTYPE html>
<html>
<head>
<title>Table Layout Demo</title>
<style>
table {
width: 100%;
border-collapse: collapse;
}
th, td {
border: 1px solid black;
padding: 8px;
text-align: left;
}
th {
background-color: #f2f2f2;
}
</style>
</head>
<body>
<table>
<tr>
<th>Name</th>
<th>Age</th>
<th>City</th>
</tr>
<tr>
<td>John Doe</td>
<td>30</td>
<td>New York</td>
</tr>
<tr>
<td>Jane Smith</td>
<td>25</td>
<td>London</td>
</tr>
</table>
<h2>Nested Table</h2>
<table>
<tr>
<th>Product</th>
<th>Description</th>
<th>Price</th>
</tr>
<tr>
<td>Laptop</td>
<td>
<table>
<tr>
<td>Brand:</td>
<td>XYZ</td>
</tr>
<tr>
<td>Model:</td>
<td>ABC</td>
</tr>
</table>
</td>
<td>$999</td>
</tr>
</table>
</body>
</html>
Explanation:
Basic table:
<table>: Defines the table structure.
<tr>: Represents a table row.
<th>: Defines a table header cell.
<td>: Defines a table data cell.
Nested table:
A table is embedded within a <td> cell of the outer table to create a more complex
layout.
CSS styling:
width: 100%: Makes the table take up the full width of its container.
border-collapse: collapse;: Collapses the borders of adjacent cells into a single border.
border: 1px solid black;: Adds a 1-pixel black border to all cells.
padding: 8px;: Adds padding around the content of each cell.
text-align: left;: Aligns the text within each cell to the left.
th { background-color: #f2f2f2; }: Sets a light gray background color for header cells.
Key points:
Semantic structure: Use tables for tabular data, not for general layout purposes. Consider
using CSS Grid or Flexbox for more flexible and accessible layouts.
Accessibility: Provide appropriate <caption>, <thead>, <tbody>, and <tfoot> elements to
enhance accessibility for screen reader users.
Responsiveness: Use CSS media queries to adjust the table layout for different screen
sizes.
Experiments 5:
<frameset> element:
Replaces the <body> tag in a frames-based layout.
cols: Specifies the column widths using percentages or fixed pixel values. In this
example:
First column: 25% of the browser width
Second column: Takes up the remaining space (*)
Third column: 25% of the browser width
<frame> elements:
Define the individual frames within the frameset.
src: Specifies the HTML file to be displayed in the frame. You'll need to create
left.html, main.html, and right.html files to make this work.
name (optional): Gives the frame a name so you can target it with links from other
frames.
Key points:
File structure: Make sure you have the left.html, main.html, and right.html files in the
same directory as this main HTML file.
Linking between frames:
To create a link in one frame that targets another frame, use the target attribute in the
<a> tag:
HTML
Important considerations:
Accessibility: Frames can create significant accessibility challenges for users with screen
readers or other assistive technologies. It's generally recommended to avoid frames
whenever possible.
SEO: Search engines might have difficulty indexing content within frames, potentially
impacting your website's visibility.
Usability: Frames can lead to a confusing user experience, especially on smaller screens
or mobile devices.
Alternatives to frames:
CSS layout techniques: Use CSS Grid or Flexbox to create complex layouts without
relying on frames.
IFrames: Consider using <iframe> elements to embed external content within your page,
but be mindful of their potential impact on performance and accessibility.
Experiments 6:
6. Design a web page with a form that uses all types of controls.
<!DOCTYPE html>
<html>
<head>
<title>Form Controls Demo</title>
</head>
<body>
<form>
<fieldset>
<legend>Personal Information</legend>
<label for="name">Name:</label>
<input type="text" id="name" name="name" required><br><br>
<label for="email">Email:</label>
<input type="email" id="email" name="email" required><br><br>
<label for="password">Password:</label>
<input type="password" id="password" name="password" required><br><br>
<label>Gender:</label>
<input type="radio" id="male" name="gender" value="male">
<label for="male">Male</label>
<input type="radio" id="female" name="gender" value="female">
<label for="female">Female</label><br><br>
<label for="country">Country:</label>
<select id="country" name="country">
<option value="india">India</option>
<option value="usa">USA</option>
<option value="uk">UK</option>
</select><br><br>
<label for="bio">Bio:</label>
<textarea id="bio" name="bio" rows="4" cols="50"></textarea><br><br>
</fieldset>
<fieldset>
<legend>Skills</legend>
<label for="html">HTML:</label>
<input type="checkbox" id="html" name="skills" value="html"><br>
<label for="css">CSS:</label>
<input type="checkbox" id="css" name="skills" value="css"><br>
<label for="javascript">JavaScript:</label>
<input type="checkbox" id="javascript" name="skills" value="javascript"><br><br>
</fieldset>
</body>
</html>
Explanation of Controls:
Key points:
Form handling: You'll need to add server-side code (e.g., PHP, Python, Node.js) or client-
side JavaScript to handle the form submission and process the data.
Validation: Consider adding validation to ensure users enter valid data (e.g., required
fields, email format, password strength).
Accessibility: Use semantic HTML and ARIA attributes to make the form accessible to
users with disabilities.
Styling: Use CSS to style the form and its elements to match your website's design.
Experiments 7:
7. Design a website using style sheets so that the pages have uniform style.
/* style.css */
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f0f0f0;
color: #333;
}
header {
background-color: #333;
color: #fff;
padding: 20px;
text-align: center;
}
nav ul {
list-style: none;
margin: 0;
padding: 0;
background-color: #eee;
}
nav li {
display: inline;
margin-right: 20px;
}
nav a {
text-decoration: none;
color: #333;
}
main {
padding: 20px;
}
footer {
background-color: #333;
color: #fff;
padding: 10px;
text-align: center;
position: fixed;
bottom: 0;
width: 100%;
}
Create your HTML pages (e.g., index.html, about.html, contact.html)
<!DOCTYPE html>
<html>
<head>
<title>Home Page</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<header>
<h1>My Website</h1>
</header>
<nav>
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="about.html">About</a></li>
<li><a href="contact.html">Contact</a></li>
</ul>
</nav>
<main>
<h2>Welcome to the Home Page</h2>
<p>This is the content of the home page.</p>
</main>
<footer>
<p>© 2023 My Website</p>
</footer>
</body>
</html>
Explanation:
HTML pages:
Include the <link rel="stylesheet" href="style.css"> tag in the <head> section to link
the external CSS file.
Use semantic HTML elements (header, nav, main, footer) to structure your content.
The CSS rules in style.css will be applied to these elements, providing a uniform look
and feel across all pages.
Key points:
Consistent styling: By using an external CSS file, you can easily update the style of your
entire website by making changes in a single location.
Maintainability: This approach makes your code more organized and easier to maintain,
especially for larger websites.
Performance: The browser can cache the CSS file, improving page load times for
subsequent visits.
Experiments 8:
8. Using Java Script design a web page that prints factorial / Fibonacci series / any
given series.
<!DOCTYPE html>
<html>
<head>
<title>Series Calculator</title>
</head>
<body>
<h1>Series Calculator</h1>
<button onclick="calculateSeries()">Calculate</button>
<p id="result"></p>
<script>
function calculateSeries() {
const seriesType = document.getElementById("seriesType").value;
const inputNumber = parseInt(document.getElementById("inputNumber").value);
let result = "";
document.getElementById("result").textContent = result;
}
function calculateFactorial(n) {
if (n === 0 || n === 1) {
return 1;
} else {
return n * calculateFactorial(n - 1);
}
}
function calculateFibonacci(n) {
const fibSeries = [0, 1];
for (let i = 2; i <= n; i++) {
fibSeries[i] = fibSeries[i - 1] + fibSeries[i - 2];
}
return fibSeries.join(", ");
}
</script>
</body>
</html>
Explanation:
HTML structure:
Dropdown (<select>) to choose the series type.
Number input (<input type="number">) to get the input value.
Button (<button>) to trigger the calculation.
Paragraph (<p>) to display the result.
JavaScript functions:
calculateSeries():
Gets the selected series type and input number.
Calls the appropriate calculation function based on the series type.
Updates the result paragraph with the calculated series.
calculateFactorial(n):
Recursively calculates the factorial of n.
calculateFibonacci(n):
Iteratively calculates the Fibonacci series up to the nth term.
Custom series:
The custom option is included, but you'll need to implement the logic for calculating
custom series based on your specific requirements.
Key points:
Error handling: You might want to add error handling to check for invalid input (e.g.,
negative numbers, non-numeric input) and display appropriate messages to the user.
Custom series: The calculateCustomSeries() function is a placeholder. You'll need to
define the logic for calculating your desired custom series.
Optimization: For large factorials or Fibonacci numbers, consider using memoization or
other optimization techniques to improve performance.
Experiments 9:
9. Design a form with a test box and a command button. Using JavaScript write a
program whether the number entered in the text box is a prime number or not.
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<button onclick="checkPrime()">Check</button>
<p id="result"></p>
<script>
function checkPrime() {
if (isPrime) {
} else {
function isPrimeNumber(num) {
if (num <= 1) {
return false;
}
if (num % i === 0) {
return false;
return true;
</script>
</body>
</html>
Explanation:
HTML structure:
Input field (<input type="number">) to get the number from the user.
JavaScript functions:
checkPrime():
isPrimeNumber(num):
If num is divisible by any number in this range, it's not prime, so returns false.
If the loop completes without finding any divisors, num is prime, so returns true.
Key points:
Input validation: You might want to add input validation to ensure the user enters a valid positive
integer.
Efficiency: The isPrimeNumber function uses the square root optimization to improve
performance for larger numbers.
Error handling: Consider adding error handling to gracefully handle cases where the user enters
invalid input.
Experiments 10:
10. Design a form and validate all the controls placed on the form using Java Script.
<!DOCTYPE html>
<html>
<head>
<title>Form Validation Demo</title>
<style>
.error {
color: red;
}
</style>
</head>
<body>
<label for="name">Name:</label>
<input type="text" id="name" name="name" required><br><br>
<label for="email">Email:</label>
<input type="email" id="email" name="email" required><br><br>
<label for="password">Password:</label>
<input type="password" id="password" name="password" required><br><br>
<label for="age">Age:</label>
<input type="number" id="age" name="age" min="18" max="120" required><br><br>
<p id="errorMessages"></p>
<script>
function validateForm() {
let isValid = true;
let errorMessages = "";
// Name validation
const name = document.getElementById("name").value;
if (name.trim() === "") {
errorMessages += "Name is required.<br>";
isValid = false;
}
// Email validation
const email = document.getElementById("email").value;
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
if (!emailRegex.test(email)) {
errorMessages += "Invalid email format.<br>";
isValid = false;
}
// Password validation
const password = document.getElementById("password").value;
const confirmPassword = document.getElementById("confirmPassword").value;
if (password !== confirmPassword) {
errorMessages += "Passwords do not match.<br>";
isValid = false;
}
</body>
</html>
Explanation:
HTML Form:
Includes input fields for name, email, password, confirm password, and age.
The required attribute ensures that these fields cannot be left blank.
The min and max attributes on the age input restrict the valid age range.
An empty paragraph (<p id="errorMessages"></p>) is added to display error
messages.
Key points:
Client-side validation: This JavaScript code performs validation on the user's browser
before the form is submitted to the server.
Server-side validation: It's crucial to also implement server-side validation to ensure data
integrity and security, as client-side validation can be bypassed.
Error handling: The errorMessages paragraph provides feedback to the user about any
validation errors. You can further enhance this with visual cues (e.g., highlighting invalid
fields).
Accessibility: Ensure your form is accessible to all users by using semantic HTML, ARIA
attributes, and clear labels.
Experiments 11:
11. Design a DTD, corresponding XML document and display it in browser using CSS.
1. DTD (Document Type Definition)
This DTD defines a catalog that can contain zero or more book elements. Each book has a title,
author, year, and price, all of which contain simple text data.
2. XML Document
<book>
<author>Douglas Adams</author>
<year>1979</year>
<price>10.99</price>
</book>
<book>
<title>1984</title>
<author>George Orwell</author>
<year>1949</year>
<price>8.50</price>
</book>
</catalog>
3. CSS Styling
Now, let's style this XML using CSS. You'll typically use XSLT (Extensible Stylesheet Language
Transformations) to transform your XML into HTML, and then apply CSS to the resulting HTML.
However, some modern browsers might have limited support for directly styling XML with CSS.
/* style.css */
catalog {
display: block;
width: 500px;
padding: 20px;
book {
display: block;
margin-bottom: 15px;
padding-bottom: 10px;
title {
font-size: 1.2em;
font-weight: bold;
author {
font-style: italic;
Add the following line within the <catalog> element in your XML file:
Open in Browser:
Open the books.xml file in a modern web browser. If your browser supports direct XML styling,
you should see the catalog rendered with the CSS styles applied.
Important Notes
Browser Support: Direct XML styling with CSS is not universally supported. For broader
compatibility, you'd typically use XSLT to transform your XML into HTML and then style the HTML
with CSS.
XSLT: If you need to use XSLT, you'll create an XSLT stylesheet (transform.xsl) to define the
transformation rules. Then, you'd link it in your XML using <?xml-stylesheet type="text/xsl"
href="transform.xsl"?>.
Experiments 12:
<xsl:template match="/">
<html>
<head>
<title>Employee List</title>
</head>
<body>
<h2>Employee Information</h2>
<table>
<tr>
<th>Name</th>
<th>Department</th>
<th>Salary</th>
</tr>
<xsl:for-each select="employees/employee">
<tr>
<td><xsl:value-of select="name"/></td>
<td><xsl:value-of select="department"/></td>
<td><xsl:value-of select="salary"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Experiments 13:
</xs:schema>
2. XML Document (library.xml)
<?xml version="1.0" encoding="UTF-8"?>
<library xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="library.xsd">
<book>
<title>The Hitchhiker's Guide to the Galaxy</title>
<author>Douglas Adams</author>
<isbn>978-0-345-39180-3</isbn>
<publicationYear>1979</publicationYear>
</book>
<book>
<title>1984</title>
<author>George Orwell</author>
<isbn>978-0-451-52493-5</isbn>
<publicationYear>1949</publicationYear>
</book>
</library>
Explanation
XML Schema (library.xsd)
Defines the structure and data types allowed in the XML document
library is the root element
book elements can appear multiple times (maxOccurs="unbounded") within library
Each book has title, author, isbn, and publicationYear
Data types are specified (e.g., xs:string, xs:gYear)
Key Points
Validation: The XML Schema ensures that the XML document conforms to the defined
structure and data types.
Data Integrity: Using a schema helps maintain data consistency and prevents errors in the
XML data.
Tooling: Many XML editors and processors can leverage schemas for validation, auto-
completion, and other helpful features
Experiments 14:
14 Write a Basic PHP program to display “Hello World” using PHP programming.
<?php
?>
Explanation:
<?php: This opening tag indicates the start of PHP code.
echo "Hello World";: The echo statement is used to output text or variables to the browser. In this
case, it outputs the string "Hello World".
Save the code: Save the code in a file with a .php extension (e.g., hello.php).
Place it on a web server: You need a web server with PHP installed to run PHP scripts. If you're
learning, you can set up a local development environment like XAMPP or WAMP.
Access the file through a web browser: Open your web browser and navigate to the URL where
you placed the hello.php file (e.g., http://localhost/hello.php).
The browser will execute the PHP code on the server, and the output ("Hello World") will be sent
back to the browser and displayed on the page.
Important Notes
PHP tags: The <?php and ?> tags are essential to tell the server that the code between them
should be interpreted as PHP.
Case sensitivity: PHP is case-sensitive for variable names, but not for keywords like echo.