Unit-2 Web Application Development
Unit-2 Web Application Development
SEMANTIC ELEMENTS
Semantic elements clearly define their purpose and meaning in the structure of a document,
improving readability and accessibility.
➢ Characteristics:
• Semantic: Provides meaning to the content for both developers and assistive
technologies (e.g., screen readers).
• Helps improve search engine optimization (SEO) by better structuring the content.
• Enhances code readability and maintainability.
➢ Use Cases:
• Defining the logical structure of a webpage.
• Enhancing accessibility and SEO.
Examples:
• <header>: Represents the header section of a document or a section.
• <footer>: Represents the footer section of a document or a section.
• <article>: Represents a self-contained, independent piece of content.
• <section>: Defines a thematic grouping of content.
• <aside>: Represents content related to the main content (like a sidebar).
• <nav>: Represents navigation links.
• <main>: Represents the main content of a document.
CODING EXAMPLE
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Semantic Elements Example</title>
</head>
<body>
<!-- Header Section -->
<header>
<h1>My Website</h1>
<nav>
<ul>
<li><a href="#home">Home</a></li>
<li><a href="#about">About</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
</nav>
</header>
<section id="about">
<h2>About Us</h2>
<article>
<h3>Our Mission</h3>
<p>We aim to create meaningful content for our users.</p>
</article>
</section>
</main>
6. Sticky Positioning
This positioning combines features of position: relative and position: fixed. The element is
treated as position: relative until it reaches a specified threshold, then it becomes position:
fixed.
Example
<div style="position: sticky; top: 10px;">Sticky Position</div>
<div id="left"></div>
<div id="middle"></div>
<div id="right"></div>
</body>
</html>
Example
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Responsive Design</title>
<style>
</style>
</head>
<body>
</body>
</html>
Responsive Images
Responsive images play a key role in responsive websites. These are images that can adjust
their size, getting bigger or smaller, based on the width of the browser.
Responsive Texts
In this method, we set font sizes using %, vw, vh, etc. This ensures that text sizes are
responsive, adjusting automatically until reaching a certain limit. Once the limit is reached,
the content is justified to fit within the available width.
In this approach, we will use CSS display property to make the page responsive. Display
layouts like flexbox, inline, blocks, and grids can be used to make the design responsive.
Syntax
.container{
display:flexbox;
}
INLINE FRAMES
HTML Iframe is used to display a nested webpage (a webpage within a webpage). The HTML
<iframe> tag defines an inline frame, hence it is also called as an Inline frame.An HTML iframe
embeds another document within the current HTML document in the rectangular region.The
webpage content and iframe contents can interact with each other using JavaScript.
Syntax
<iframe src="URL"></iframe>
Here, "src" attribute specifies the web address (URL) of the inline frame page.
Set Width and Height of iframe
You can set the width and height of iframe by using "width" and "height" attributes. By default,
the attributes values are specified in pixels but you can also set them in percent. i.e. 50%, 60%
etc.
<!DOCTYPE html>
<html>
<body>
<h2>HTML Iframes example</h2>
<p>Use the height and width attributes to specify the size of the iframe:</p>
<iframe src="form.html" height="300" width="400"></iframe>
</body>
</html>
Embedding Audio
The <audio> tag, helps us to embed the required audio into the webpage. The control property
adds playback control like play, pause, volume. etc. The <source> tag specifies the specific
audio file and the type attribute is used to specify the MIME (Multipurpose Internet Mail
Extensions) type. If the browser does not support video a tag then the content present inside
will be displayed.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,
initial-scale=1.0">
<title>Embedding audio in HTML</title>
</head>
<body>
<audio controls>
<source src="Small_audio.mp3" type="audio/mp3">
Your browser does not support the audio tag.
</audio>
</body>
</html>
IMAGEMAPS IN HTML
HTML image maps are defined by the <map> tag. An image map enables specific areas of an
image to be clickable, acting as links to different destinations. This technique is useful for
creating complex navigation systems or interactive graphics on a webpage.
By defining various shapes (rectangles, circles, and polygons) within an image, each with its
own associated link, developers can create dynamic and interactive visual content that enhances
user engagement and navigation.
TYPES OF IMAGEMAPS
1. Client-Side Image Map
• The image map logic is handled in the browser using HTML.
• Defined using the <map> and <area> tags.
• Each <area> specifies a shape (rectangle, circle, or polygon) and links to a URL.
• Lightweight and doesn't require server processing.
2. Server-Side Image Map
• The map logic is processed on the server.
• The entire image is submitted to the server, and coordinates of the clicked point are
sent.
• Defined using the <input type="image"> element.
• Used when server processing is needed to decide the destination.
<form action="server-script.php" method="post">
<input type="image" src="image.jpg" name="mapImage">
</form>
It is useful to create interactive graphics by defining clickable regions within an image. This
allows users to interact with different image parts, triggering specific actions or links.
The <map> tag in HTML is used to define an image map. It is an image with clickable areas
that link to different destinations or perform specific actions. The <map> tag is typically used
in combination with the <img> tag and <area> tags to create these interactive regions. Each
<area> tag within a <map> defines a shape (rectangle, circle, or polygon) and specifies the
coordinates for the clickable area.
Syntax
<img src="image.jpg" usemap="#mapname" alt="Descriptive Image">
<map name="mapname">
<area shape="rect" coords="x1,y1,x2,y2"
href="link1.html" alt="Rectangle Area">
<area shape="circle" coords="x,y,radius"
href="link2.html" alt="Circle Area">
<area shape="poly" coords="x1,y1,x2,y2,x3,y3,..."
href="link3.html" alt="Polygon Area">
</map>
EXAMPLE
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HTML Imagemap Example</title>
</head>
<body>
<h1>Interactive Image with Imagemap</h1>
ADDING FAVICON
An HTML favicon (or favorite icon) is a small image or icon that represents a website, typically
shown in the browser tab, bookmarks, and shortcuts.
Need of favicons in HTML
• Brand Recognition
• A favicon helps users quickly identify a website among multiple open tabs or
bookmarks.
• It reinforces brand identity by displaying a recognizable logo or symbol.
• Improved User Experience
• Users can easily spot a specific tab, especially when several tabs are open.
• Enhances website professionalism and trustworthiness.
• Bookmark Visibility
• Favicons appear next to the site name in bookmarks and browser history, making the
site visually distinct.
• SEO and Accessibility
• While it doesn't directly affect search rankings, a favicon can improve user engagement,
indirectly benefiting SEO.
• Accessible icons make it easier for users to navigate and revisit sites.
• Browser Functionality
• Favicons are used in browser tasks like pinned tabs or progressive web apps (PWAs),
enhancing usability.
• Visual Appeal
• Adds a polished, complete look to the website.
• A missing favicon often leaves a generic or blank icon, detracting from the site’s
aesthetic.
• Favicon File Format Support
• ICO
• PNG
• GIF
• JPEG
• SVG
<html>
<head>
<title>HTML FAVICONS</title>
<link rel="icon" type="image/x-icon" href="google.png">
</head>
<body bgcolor="pink">
<h1><marquee direction="right">WELCOME TO GOOGLE</marquee></H1>
</BODY>
</HTML>
TABLES IN HTML
HTML Tables allow you to arrange data into rows and columns on a web page, making it easy
to display information like schedules, statistics, or other structured data in a clear format.There
can be many columns in a row.We can create a table to display data in tabular form, using
<table> element, with the help of <tr> , <td>, and <th> elements.In each table, table row is
defined by <tr> tag, table header is defined by <th>, and table data is defined by <td>
tags.HTML tables are used to manage the layout of the page e.g. header section, navigation
bar, body content, footer section etc. But it is recommended to use div tag over table to manage
the layout of the page .
HTML Table Tags
TABLE DIMENSION
Rowspan and Colspan are attributes used in HTML tables to merge cells, either vertically or
horizontally, to create a more organized layout. The rowspan attribute is used to merge multiple
rows into a single cell.Rowspan is useful when a cell's content spans vertically across multiple
rows.The colspan attribute is used to merge multiple columns into a single cell.Colspan is
useful when a cell's content spans horizontally across multiple columns.
<table style="border-collapse:collapse"; border="1" >
<tr>
<th>Name</th>
<th colspan="2">Details</th>
</tr>
<tr>
<td rowspan="2">John</td>
<td>Age</td>
<td>25</td>
</tr>
<tr>
<td>Role</td>
<td>Developer</td>
</tr>
</table>
FORMATTING TABLES: APPLYING BORDERS, BACKGROUND AND
FOREGROUND FILLS
9.<legend>
• Provides a caption for a <fieldset>.
• Example: <legend>Contact Info</legend>
10.<datalist>
• Provides a list of predefined options for an <input> element.
11. <input type="file">
• Allows users to upload files.
• Example: <input type="file" name="upload">
12. <input type="submit">
• Creates a button to submit the form.
• Example: <input type="submit" value="Submit">
<!DOCTYPE html>
<html lang="en">
<head>
<title>Html Forms</title>
</head>
<body>
<h2>HTML Forms</h2>
<form>
<label for="username">Username:</label><br>
<input type="text" id="username" name="username"><br><br>
<label for="password">Password:</label><br>
<input type="password" id="password" name="password"><br><br>
EXAMPLE2
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Simple HTML Form</title>
<style>
label
{
display: inline-block;
width: 150px;
display:flex;
}
.checkbox-container
{
display: flex;
white-space: nowrap;
}
.radio-container
{
display: flex; /* Align items horizontally */
align-items: center; /* Align items vertically in the center */
}
</style>
</head>
<body bgcolor="cyan">
<h1>CONTACT US</h1>
<form action="" method="POST">
<!-- Text Input for Name -->
<label for="name">Full Name:</label>
<input type="text" id="name" name="name" required><br><br>
<!--Number-->
<label for="Contact">Contact</label>
<input type="tel" id="number" name="num" min="0" max="9" maxlength="10" required>
<br><br>
<!--Textarea-->
<label for="feedback" >Your Query:</label>
<textarea id="query" name="query" rows="4" cols="50" placeholder="Enter your query
here..." required></textarea><br><br>
<!-- Radio Buttons for Gender -->
<div class="radio-container">
<label for="gender">Gender:</label>
<!DOCTYPE html>
<html lang="en">
<head>
</style>
</head>
<body bgcolor="pink">
<h1>HTML5 ADDITIONAL INPUT TYPES</h1>
<form action="" method="POST">
<!-- Date Input -->
<label for="dob">Date of Birth:</label>
<input type="date" id="dob" name="dob" required><br><br>
<!-- Time Input -->
<label for="time">Appointment Time:</label>
<input type="time" id="time" name="time" required><br><br>
<!-- dateTime Input -->
<label for="date">Enter Date-Time : </label>
<input type="datetime" />
<br /><br>
<br /><br>
<!-- week Input -->
<label for="time">Select Week : </label>
<input type="week" />
<br>
<br>
<!-- Range Input -->
<label for="age">Age (Select between 18 and 100):</label>
<input type="range" id="age" name="age" min="18" max="100" step="1" value="25"
required><br><br>
<span id="ageValue">25</span> years old<br><br>
<script>
// Update age value dynamically based on the range slider
document.getElementById('age').addEventListener('input', function() {
document.getElementById('ageValue').textContent = this.value;
});
</script>
</body>
</html>