Web technology
Web technology
Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
Unit 1
Introduction HTML: Basic Syntax, Standard HTML Document Structure, Basic Text Markup,
Html styles, Elements, Attributes, Heading, Layouts, Html media, Iframes Images, Hypertext
Links, Lists, Tables, Forms, GET and POST method, HTML 5, Dynamic HTML. CSS: Cascading
style sheets, Levels of Style Sheets, Style Specification Formats, Selector Forms, The Box Model,
Conflict Resolution, and CSS3.
Evolution of HTML
Version Year Functionality
HTML 1.0 1993 Basic text documents with hyperlinks
HTML 2.0 1995 Tables and image embedding
HTML 3.0 1995 Multimedia, style sheets, and
enhanced tables
HTML 3.2 1997 Forms, support for multiple character
sets, and frames
HTML 4.01 1999 Cascading style sheets , div and span
tags
XHTML 2000 XML structure
Introduction
HTML is an acronym which stands for Hyper Text Markup Language which is used for
creating web pages and web applications. It is only a formatting language are not a
programming language
Hyper Text: HyperText simply means "Text within Text." A text has a link within it, called
hypertext, whenever you click on a link which brings you to a new webpage. It is a way to
link two or more web pages (HTML documents) with each other.
Markup language: A markup language is a computer language that is used to apply layout
and formatting conventions to a text document. Markup language makes text more interactive
and dynamic. It can turn text into images, tables, links, etc.
Features
1) It is a very easy and simple language. It can be easily understood and modified.
2) It is very easy to make an effective presentation with HTML because it has a lot of formatting
tags.
3) It is a markup language, so it provides a flexible way to design web pages along with the text.
4) It facilitates programmers to add a link on the web pages (by html anchor tag), so it enhances the
interest of browsing of the user.
5) It is platform-independent because it can be displayed on any platform like Windows, Linux, and
Macintosh, etc.
Page 1
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
6) It facilitates the programmer to add Graphics, Videos, and Sound to the web pages which makes it
more attractive and interactive.
7) HTML is a case-insensitive language, which means we can use tags either in lower-case or upper-
case.
In older documents (HTML 4 or XHTML), the declaration is more complicated because the
declaration must refer to a DTD (Document Type Definition)
HTML 4
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
XHTML 1.1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2) <html> : Every HTML document starts with a <html> tag that encloses the entire HTML
document, serving as the root element for all HTML content. The end tag <html> is
</html>.
3) <head> : The <head> element is a container for metadata (data about data) which contains
following elements: <title>, <style>, <meta>, <link>, <script>, and <base>.The <head> is placed
between the <html> tag and the <body> tag.
Eg: <head>
<title>Title of the document</title>
</head>
Page 2
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
4) <title> : Used within the <head> section to define the title of the HTML document. It appears in
the browser tab or window and provides a brief description of the webpage’s content.
5) Comments: With the help of this tag, we can add comments in the HTML. These comments parts
are not displayed on the web page. But these commented codes are available in the source code.
Eg: <! -- Anything in between is considered a comment -->
6) <body> : The <body> tag defines the document's body. The <body> element contains all the
contents of an HTML document, such as headings, paragraphs, images, hyperlinks, tables, lists, etc.
There can only be one <body> element in an HTML document.
Eg: <body>
Body Contents
………….
………..
</body>
Page 3
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
<h1> Welcome to KHIT</h1>
<h2> Department of CSE 4-2 </h2>
<h3> Subject: Web technologies </h3>
</body>
</html>
Page 4
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
13) <big> – Increases the font size of the text: The <big> tag renders text in a bigger font than
the surrounding text.
Example program 1
<!DOCTYPE html>
<head>
<title> Text Formatting</title>
</head>
<body>
<p>This is a <strong><em>KHIT</em></strong> message.
</p>
<p>The chemical formula of water is H <sub>2</sub>O.
</p>
<p>
<del> Deleted text</del> and <ins>inserted text</ins> are shown here.
</p>
<p><small> Smaller text</small> can be used for disclaimers.
</p>
<p>E = mc<sup>2</sup></p>
</body>
</html>
Example program 2
Page 5
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
HTML Styles
The HTML style attribute is used to add styles to an element, such as color, font, size, and more. The
style attribute can be used with any HTML tag.
1) Background: The CSS background-color property defines the background color for an HTML
element. This property can be applied only to <body>, individual tags within the <body> or both at
the same time.
<body style="background-color:powderblue;">
<h1 style="background-color:red;"> IV year CSE</h1>
<p>KHIT</p>
</body>
2) Text Color: The CSS color property defines the text color for an HTML element.
<h1 style="color:orange;">Department of CSE</h1>
<p style="color:yellow;">KHIT</p>
3) Text Size: The CSS font-size property defines the text size for an HTML element.
<h1 style="font-size:300%;">Your Name</h1>
<p style="font-size:160%;">Your friend’s Name</p>
4) Text Alignment: The CSS text-align property defines the horizontal text alignment for an HTML
element
<h1 style="text-align:center;">Web Technologies</h1>
<p style="text-align:center;">IV year CSE – A,B,C</p>
Elements
An HTML file is made of elements. These elements are responsible for creating web pages
and define content in that webpage.
An element in HTML usually consist of a start tag <tag name>, close tag </tag name> and
content inserted between them.
All the content written between body element is visible on web page.
All the elements in HTML do not require to have start tag and end tag, some elements does
not have content and end tag such elements are known as Void elements or empty
elements. Eg: <br> (represents a line break), <hr> (represents a horizontal line).
HTML can have nested, which means an element can contain another element.
All the elements are divided into two categories:
1) Block-level elements
o These are the elements, which structure main part of web page, by dividing a page
into coherent blocks.
o A block-level element always starts with new line and takes the full width of web
page, from left to right. These elements can contain block-level as well as inline
elements.
Example: <address>, <article>, <aside>, <blockquote>, <canvas>, <dd>, <div>, <dl>, <dt>,
<fieldset>, <figcaption>, <figure>, <footer>, <form>, <h1>-<h6>, <header>, <hr>,
Page 6
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
<li>, <main>, <nav>, <noscript>, <ol>, <output>, <p>, <pre>, <section>, <table>,
<tfoot>, <ul> and <video>.
2) Inline elements
o Inline elements are those elements, which differentiate the part of a given text and
provide it a particular function.
o These elements do not start with new line and take width as per requirement. The
inline elements are mostly used with other elements.
Examples: <a>, <abbr>, <acronym>, <b>, <bdo>, <big>, <br>, <button>, <cite>, <code>,
<dfn>, <em>, <i>, <img>, <input>, <kbd>, <label>, <map>, <object>, <q>, <samp>, <script>,
<select>, <small>, <span>, <strong>, <sub>, <sup>, <textarea>, <time>, <tt>, <var>.
Attributes
HTML attributes are special words that provide additional information to an HTML element.
Attributes are placed inside the element's opening tag, and they are used to configure or adjust
the element's behavior.
All attributes are made up of two parts: a name and a value −
syntax: <element attribute_name="value">content</element>
Name: The attribute name is the keyword, also known as the attribute identifier,
which defines a specific characteristic for the element in which it is using. For
example, the paragraph <p> element has an attribute "align", which defines the
alignment of the paragraph on the page.
Value: The attribute value is the data or information that defines the value to be set for
that attribute. The value is assigned within the double quotes. For example, "left",
"center", or "right" can be assigned to the "align" attribute with the paragraph tag.
2) src Attribute: We use the <img> tag add an image in an HTML page. The src attribute specifies
the image path. We can specify the address of the image inside the double quotes.
<img src="img_tulip.jpg">
The <img> tag also contains the width and height attributes. As the name suggests, these attributes
specify the width and height of the image in pixels).
Page 7
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
<img src="img_tulip.jpg" width="500" height="200">
The alt attribute is used with the image <img> tag. It helps us to specify the alternative text in case,
the image cannot be displayed on the website. The alt attribute should reflect the image content so
that users can understand what the image contains.
<img src="img_tulip.jpg" alt="Red Tulips in a Garden">
3) style Attribute: The style attribute helps us set the style, such as font, size, colour, etc., of the
HTML element.
<p style=" background:lightblue; color:navy;">Style attribute in HTML.</p>
4) lang Attribute: The lang attribute specifies the language used in an HTML document to assist
search engines and browsers. This attribute is always used inside the <html> tag.
We can also use the country codes to the language code. The first two characters specify the language
of the web page while the last two characters specify the country.
Example that specifies Hindi as the language and India as the country:
<!DOCTYPE html>
<html lang="hin-IN">
<body>
Content Goes Here.
</body>
</html>
5) Title Attribute: The title attribute specifies extra information about the element. It supports all
HTML elements and displays the information when the mouse moves over the element (link or any
text).
<p title="This is paragraph tag">Example of title attribute</p>
Page 8
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
Heading
HTML headings are used to define the content hierarchy and structure of a webpage. They
range from <h1> to <h6>, with <h1> being the most important heading and <h6> the least
important.
Hierarchical Structure of Heading Tags
The <h1> tag: The top-level heading denotes the main topic or title of the entire page.
The <h2> tag: Subheadings under <h1> represent major sections related to the main
topic. They provide a more specific context to the content.
The <h3> to <h6> tags: These tags are used for further subsections or nested content
within <h2> headings. They offer a deeper level of hierarchy for organizing content
within specific sections.
Example
<!DOCTYPE html>
<html>
<head> <title>Heading elements</title> </head>
<body>
<h1>This is main heading of page. </h1>
<p>h1 is the most important heading, which is used to display the keyword of page </p>
<h2>This is first sub-heading</h2>
<p>h2 describes the first sub heading of page. </p>
<h3>This is Second sub-heading</h3>
<p>h3 describes the second sub heading of page.</p>
<p>We can use h1 to h6 tag to use the different sub-heading with their paragraphs if
required. </p>
</body>
</html>
Page 9
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
Layouts
HTML layouts are the backbone of web pages, which are used for structuring content for
user-friendly navigation.
HTML layout structures the web page using elements such as <header>, <nav>, <main>,
<article>, <section>, <aside> and <footer>.
Techniques for Creating HTML Layouts: There are several techniques to create multi-
column layouts in HTML:
CSS Frameworks (like Bootstrap): Speed up layout design with pre-built
components and grid systems.
CSS Float Property: A classic way to position elements, but be aware of how it
interacts with normal document flow.
CSS Flexbox: Ideal for dynamic layouts, easily adjusting content across different
screen sizes.
CSS Grid: Create complex, two-dimensional layouts with ease.
Page 10
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
font-weight: bold;
}
.head2 {
font-size: 17px;
margin-left: 10px;
margin-bottom: 15px;
}
body {
margin: 0 auto;
background-position: center;
background-size: contain;
}
.menu {
position: sticky;
top: 0;
background-color: #009900;
padding: 10px 0px 10px 0px;
color: white;
margin: 0 auto;
overflow: hidden;
}
.menu a {
float: left;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 20px;
}
footer {
width: 100%;
Page 11
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
bottom: 0px;
background-color: #000;
color: #fff;
position: absolute;
padding-top: 20px;
padding-bottom: 50px;
text-align: center;
font-size: 30px;
font-weight: bold;
}
.body_sec {
margin-left: 20px;
}
</style>
</head>
<body>
Page 12
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
<h3>Content section</h3>
</section>
</main>
<!-- Footer Section -->
<footer>Footer Section</footer>
</body>
</html>
HTML Media
HTML5 has revolutionized the way we consume multimedia content on the web. Web
developers can create immersive and interactive multimedia experiences that rival those
of traditional desktop applications.
However, with great power comes great responsibility. As the amount of multimedia
content on the web grows, so does the need to organize and manage it effectively. This is
where multimedia tags in HTML5 come in.
In HTML5, multimedia tags are used to embed audio, video, and other types of
multimedia content into web pages. These tags provide a standardized way of playing
multimedia content across different browsers and devices.
1) <audio>- This tag is used to embed audio files, such as music or podcasts, into web
pages.
<audio src="audiofile.mp3" controls>
Your browser does not support the audio element.
</audio>
2) <video>- This tag is used to embed video files, such as movies or TV shows, into web
pages.
<video src="videofile.mp4" controls>
Your browser does not support the video element.
</video>
Page 13
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
3) <source>- This tag is used to specify alternative versions of media files, such as different
formats or bitrates, which the browser can choose from based on the user's device and
internet connection.
<video controls>
<source src="videofile.mp4" type="video/mp4">
<source src="videofile.webm" type="video/webm">
Your browser does not support the video element.
</video>
Attributes of source
src: specifies the URL of the multimedia file
type: specifies the MIME type of the multimedia file
4) <track>- This tag is used to add subtitles or captions to video or audio files.
<video controls>
<source src="videofile.mp4" type="video/mp4">
<track src="subtitles.vtt" kind="subtitles" srclang="en">
Your browser does not support the video element.
</video>
Attributes of track
src: specifies the URL of the subtitles file
kind: specifies the type of subtitles (e.g., subtitlesor captions)
srclang: specifies the language of the subtitles
label: specifies a label for the subtitles
5) <picture>- This tag is used to specify different versions of an image that can be displayed
depending on the user's device and screen size.
<picture>
<source media="(min-width: 1200px)" srcset="largeimage.jpg">
<source media="(min-width: 768px)" srcset="mediumimage.jpg">
<img src="smallimage.jpg" alt="Small Image"> </picture>
Attributes of picture
<source>tags: the same attributes as for the <source>tag in the <video>tag, plus the
mediaattribute, which specifies the conditions under which the image should be
displayed
<img>tag: the same attributes as for the <img>tag in HTML, such as src, alt, width,
and height.
Page 14
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
Iframes Images
Images
In HTML, images are a type of multimedia content that can be embedded within a web page.
They are used to enhance the visual presentation of a webpage by displaying pictures,
diagrams, illustrations, or other types of graphics.
To insert an image in HTML, you need to use the <img> tag. The <img> tag is an empty
element, which means it doesn't have a closing tag. Instead, you need to specify the image
source (URL) and other attributes within the opening tag.
Iframes
The term "iframe" stands for "inline frame". Iframes are HTML tags that allow you to embed
content from another website or web page within a frame on your own web page.
The <iframe> tag specifies the URL of the external content, enabling seamless integration
of videos, maps, forms, or entire web pages into your site.
<iframe src="URL" title="description"></iframe>
There are two types of URL links
URL Descriptions
Attributes of Iframe
Attributes Description
Page 15
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
Attributes Description
Example 1
<!DOCTYPE html>
<html>
<body>
<h2>HTML Iframes</h2>
<p>Use the CSS height and width properties to specify the size of the iframe:</p>
<iframe src="https://khitguntur.ac.in/" style="height:300px;width:400px"></iframe>
</body>
</html>
Page 16
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
Example 2
<!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="https://vitap.ac.in/" height="300" width="400"></iframe>
</body>
</html>
Example 3
<!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="https://vitap.ac.in/" height="300" width="400"></iframe>
<iframe src="https://khitguntur.ac.in/" style="height:300px;width:400px"></iframe>
</body>
</html>
Hypertext Links
HTML links, or hyperlinks, connect web pages; they enable users to navigate between
pages or resources. Links can be text, images, or other elements, enhancing web navigation
and interactivity.
Hyperlinks are created using the `<a>` tag with the `href` attribute.
Another method for creating hyperlinks is to use the HTML DOM window.location
property to dynamically set the browser's current location. By assigning a URL to
window.location.href, we can trigger a redirection, providing hyperlink-like functionality.
<button onclick=
"window.location.href='https://www.khitguntur.ac.in/'">Visit for KHIT College
Web page </button>
By default, links will appear as follows in all browsers:
An unvisited link is underlined and blue
A visited link is underlined and purple
An active link is underlined and red
Syntax: <a href="url">link text</a>
Attribute Description
Page 17
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
Attribute Description
A Uniform Resource Locator (URL) is an address that indicates the location of a specific file
or resource on the World Wide Web (WWW). A URL specifies the site of a target saved on a
local or networked computer.
1) Absolute URL
An absolute URL is a complete web address that specifies the exact location of a resource on
the internet, including the protocol and domain name.
An absolute web address includes all of the following parts: Protocol (e.g., HTTP, HTTPS),
Domain name (e.g., example.com), Path (e.g., /about/), Anchor (optional).
When to use absolute URLs :
When linking to a resource on a different website
When linking to a resource that is not located in the same directory as the current
page
When you need to ensure that the link will always work, even if the website is moved
to a different domain or protocol in the future
Example:
<h2>Absolute URLs</h2>
<p><a href="https://www. khitguntur.ac.in/">KHIT College Website</a></p>
<p><a href="https://www.google.com/">Google</a></p>
2) Relative URL
A relative link provides a shorthand way to reference a resource within the same website or
directory, rather than providing the complete web address. It’s “relative” to the current
location or page where it’s used.
When to use relative URLs
When linking to a resource on the same website
When linking to a resource that is located in the same directory as the current page,
or in a subdirectory of the current page
When you want to make your code more portable and easier to maintain
Example:
Page 18
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
<h2>Relative URLs</h2>
<p><a href="html_images.asp">HTML Images</a></p>
<p><a href="/css/default.asp">CSS Tutorial</a></p>
<head>
<title>Target Attribute Example</title>
</head>
<body>
<h3> Various options available in the Target Attribute </h3>
<p>
If you set the target attribute to "_blank", the link will open in a new browser window
or tab. </p>
<a href="https://www. khitguntur.ac.in/" target="_blank"> KHIT College Page </a>
<p>
If you set the target attribute to "_self", the link will open in the same window or tab.
</p>
<a href=" https://www. khitguntur.ac.in/" target="_self"> KHIT College Page </a>
<p>
If you set the target attribute to "_top", the link will open in the full body of the
window. </p>
<a href=" https://www. khitguntur.ac.in/" target="_top"> KHIT College Page </a>
<p>
If you set the target attribute to "_parent", the link will open in the parent frame.
</p>
<a href=" https://www. khitguntur.ac.in/" target="_parent"> KHIT College Page
</a>
</body>
</html>
Page 19
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
Lists
An HTML list is a structured record of related information used to display data or
information on web pages in an ordered or unordered form.
There are three main types of lists in HTML:
1) Unordered Lists
2) Ordered Lists
3) Description Lists
List of all lists tags HTML:
Unordered Lists: The unordered list items are marked with bullets, also known as bulleted lists.
An unordered list starts with the <ul> tag, and each list item begins with the <li> tag.
Syntax: <ul> list of items </ul>
Attribute:
1) compact: It will render the list smaller.
2) type: It specifies which kind of marker is used in the list.
Example:
<!DOCTYPE html>
<html> <head> <title> Example for unordered list </title> </head>
<body>
<h2>Grocery list</h2>
<ul>
<li>Bread</li>
<li>Eggs</li>
<li>Milk</li>
<li>Coffee</li>
</ul>
</body>
</html>
Page 20
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
Ordered Lists: In an ordered list, all list items are marked with numbers by default. An ordered
list starts with the <ol> tag, and each list item begins with the <li> tag.
Syntax: <ol>
<li>Item1</li>
<li>Item2</li>
<li>Item3</li>
</ol>
Attributes:
1) compact: It defines the list should be compacted (compact attribute is not supported in
HTML5. Use CSS instead.).
2) reversed: It defines that the order will be descending.
3) start: It defines from which number or alphabet the order will start.
4) type: It defines which type(1, A, a, I, and i) of the order you want in your list of numeric,
alphabetic, or roman numbers
Example:
<!DOCTYPE html>
<html>
<head>
<title>HTML ol tag</title>
</head>
<body>
<h1 style="color: green">Final Year Subjects</h1>
<h3>HTML ol tag</h3>
<p>reversed attribute</p>
<ol reversed>
<li>CC</li>
<li>WT</li>
<li>CSP</li>
</ol>
<p>start attribute</p>
<ol start="5">
<li>CC</li>
<li>WT</li>
<li>CSP</li>
</ol>
<p>type attribute</p>
<ol type="i">
<li>CC</li>
<li>WT</li>
<li>CSP</li>
Page 21
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
</ol>
</body>
</html>
Description Lists: A description list is a list of terms, with a description of each term. The <dl>
tag defines the description list, the <dt> tag defines the term name, and the <dd> tag describes
each term. The HTML definition list contains following three tags:
<dl> tag defines the start of the list.
<dt> tag defines a term.
<dd> tag defines the term definition (description).
Example:
<!DOCTYPE html>
<html>
<body>
<h2> Description List of CSE Department</h2>
<dl>
<dt>II<sup>nd</sup>Year</dt>
<dd>4 Sections (A,B,C,D)</dd>
<dt>III<sup>rd</sup>Year</dt>
<dd>4 Sections (A,B,C,D)</dd>
<dt>IV<sup>th</sup>Year</dt>
<dd>3 Sections (A,B,C)</dd>
</dl>
</body>
</html>
Tables
A table in HTML refers to the arrangement of data in rows and columns.
An HTML table is created using the <table> tag. Inside this tag, you use
<tr> to define table rows,
<th> for table headers, and
<td> for table data cells
Tags used in HTML Tables
HTML Tags Descriptions
Page 22
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
Represents a
<td> standard data cell, holding
content or data.
Provides a title or
<caption> description for the entire
table.
Page 23
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
Example
<!-- index.html -->
<!DOCTYPE html>
<html>
<body>
<table>
<tr>
<th>Book Name</th>
<th>Author Name</th>
<th>Genre</th>
</tr>
<tr>
<td>The Book Thief</td>
<td>Markus Zusak</td>
<td>Historical Fiction</td>
</tr>
<tr>
<td>The Cruel Prince</td>
<td>Holly Black</td>
<td>Fantasy</td>
</tr>
<tr>
<td>The Silent Patient</td>
<td> Alex Michaelides</td>
<td>Psychological Fiction</td>
</tr>
</table>
</body>
</html>
Styling Table: Styling an HTML table can significantly improve its appearance and readability.
You can use CSS.
1) Adding a Border
Page 24
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
<!-- index.html -->
<!DOCTYPE html>
<html>
<head>
<style>
table,
th,
td {
border: 1px solid black;
}
</style>
</head>
<body>
<table style="width:100%">
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Age</th>
</tr>
<tr>
<td>Priya</td>
<td>Sharma</td>
<td>24</td>
</tr>
<tr>
<td>Arun</td>
<td>Singh</td>
<td>32</td>
</tr>
<tr>
<td>Sam</td>
<td>Watson</td>
<td>41</td>
</tr>
</table>
</body>
</html>
Page 25
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
<style>
table,
th,
td {
border: 1px solid black;
border-collapse: collapse;
}
</style>
</head>
th,
td {
padding: 20px;
}
</style>
</head>
th,
td {
padding: 20px;
}
Page 26
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
th {
text-align: left;
}
</style>
</head>
table {
border-spacing: 5px;
}
</style>
</head>
Page 27
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
</tr>
8) Adding a Caption
<body>
<table style="width:100%">
<caption>DETAILS</caption>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Age</th>
</tr>
th,
td {
padding: 5px;
text-align: left;
width: 100%;
background-color: #f2f2d1;
</style>
</head>
Page 28
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
</tr>
<tr>
<td> Second row of Inner Table </td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
Forms
Web forms are one of the main points of interaction between a user and a website or
application.
HTML Forms use the <form> tag to collect user input through various interactive controls.
These controls range from text fields, numeric inputs, and email fields to password fields,
checkboxes, radio buttons, and submit buttons.
Syntax: <form>
<!--form elements-->
</form>
Form Elements: The HTML <form> comprises several elements, each serving a unique
purpose.
Elements Descriptions
Page 29
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
Elements Descriptions
Commonly Used Input Types in HTML Forms: In HTML forms, various input types are
used to collect different types of data from users. Here are some commonly used input
types:
Input Type Description
Page 30
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
Example Program
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HTML Form</title>
<style>
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
background-color: #f0f0f0;
}
form {
width: 400px;
background-color: #fff;
padding: 20px;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
Page 31
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
}
fieldset {
border: 1px solid black;
padding: 10px;
margin: 0;
}
legend {
font-weight: bold;
margin-bottom: 10px;
}
label {
display: block;
margin-bottom: 5px;
}
input[type="text"],
input[type="email"],
input[type="password"],
textarea,
input[type="date"] {
width: calc(100% - 20px);
padding: 8px;
margin-bottom: 10px;
box-sizing: border-box;
border: 1px solid #ccc;
border-radius: 4px;
}
.gender-group {
margin-bottom: 10px;
}
.gender-group label {
display: inline-block;
margin-left: 10px;
}
input[type="radio"] {
margin-left: 10px;
vertical-align: middle;
Page 32
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
}
input[type="submit"] {
padding: 10px 20px;
border-radius: 5px;
cursor: pointer;
}
</style>
</head>
<body>
<form>
<fieldset>
<legend>User Personal Information</legend>
<label for="name">Enter your full name:</label>
<input type="text" id="name" name="name" required />
<label for="email">Enter your email:</label>
<input type="email" id="email" name="email" required />
<label for="password">Enter your password:</label>
<input type="password" id="password" name="pass" required />
<label for="confirmPassword">Confirm your password:</label>
<input type="password" id="confirmPassword" name="confirmPass" required
/>
<label>Enter your gender:</label>
<div class="gender-group">
<input type="radio" name="gender" value="male" id="male" required />
<label for="male">Male</label>
<input type="radio" name="gender" value="female" id="female" />
<label for="female">Female</label>
<input type="radio" name="gender" value="others" id="others" />
<label for="others">Others</label>
</div>
<label for="dob">Enter your Date of Birth:</label>
<input type="date" id="dob" name="dob" required />
<label for="address">Enter your Address:</label>
<textarea id="address" name="address" required></textarea>
<input type="submit" value="Submit" />
</fieldset>
</form>
</body>
</html>
Page 33
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
GET and POST method
The method attribute in the <form> element specifies how the data is sent to the server.
HTTP methods declare what action is to be performed on the data that is submitted to the
server. HTTP Protocol provides several methods, and the HTML Form element is able to use
two methods to send user data:
1) GET method - used to request data from a specified resource
2) POST method - used to send data to a server to update a resource
GET vs POST
GET POST
Page 34
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
HTML 5
HTML5 described as a new version of HTML is a successor to previous HTML versions and
introduced new elements and capabilities such as Application Programming Interfaces (API),
hardware access and Document Object Model (DOM).
Features:
It has introduced new multimedia features which supports both audio and video
controls by using <audio> and <video> tags.
There are new graphics elements including vector graphics and tags.
Enrich semantic content by including <header> <footer>, <article>, <section> and
<figure> are added.
Drag and Drop- The user can grab an object and drag it further dropping it to a new
location.
Geo-location services- It helps to locate the geographical location of a client.
Web storage facility which provides web application methods to store data on the
web browser.
Uses SQL database to store data offline.
Allows drawing various shapes like triangle, rectangle, circle, etc.
Capable of handling incorrect syntax.
Easy DOCTYPE declaration i.e., <!doctype html>
Easy character encoding i.e., <meta charset=”UTF-8″>
<acronym> <abbr>
<applet> <object>
<basefont> CSS
Page 35
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
<big> CSS
<center> CSS
<dir> <ul>
<font> CSS
<frame>
<frameset>
<noframes>
<isindex>
<tt> CSS
Added elements
<article>: The <article> tag is used to represent an article.
<aside>: The <aside> tag is used to describe the main object of the web page in a shorter way
like a highlighter.
<figcaption>: The <figcaption> tag in HTML is used to set a caption to the figure element in a
document.
<figure>: The <figure> tag in HTML is used to add self-contained content like illustrations,
diagrams, photos or codes listing in a document
<header>: It contains the section heading as well as other content, such as a navigation links,
table of contents, etc.
<footer>: The <footer> tag in HTML is used to define a footer of HTML document.
<main>: Delineates the main content of the body of a document or web app.
<mark>: The <mark> tag in HTML is used to define the marked text. It is used to highlight the
part of the text in the paragraph.
<nav>: The <nav> tag is used to declaring the navigational section in HTML documents..
<section>: It demarcates a thematic grouping of content.
<details>: The <details> tag is used for the content/information which is initially hidden but
could be displayed if the user wishes to see it.
<summary>: The <summary> tag in HTML is used to define a summary for the <details>
element.
Page 36
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
<time>: The <time> tag is used to display the human-readable data/time. It can also be used to
encode dates and times in a machine-readable form.
<bdi>: The <bdi> tag refers to the Bi-Directional Isolation. It differentiates a text from other
text that may be formatted in different direction.
<wbr>: The <wbr> tag in HTML stands for word break opportunity and is used to define the
position within the text which is treated as a line break by the browser.
<datalist>: The <datalist> tag is used to provide autocomplete feature in the HTML files. It
can be used with input tag, so that users can easily fill the data in the forms using select the
data.
<keygen>: The <keygen> tag in HTML is used to specify a key-pair generator field in a form.
The purpose of <keygen> element is to provide a secure way to authenticate users.
<output>: The <output> tag in HTML is used to represent the result of a calculation performed
by the client-side script such as JavaScript.
<progress>: It is used to represent the progress of a task. It also defines how much work is
done and how much is left to download a task.
<svg>: It is the Scalable Vector Graphics.
<canvas>: The <canvas> tag in HTML is used to draw graphics on web page using JavaScript.
It can be used to draw paths, boxes, texts, gradient and adding images. By default, it does not
contain border and text.
<audio>: It defines the music or audio content.
<embed>: Defines containers for external applications (usually a video player).
<source>: It defines the sources for <video> and <audio>.
<track>: It defines the tracks for <video> and <audio>.
<video>: It defines the video content.
Advantages:
All browsers supported.
More device friendly.
Easy to use and implement.
HTML 5 in integration with CSS, JavaScript, etc. can help build beautiful websites.
Disadvantages:
Long codes have to be written which is time consuming.
Only modern browsers support it.
Dynamic HTML
DHTML, or Dynamic HTML, is a technology that differs from traditional HTML.
DHTML combines HTML, CSS, JavaScript, and the Document Object Model (DOM) to
create dynamic content and to modify settings, properties, and methods.
Page 37
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
Key Features:
Tags and their properties can be changed using DHTML.
It is used for real-time positioning.
Dynamic fonts can be generated using DHTML.
It is also used for data binding.
It makes a webpage dynamic and be used to create animations, games, applications
along with providing new ways of navigating through websites.
The functionality of a webpage is enhanced due to the usage of low-bandwidth effect
by DHTML.
DHTML also facilitates the use of methods, events, properties, and codes.
DHTML: JavaScript
Example: The following example simply uses the document.write() method of JavaScript in the
DHTML
<HTML>
<head>
<title>
Method of a JavaScript
</title>
</head>
<body>
<script type="text/javascript">
document.write("KHIT: Dept.. of CSE");
</script>
</body>
</html>
Page 38
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
CSS: Cascading style sheets
CSS (Cascading Style Sheets) is a language designed to simplify the process of making web
pages presentable.
It allows you to apply styles to HTML documents, describing how a webpage should look
by prescribing colors, fonts, spacing, and positioning.
It provides developers and designers with powerful control over the presentation of HTML
elements.
HTML uses tags and CSS uses rulesets. CSS styles are applied to the HTML element using
selectors.
Benefits of using CSS
Saves Time: Write CSS once and reuse it across multiple HTML pages.
Easy Maintenance: Change the style globally with a single modification.
Search Engine Friendly: Clean coding technique that improves readability for
search engines.
Superior Styles: Offers a wider array of attributes compared to HTML.
Offline Browsing: CSS can store web applications locally using offline cache,
allowing offline viewing.
CSS consists of style rules that are interpreted by the browser and applied to the
corresponding elements. CSS declaration always ends with a semicolon, and declaration
blocks are surrounded by curly braces. A style rule set includes a selector and a declaration
block.
Selector: Targets specific HTML elements to apply styles.
Declaration: Combination of a property and its corresponding value.
Syntax:
// HTML Element
<h1>Dr. Vamshi Krishna K</h2>
// CSS Style
h1 { color: blue; font-size: 12px; }
Example
<!DOCTYPE html>
<html>
<head>
<title>Simple web page</title>
<style>
main {
width: 600px;
height: 200px;
padding: 10px;
background: beige;
Page 39
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
}
h1 {
color: blue;
border-bottom: 1px dotted darkgreen;
}
p{
font-family: sans-serif;
color: orange;
}
</style>
</head>
<body>
<main>
<h1>My first Page</h1>
<p>This is a basic web page.</p>
</main>
</body>
</html>
1) Inline CSS involves applying styles directly to individual HTML elements using the style
attribute. This method allows for specific styling of elements within the HTML document,
overriding any external or internal styles.
Example:
<p style="color:#009900;
font-size:50px;
font-style:italic;
text-align:center;">
Page 40
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
Dr. Vamshi Krishna K
</p>
2) Internal or Embedded CSS is defined within the HTML document’s <style> element. It applies
styles to specified HTML elements. The CSS rule set should be within the HTML file in the head
section i.e. the CSS is embedded within the <style> tag inside the head section of the HTML file.
Example:
<!DOCTYPE html>
<html>
<head>
<style>
.main {
text-align: center;
}
.name {
color: #009900;
font-size: 50px;
font-weight: bold;
}
.dest {
font-style: bold;
font-size: 20px;
}
</style>
</head>
<body>
<div class="main">
<div class="name">Dr. Vamshi Krishna K</div>
<div class="dest">
Associate Professor
</div>
</div>
</body>
</html>
3) External CSS contains separate CSS files with .css extension that contain only style properties
with the help of tag attributes (For example class, id, heading, … etc) and should be linked to the
HTML document using a link tag. It means that, for each element, style can be set only once and
will be applied across web pages.
Example:
Filename.html
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="style.css">
Page 41
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
</head>
<body>
<div class="main">
<div class="name">Dr. Vamshi Krishna K </div>
<div id="dest">
Associate Professor
</div>
</div>
</body>
</html>
style.css
body {
background-color: powderblue;
}
.main {
text-align: center;
}
.name {
color: #009900;
font-size: 50px;
font-weight: bold;
}
#dest {
font-style: bold;
font-size: 20px;
}
Page 42
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
Page 43
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
Selector Forms
CSS selectors target the HTML elements on your pages, allowing you to add styles based
on their ID, class, type, attribute, and more.
Types of CSS selectors
1) Simple selectors: It is used to select the HTML elements based on their element name, id,
attributes, etc
Example:
<!DOCTYPE html>
<html lang="en">
<head>
<title>CSS Selectors</title>
<link rel="stylesheet" href="style.css" />
</head>
Page 44
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
<body>
<h1>Sample Heading</h1>
<p>This is Content inside first paragraph</p>
<div id="div-container">
This is a div with id div-container
</div>
<p class="paragraph-class">
This is a paragraph with class paragraph-class
</p>
</body>
</html>
2) Element selectors: The element selector selects HTML elements based on the element name (or
tag) for example p, h1, div, span, etc.
Example:
h1 {
color: red;
font-size: 3rem;
}
p{
color: white;
background-color: gray;
}
3) Id selectors: The id selector uses the id attribute of an HTML element to select a specific
element. An id of the element is unique on a page to use the id selector.
Example:
#div-container{
color: blue;
background-color: gray;
}
4) Class selector: The class selector selects HTML elements with a specific class attribute.
Example:
.paragraph-class {
color:white;
font-family: monospace;
background-color: purple;
}
5) Universal selector: The Universal selector (*) in CSS is used to select all the elements in an
HTML document. It also includes other elements which are inside under another element.
Example:
*{
color: white;
background-color: black;
}
Page 45
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
6) Group selectors: The Group selector is used to style all comma-separated elements with the same
style.
Example:
#div-container, .paragraph-class, h1{
color: white;
background-color: purple;
font-family: monospace;
}
7) Attribute selector: The attribute selector [attribute] is used to select the elements with a specified
attribute or attribute value.
Example:
[href] {
background-color: lightgreen;
color: black;
font-family: monospace;
font-size: 1rem;
}
Page 46
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
Conflict Resolution
CSS conflicts between selectors occur when two or more selectors have conflicting styles
applied to the same element, leading to unexpected results. In such cases, the browser has to
decide which style to apply to the element.
There are three reasons for CSS style conflict:
1) Specificity: The more specific selector will override the less specific one. Specificity is
calculated based on the number of elements, classes, and IDs in the selector. For example,
the selector with an ID has a higher specificity than the one with a class, and the one with
a class has a higher specificity than the one with an element.
Example:
<!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" />
<style>
p{
Page 47
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
color: blue;
}
.special {
color: red;
}
</style>
</head>
<body>
<p class="special">This is a red text.</p>
</body>
</html>
2) Inheritance: Inheritance is the process by which styles applied to a parent element are
passed down to its child elements. If two selectors have the same specificity, the one that
comes later in the stylesheet will override the earlier one. If one of the conflicting styles is
inherited, the browser will use the inherited style over the non-inherited style, even if the
non-inherited style has a higher specificity or is defined later in the cascade order.
Example:
<!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" />
<style>
/* Style applied to the parent element */
.parent {
font-size: 14px;
}
/* Conflicting style applied to
the child element */
.child {
font-size: 16px;
}
</style>
</head>
<body>
<div class="parent">
<p>
Parent element with font-size of 14px
</p>
<div class="child">
<p>
Child element with conflicting
font-size of 16px
</p>
</div> </div>
</body> </html>
Page 48
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
3) !important: The styles marked with the !important keyword will always take precedence
over any other styles.
Example:
<!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" />
<style>
p{
color: blue !important;
}
.special {
color: red;
}
</style>
</head>
<body>
<p class="special">This is a red text.</p>
</body>
</html>
CSS3
CSS3, also known as Cascading Style Sheets Level 3, is a more advanced version of CSS and
the successor of CSS2.
CSS3 is used for the same thing as CSS, namely to style web pages and make them more
attractive and user-friendly.
In addition, CSS3 incorporates more up-to-date features designed to increase efficiency and
make it more convenient for developers to use.
Opacity. This property lets web designers make web page elements partially or fully transparent.
You can define the elements’ opacity levels to make them fully opaque, transparent, or even see-
through.
Rounded Corners. Rounded corners make selected web page elements look more professional and
visually appealing. Before the introduction of the border-radius property, web developers had to
spend lots of time writing lengthy code to round off an element's corners.
Text and Box Shadows. CSS3 features built-in support for text and box shadows, so web
designers can easily apply shadowing to different text sections and even easily define the
shadow's color, angle, and blur level.
Page 49
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
Difference between CSS and CSS3
CSS CSS3
Year
1996 2005
Released
No support for
modern browsers,
Browser but it still works on Supported fully by all
Support older versions of modern browsers
Explorer or
Chrome
Compatibility
Not compatible Backward compatible with
Between
with CSS3 CSS
Versions
Page 50
Dr. Vamshi Krishna K
Associate Professor, Dept. of CSE, KHIT, Guntur
[email protected], 8143260297
It provides average
It offers fast, excellent
performance and
Performance performance and doesn’t
requires high
use as much memory
memory usage
Page 51