HTML Full Notes
HTML Full Notes
INTRODUCTION TO HTML
Structure-Basics tags.
Unit - III: Lists: Types of lists: Ordered, Unordered– Nesting Lists– Other
tags: Marquee, HR, BR. Links: Hyperlinks – HTML links syntax – HTML
Using Images.
Unit – IV: Tables: HTML Tables- Definition and Usage- Define a HTML
table- Table Cells – Table rows – Table headers – HTML Table tags-
HTML Tables Colspan & Rowspan – HTML Table Padding & Spacing.
Forms: Input, Text fields – the <label> element – the Name Attribute
TABLE OF CONTENTS
UNIT TOPICS PAGE
1.1. Foundations of HTML and Basic elements 7
1.1.1. What is HTML? 7
1.2.A simple HTML Document. 7
[Link] browsers 9
[Link] Page structure 9
1
[Link] History 10
[Link]-Server Model 11
[Link] overview: HTML tags 13
[Link] Structure 16
[Link] tags 17
UNIT OBJECTIVES :
In this unit, learners will have a deep foundations in HTML and its basic elements.
Learners will be able to create a web page using basic commands, and able to apply the same
concept for real time applications in our day to day life.
Example Explained
The <!DOCTYPE html> declaration defines that this document is an HTML5 document
The <html> element is the root element of an HTML page
The <head> element contains meta information about the HTML page
The <title> element specifies a title for the HTML page (which is shown in the browser's title bar or in
the page's tab)
The <body> element defines the document's body, and is a container for all the visible contents, such
as headings, paragraphs, images, hyperlinks, tables, lists, etc.
The <h1> element defines a large heading
The <p> element defines a paragraph
HTML Element
An HTML element is defined by a start tag, some content, and an end tag:
<tagname> Content goes here... </tagname>
The HTML element is everything from the start tag to the end tag:
Year Version
<!DOCTYPE html>
<html>
<head>
<title>This is document title</title>
</head>
<body>
<h1>This is a heading</h1>
<p>Document content goes here </p>
</body>
</html>
Either you can use Try it option available at the top right corner of the code box to
check the result of this HTML code, or let's save it in an HTML file [Link] using your
favorite text editor. Finally open it using a web browser like Internet Explorer or Google
Chrome, or Firefox etc. It must show the following output:
HTML Tags
As told earlier, HTML is a markup language and makes use of various tags to format
the content. These tags are enclosed within angle braces <Tag Name>. Except few
tags, most of the tags have their corresponding closing tags. For example, <html> has
its closing tag</html> and <body> tag has its closing tag </body> tag etc.
Above example of HTML document uses the following tags:
Tag Description
<!DOCTYPE... This tag defines the document type and HTML version.
>
This tag encloses the complete HTML document and mainly
<html> comprises of document header which is represented by
<head>...</head> and document body which is represented by
<body>...</body> tags.
This tag represents the document's header which can keep
<head> other HTML tags like <title>, <link> etc.
The <title> tag is used inside the <head> tag to mention the
<title> document title.
To learn HTML, you will need to study various tags and understand how they behave,
while formatting a textual document. Learning HTML is simple as users have to learn
the usage of different tags in order to format the text or images to make a beautiful
webpage.
World Wide Web Consortium (W3C) recommends to use lowercase tags starting from
HTML 4.
<body>
Document body related tags
</body>
</html>
We will study all the header and body tags in subsequent chapters, but for now let's see
what is document declaration tag.
<!DOCTYPE html>
There are many other declaration types which can be used in HTML document
depending on what version of HTML is being used. We will see more details on this
while discussing
<!DOCTYPE...> tag along with other HTML tags.
Paragraph Tag
The <p> tag offers a way to structure your text into different paragraphs. Each paragraph
of text should go in between an opening <p> and a closing </p> tag as shown below in
the example:
Example
<!DOCTYPE html>
<html>
<head>
<title>Paragraph Example</title>
</head>
<body>
<p>Here is a first paragraph of text.</p>
<p>Here is a second paragraph of text.</p>
<p>Here is a third paragraph of text.</p>
</body>
</html>
Example
<!DOCTYPE html>
<html>
<head>
<title>Line Break Example</title>
</head>
<body>
<p>Hello<br />
You delivered your assignment on time.<br />
Thanks<br />
Mahnaz</p>
</body>
</html>
This will produce the following result:
Hello
You delivered your assignment on time.
Thanks
Mahnaz
Centering Content
You can use <center> tag to put any content in the center of the page or any table cell.
Example
<!DOCTYPE html>
<html>
<head>
<title>Centring Content Example</title>
</head>
<body>
<p>This text is not in the center.</p>
<center>
<p>This text is in the center.</p>
</center>
</body>
</html>
Example
<!DOCTYPE html>
<html>
<head>
<title>Horizontal Line Example</title>
</head>
<body>
<p>This is paragraph one and should be on top</p>
<hr />
<p>This is paragraph two and should be at bottom</p>
</body>
</html>
Preserve Formatting
Sometimes, you want your text to follow the exact format of how it is written in
the HTML document. In these cases, you can use the preformatted tag
<pre>.
Any text between the opening <pre> tag and the closing </pre> tag will
preserve the formatting of the source document.
Example
<!DOCTYPE html>
<html>
<head>
<title>Preserve Formatting Example</title>
</head>
<body>
<pre>
function testFunction( strText
){ alert (strText)
}
</pre>
</body>
</html>
alert (strText)
}
Try using the same code without keeping it inside <pre>...</pre> tags
Nonbreaking Spaces
Suppose you want to use the phrase "12 Angry Men." Here, you would not
want a browser to split the "12, Angry" and "Men" across two lines:
In cases, where you do not want the client browser to break text, you should
use a nonbreaking space entity instead of a normal space. For
example, when coding the "12 Angry Men" in a paragraph, you should use
something similar to the following code:
Example
<!DOCTYPE html>
<html>
<head>
<title>Nonbreaking Spaces Example</title>
</head>
<body>
<p>An example of this technique appears in the movie
"12 Angry Men."</p>
</body>
</html>
Summary:
1) What is HTML? HTML (HyperText Markup Language) is the standard language used to
create and design webpages. It structures web content by defining elements and their
relationships within a document.
2) A Simple HTML Document: An HTML document is composed of elements enclosed in
tags. A basic HTML document includes:
i) <!DOCTYPE html> declaration
ii) <html> element
iii) <head> section with metadata and links to resources
iv) <body> section containing the content visible to users
3) Web Browsers: Web browsers interpret and render HTML documents. They read HTML
code and display the structured content as webpages.
4) HTML Page Structure: HTML documents have a specific structure:
i) <!DOCTYPE html>: Defines the document type and HTML version
ii) <html>: The root element
iii) <head>: Contains meta-information, links to stylesheets, and scripts
iv) <body>: Contains the content of the webpage, such as text, images, and links
5) HTML History: HTML has evolved from its initial version in the early 1990s to HTML5,
which introduced new elements and APIs to support modern web applications and
multimedia.
6) Client-Server Model: In the client-server model, the client (browser) requests HTML
documents from a server. The server responds by sending the requested HTML files, which
the browser then renders.
7) HTML Overview: HTML tags are used to create elements and structure content. Common
tags include:
i) <h1> to <h6>: Headings
ii) <p>: Paragraphs
iii) <a>: Hyperlinks
iv) <img>: Images
v) <div>: Division or section
8) Document Structure and Basic Tags: HTML documents are structured using a
combination of tags. Basic tags and their purposes include:
i) <html>: Encloses the entire document
ii) <head>: Contains meta-information
iii) <title>: Sets the document title
iv) <body>: Contains the content visible to users
v) <h1>, <h2>, <h3>, etc.: Define headings
vi) <p>: Defines paragraphs
vii) <a>: Creates hyperlinks
viii) <img>: Embeds images
Glossary :
HTML (HyperText Markup Language): A standard language used to create and
design webpages, providing structure and organization for web content.
HTML Document: A file containing HTML code, which structures and formats content
for web browsers.
Web Browser: Software application that interprets and displays HTML documents as
webpages (e.g., Chrome, Firefox, Safari).
HTML Tags: Special codes enclosed in angle brackets that define elements within an
HTML document (e.g., <p>, <a>).
HTML Page Structure: The organized layout of an HTML document, including
<!DOCTYPE html>, <html>, <head>, and <body> elements.
DOCTYPE Declaration: <!DOCTYPE html>: A declaration at the beginning of an HTML
document that specifies the version of HTML used.
Client-Server Model: A network architecture where a client (e.g., web browser)
requests resources from a server, which responds with the requested content.
Head Section: The <head> part of an HTML document that contains metadata, links to
stylesheets, and scripts but does not display content directly.
Body Section: The <body> part of an HTML document that contains the visible content
of the webpage, such as text, images, and links.
HTML5: The fifth version of HTML, which includes new elements and APIs for
enhanced functionality and multimedia support.
Headings: HTML tags <h1> to <h6> that define headings of different levels, with <h1>
being the highest and <h6> the lowest.
Paragraph Tag (<p>): An HTML tag used to define paragraphs of text within a
webpage.
Anchor Tag (<a>): An HTML tag used to create hyperlinks that link to other
webpages, files, or locations within the same document.
Image Tag (<img>): An HTML tag used to embed images in a webpage.
Division Tag (<div>): A generic container element used to group and style sections of
content within a webpage.
Metadata: Information about a webpage, such as its title or character set, included in
the <head> section of an HTML document.
HTML Elements: Components of an HTML document defined by tags, including text,
images, and links, which are structured to create webpages.
HTML Attribute: Additional information provided within HTML tags to modify the
behavior or appearance of an element (e.g., href in <a href="...">).
Case Studies:
I. Case Study: Building a Personal Portfolio Page
Objective: Apply HTML skills to create a personal portfolio webpage.
Instructions: Develop a webpage to showcase a personal portfolio. Include
sections such as:
About Me: Use headings and paragraphs to introduce yourself.
Projects: Create a list or table of projects with descriptions and links.
Contact: Provide a form with fields for name, email, and a message.
Include styling for layout and readability.
II. Case Study: Analyzing an Existing Webpage
Objective: Analyze the structure and tags used in a real-world webpage.
Instructions: Choose a well-known website and inspect its HTML source
code using browser developer tools. Analyze:
a. The use of headings, paragraphs, and lists.
b. How images and links are implemented.
c. The structure of the <head> section (meta tags, links to stylesheets).
d. Any embedded multimedia or interactive elements.
III. Case Study: Updating a Legacy HTML Page
Objective: Update an older HTML page to meet modern standards.
Instructions: Take an outdated HTML page and update it to use HTML5
standards. Focus on:
a. Replacing deprecated tags with HTML5 equivalents.
b. Adding semantic HTML5 elements (e.g., <header>, <footer>, <article>).
c. Ensuring proper use of the <!DOCTYPE html> declaration.
IV. Case Study: Client-Server Model in Practice
Objective: Demonstrate a real-world application of the client-server model.
Instructions: Build a simple web application that includes:
a. A front-end HTML page that sends a request to a back-end server.
b. A server-side script (e.g., using [Link] or PHP) that processes the
request and returns a response.
c. Display the server’s response on the client-side webpage.
UNIT II
UNIT 2 - HTML element
Tag Vs Element, HTML Attributes: Core Attributes – Class
Attributes – Internationalization Attributes. HTML formatting (Bold,
talic, Underlined, Strike, Monospaced, Superscript, Subscript,
Inserted, Deleted, Large, Smaller, Grouping Content) HTML Phrase
tags(Emphasized, marked, strong, text abbreviation, Acronym
element, Text Direction, Special terms, Quoting text, Short
Quotations, Text citations, Computer code, Keyboard text,
Programming variables, Address Text), HTML meta tags
TABLE OF CONTENTS
UNIT TOPICS PAGE
2.1. HTML Element 33
2.1.1. Tag Vs Element 34
2.2. HTML Attributes 35
2.2.1. Core Attributes 35
2.2.2. Class Attributes 38
2.2.3. Internationalization Attributes 39
2.4. HTML formatting (Bold, talic, Underlined, 42
Strike, Monospaced, Superscript, Subscript,
2 Inserted, Deleted, Large, Smaller, Grouping
Content)
2.5. HTML Phrase tags(Emphasized, marked, 51
strong, text abbreviation, Acronym element, Text
Direction, Special terms, Quoting text, Short
Quotations, Text citations, Computer code,
Keyboard text, Programming variables, Address
Text)
2.6. HTML meta tags 63
UNIT OBJECTIVES :
In this unit, learners will have a get knowledge about HTML element and
formatting. Learners will be able to innovate a web page using these formatting
commands, and will be able to make the world to turn into their web page by applying
the style of the content.
HTML element
An HTML element is defined by a starting tag. If the element contains other
content, it ends with a closing tag, where the element name is preceded by a
forward slash as shown below with few tags:
So here <p>
</p> is an HTML element, <h1>...</h1> is another HTML element. There
are some HTML elements which don't need to be closed, such as
<img.../>, <hr /> and
<br /> elements. These are known as void elements.
HTML documents consists of a tree of these elements and they specify how
TML documents should be built, and what kind of content should be placed
n
what part of an HTML document.
Example
<!DOCTYPE html>
<html>
<head>
<title>Nested Elements Example</title>
</head>
<body>
<h1>This is <i>italic</i> heading</h1>
<p>This is <u>underlined</u> paragraph</p>
</body>
</html>
<!DOCTYPE html>
<html><head><title>Align Attribute Example</title>
</head><body>
<p align="left">This is left aligned</p>
<p align="center">This is center aligned</p>
<p align="right">This is right aligned</p>
</body>
</html>
This will display the following result:
This is left aligned
This is center aligned
The Id Attribute
The id attribute of an HTML tag can be used to uniquely identify any element
within an HTML page. There are two primary reasons that you might want to
use an id attribute on an element:
If an element carries an id attribute as a unique identifier, it is possible
to identify just that element and its content.
If you have two elements of the same name within a Web page (or
style sheet), you can use the id attribute to distinguish between
elements that have the same name.
We will discuss style sheet in separate tutorial. For now, let's use the id attribute
to distinguish between two paragraph elements as shown below.
Example
<p id="html">This para explains what is HTML</p>
<p id="css">This para explains what is Cascading Style Sheet</p>
<!DOCTYPE html>
<html>
<head>
<title>The title Attribute Example</title>
</head>
<body>
<h3 title="Hello HTML!">Titled Heading Tag Example</h3>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>The style Attribute</title>
</head>
<body>
<p style="font-family:arial; color:#FF0000;">Some text...</p>
</body>
</html>
Some text...
At this point of time, we are not learning CSS, so just let's proceed without bothering
much about CSS. Here, you need to understand what are HTML attributes and how
they can be used while formatting content.
2.2.3 Internationalization Attributes
There are three internationalization attributes, which are available for most (although not
all) XHTML elements.
dir
lang
xml:lang
Value Meaning
rtl Right to left (for languages such as Hebrew or Arabic that are read right to
left)
Example
<!DOCTYPE html>
<html dir="rtl">
<head>
<title>Display Directions</title>
</head>
<body>
This is how IE 5 renders right-to-left directed text.
</body>
</html>
This will produce the following result:
When dir attribute is used within the <html> tag, it determines how text will be presented
within the entire document. When used within another tag, it controls the text's direction
for just the content of that tag.
When dir attribute is used within the <html> tag, it determines how text will be presented
within the entire document. When used within another tag, it controls the text's direction
for just the content of that tag.
<!DOCTYPE html>
<html lang="en">
<head>
<title>English Language Page</title>
</head>
<body>
This page is using English Language
</body>
</html>
Generic Attributes
Here's a table of some other attributes that are readily usable with many of the HTML tags.
Attribute Options Function
We will see related examples as we will proceed to study other HTML tags. For a
complete list of HTML Tags and related attributes please check reference to HTML Tags
List.
Bold Text
Anything that appears within <b>...</b> element, is displayed in bold as shown below:
Example
<!DOCTYPE html>
<html>
<head>
<title>Bold Text Example</title>
</head>
<body>
<p>The following word uses a <b>bold</b> typeface.</p>
</body>
</html>
This will produce the following result:
Italic Text
Anything that appears within <i>...</i> element is displayed in italicized as shown below:
Example
<!DOCTYPE html>
<html>
<head>
<title>Italic Text Example</title>
</head>
<body>
<p>The following word uses a <i>italicized</i> typeface.</p>
</body>
This will produce the following result:
</html>
Example
<!DOCTYPE html>
<html>
<head>
<title>Underlined Text Example</title>
</head>
<body>
<p>The following word uses a <u>underlined</u> typeface.</p>
</body>
</html>
This will produce the following result:
The following word uses an underlined typeface.
Strike Text
Anything that appears within <strike>...</strike> element is displayed with strikethrough,
which is a thin line through the text as shown below:
Example
<!DOCTYPE html>
<html><head><title>Strike Text Example</title></head>
<body>
<p>The following word uses a <strike>strikethrough</strike>
typeface.</p>
</body></html>
This will produce the following result:
The following word uses a strikethrough typeface.
Monospaced Font
The content of a <tt>...</tt> element is written in monospaced font. Most of the fonts
are known as variable-width fonts because different letters are of different widths (for
example, the letter 'm' is wider than the letter 'i'). In a monospaced font, however, each
letter has the same width.
Example
<!DOCTYPE html>
<html><head><title>Monospaced Font Example</title>
</head>
<body>
<p>The following word uses a <tt>monospaced</tt> typeface.</p>
</body></html>
Superscript Text
The content of a <sup>...</sup> element is written in superscript; the font size used is
the same size as the characters surrounding it but is displayed half a character's height
above the other characters.
Example
<!DOCTYPE html>
<html>
<head>
<title>Superscript Text Example</title>
</head>
<body>
<p>The following word uses a <sup>superscript</sup> typeface.</p>
</body>
</html>
This will produce the following result:
Subscript Text
The content of a <sub>...</sub> element is written in subscript; the font size used is the
same as the characters surrounding it, but is displayed half a character's height beneath
the other characters.
Example
<!DOCTYPE html>
<html><head><title>Subscript Text Example</title></head>
<body>
<p>The following word uses a <sub>subscript</sub> typeface.</p>
</body>
</html>
This will produce the following result:
The following word uses a subscript typeface.
Inserted Text
Anything that appears within <ins>...</ins> element is displayed as inserted text.
Example
<!DOCTYPE html>
<html>
<head>
<title>Inserted Text Example</title>
</head>
<body>
<p>I want to drink <del>cola</del> <ins>wine</ins></p>
</body>
</html>
This will produce the following result:
Deleted Text
Anything that appears within <del>...</del> element, is displayed as deleted text.
Example
<!DOCTYPE html>
<html>
<head>
<title>Deleted Text Example</title>
</head>
<body>
<p>I want to drink <del>cola</del> <ins>wine</ins></p>
</body>
</html>
Larger Text
The content of the <big>...</big> element is displayed one font size larger than the rest of
the text surrounding it as shown below:
Example
<!DOCTYPE html>
<html>
<head>
<title>Larger Text Example</title>
</head>
<body>
<p>The following word uses a <big>big</big> typeface.</p>
</body>
</html>
This will produce the following result:
The following word uses a big typeface.
Smaller Text
The content of the <small>...</small> element is displayed one font size smaller than the
rest of the text surrounding it as shown below:
Example
<!DOCTYPE html>
<html>
<head>
<title>Smaller Text Example</title>
</head>
<body>
<p>The following word uses a <small>small</small> typeface.</p>
</body>
</html>
Grouping Content
The <div> and <span> elements allow you to group together several elements to create
sections or subsections of a page.
For example, you might want to put all of the footnotes on a page within a <div> element
to indicate that all of the elements within that <div> element relate to the footnotes. You
might then attach a style to this <div> element so that they appear using a special set of
style rules.
Example
<!DOCTYPE html>
<html>
<head>
<title>Div Tag Example</title>
</head>
<body>
<div id="menu" align="middle" >
<a href="/[Link]">HOME</a> |
<a href="/about/contact_us.htm">CONTACT</a> |
<a href="/about/[Link]">ABOUT</a>
</div>
CONTENT ARTICLES
Actual content goes here
The <span> element, on the other hand, can be used to group inline
elements only. So, if you have a part of a sentence or paragraph which you
want to group together, you could use the <span> element as follows
Example
<!DOCTYPE html>
<html>
<head>
<title>Span Tag Example</title>
</head>
<body>
<p>This is the example of <span style="color:green">span tag</span>
and the <span style="color:red">div tag</span> alongwith CSS</p>
</body>
</html>
This will produce the following result:
This is the example of span tag and the div tag along with CSS
These tags are commonly used with CSS to allow you to attach a style to a section of a page.
Example
<!DOCTYPE html>
<html>
<head>
<title>Emphasized Text Example</title>
</head>
<body>
<p>The following word uses a <em>emphasized</em> typeface.</p>
</body>
</html>
Marked Text
Anything that appears with-in <mark>...</mark> element, is displayed as marked with
yellow ink.
Example
<!DOCTYPE html>
<html>
<head>
<title>Marked Text Example</title>
</head>
<body>
<p>The following word has been <mark>marked</mark> with yellow</p>
</body>
</html>
Strong Text
Anything that appears within <strong>...</strong> element is displayed as important text.
Example
<!DOCTYPE html>
<html>
<head>
<title>Strong Text Example</title>
</head>
<body>
<p>The following word uses a <strong>strong</strong> typeface.</p>
</body>
</html>
This will produce the following result:
The following word uses a strong typeface.
Text Abbreviation
You can abbreviate a text by putting it inside opening <abbr> and closing </abbr> tags. If
present, the title attribute must contain this full description and nothing else.
<!DOCTYPE html>
<html><head><title>Text Abbreviation</title>
</head><body>
<p>My best friend's name is <abbr title="Abhishek">Abhy</abbr>.</p>
</body></html>
Example
Acronym Element
The <acronym> element allows you to indicate that the text between <acronym> and
</acronym> tags is an acronym.
At present, the major browsers do not change the appearance of the content of the
<acronym> element.
Example
<!DOCTYPE html>
<html><head><title>Acronym Example</title>
</head><body>
<p>This chapter covers marking up text in
<acronym>XHTML</acronym>.</p>
</body></html>
Text Direction
The <bdo>...</bdo> element stands for Bi-Directional Override and it is used to override
the current text direction.
Example
<!DOCTYPE html>
<html>
<head>
<title>Text Direction Example</title>
</head>
<body>
<p>This text will go left to right.</p>
<p><bdo dir="rtl">This text will go right to left.</bdo></p>
</body>
</html>
This will produce the following result:
Special Terms
The <dfn>...</dfn> element (or HTML Definition Element) allows you to specify that you
are introducing a special term. It's usage is similar to italic words in the midst of a
paragraph.
Typically, you would use the <dfn> element the first time you introduce a key term. Most
recent browsers render the content of a <dfn> element in an italic font.
Example
<!DOCTYPE html>
<html>
<head>
<title>Special Terms Example</title>
</head>
<body>
<p>The following word is a <dfn>special</dfn> term.</p>
</body>
</html>
Quoting Text
When you want to quote a passage from another source, you should put it
in between<blockquote>...</blockquote> tags.
Text inside a <blockquote> element is usually indented from the left and right edges of
the surrounding text, and sometimes uses an italicized font.
Example
This will produce the following result:
<!DOCTYPE html>
<html>
<head>
<title>Blockquote Example</title>
</head>
<body>
<p>The following description of XHTML is taken from the W3C Web
site:</p>
The following description of XHTML is taken from the W3C Web site:
XHTML 1.0 is the W3C's first Recommendation for XHTML, following on from earlier
work on HTML 4.01, HTML 4.0, HTML 3.2 and HTML 2.0.
Short Quotations
The <q>...</q> element is used when you want to add a double quote within a sentence.
Example
<!DOCTYPE html>
<html>
<head>
<title>Double Quote Example</title>
</head>
<body>
<p>Amit is in Spain, <q>I think I am wrong</q>.</p>
</body>
</html>
Text Citations
If you are quoting a text, you can indicate the source placing it between an opening
<cite>tag and closing </cite> tag
As you would expect in a print publication, the content of the <cite> element is rendered
in italicized text by default.
Example
<!DOCTYPE html>
<html>
<head>
<title>Citations Example</title>
</head>
<body>
<p>This HTML tutorial is derived from <cite>W3 Standard for
HTML</cite>.</p>
</body>
</html>
This will produce the following result:
This HTML tutorial is derived from W3 Standard for HTML.
Computer Code
Any programming code to appear on a Web page should be
placed inside <code>...</code>tags. Usually the content of the <code> element is
presented in a monospaced font, just like the code in most programming books.
Example
<!DOCTYPE html>
<html>
<head>
<title>Computer Code Example</title>
</head>
<body>
<p>Regular text. <code>This is code.</code> Regular text.</p>
</body>
</html>
Keyboard Text
When you are talking about computers, if you want to tell a reader to enter some text,
you can use the <kbd>...</kbd> element to indicate what should be typed in, as in this
example.
Example
<!DOCTYPE html>
<html>
<head>
<title>Keyboard Text Example</title>
</head>
<body>
<p>Regular text. <kbd>This is inside kbd element</kbd> Regular
text.</p>
</body>
</html>
Programming Variables
This element is usually used in conjunction with the <pre> and
<code> elements to indicate that the content of that element
is a variable.
Example
<!DOCTYPE html>
<html>
<head>
<title>Variable Text Example</title>
</head>
<body>
<p><code>[Link]("<var>user-name</var>")</code></p>
</body>
</html>
Program Output
The <samp>...</samp> element indicates sample output
from a program, and script etc. Again, it is mainly used when
documenting programming or coding concepts.
Example
CDOE - ODL [Link].,(CS) – SEMESTER IV
<!DOCTYPE html>
<html><head><title>Program Output Example</title>
</head><body>
<p>Result produced by the program is <samp>Hello World!</samp></p>
</body></html>
Address Text
The <address>...</address> element is used to contain any address.
Example
<!DOCTYPE html>
<html>
<head>
<title>Address Example</title>
</head>
<body>
<address>388A, Road No 22, Jubilee Hills - Hyderabad</address>
</body>
</html>
Attribute Description
http- Used for http response message headers. For example, http-equiv can
equi be used to refresh the page or to set a cookie. Values include content-
v type, expires, refresh and set-cookie.
Specifying Keywords
You can use <meta> tag to specify important keywords
related to the document and later these keywords are used
by the search engines while indexing your webpage for
searching purpose.
Example
Following is an example, where we are adding HTML,
Meta Tags, Metadata as important keywords about the
document.
<!DOCTYPE html>
<html>
<head>
<title>Meta Tags Example</title>
<meta name="keywords" content="HTML, Meta Tags, Metadata" />
</head>
<body>
<p>Hello HTML5!</p>
</body>
</html>
This will produce the following result:
Hello HTML5!
CDOE - ODL [Link].,(CS) – SEMESTER IV
Document Description
You can use <meta> tag to give a short description about the
document. This again can be used by various search engines
while indexing your webpage for searching purpose.
Example
<!DOCTYPE html>
<html>
<head>
<title>Meta Tags Example</title>
<meta name="keywords" content="HTML, Meta Tags, Metadata" />
<meta name="description" content="Learning about Meta Tags." />
</head>
<body>
<p>Hello HTML5!</p>
</body>
</html>
Example
CDOE - ODL [Link].,(CS) – SEMESTER IV
<!DOCTYPE html>
<html><head><title>Meta Tags Example</title>
<meta name="keywords" content="HTML, Meta Tags, Metadata" />
<meta name="description" content="Learning about Meta Tags." />
<meta name="revised" content="Tutorialspoint, 3/7/2014" />
</head>
<body><p>Hello HTML5!</p></body></html>
Document Refreshing
A <meta> tag can be used to specify a duration after which your web page
will keep refreshing automatically.
Example
If you want your page keep refreshing after every 5 seconds then use the
<!DOCTYPE html>
<html>
<head>
<title>Meta Tags Example</title>
<meta name="keywords" content="HTML, Meta Tags, Metadata" />
<meta name="description" content="Learning about Meta Tags." />
<meta name="revised" content="Tutorialspoint, 3/7/2014" />
<meta http-equiv="refresh" content="5" />
</head>
<body>
<p>Hello HTML5!</p>
</body>
</html>
following syntax.
CDOE - ODL [Link].,(CS) – SEMESTER IV
Page Redirection
You can use <meta> tag to redirect your page to any other webpage. You
can also specify a duration if you want to redirect the page after a certain
number of seconds.
Example
Following is an example of redirecting current page to another page after 5
seconds. If you want to redirect page immediately then do not specify
content attribute.
<!DOCTYPE html>
<html>
<head>
<title>Meta Tags Example</title>
<meta name="keywords" content="HTML, Meta Tags, Metadata" />
<meta name="description" content="Learning about Meta Tags." />
<meta name="revised" content="Tutorialspoint, 3/7/2014" />
<meta http-equiv="refresh" content="5;
url=[Link] />
</head>
<body>
<p>Hello HTML5!</p>
</body>
</html>
Setting Cookies
Cookies are data, stored in small text files on your computer and it is
exchanged between web browser and web server to keep track of various
information based on your web application need.
CDOE - ODL [Link].,(CS) – SEMESTER IV
You can use <meta> tag to store cookies on client side and later this
information can be used by the Web Server to track a site visitor.
Example
Following is an example of redirecting current page to another page after 5
seconds. If you want to redirect page immediately then do not specify
content attribute.
<!DOCTYPE html>
<html>
<head>
<title>Meta Tags Example</title>
<meta name="keywords" content="HTML, Meta Tags, Metadata" />
<meta name="description" content="Learning about Meta Tags." />
<meta name="revised" content="Tutorialspoint, 3/7/2014" />
</head>
<body>
<p>Hello HTML5!</p>
</body>
</html>
CDOE - ODL [Link].,(CS) – SEMESTER IV
Summary :
1. HTML Element: Tag vs. Element
Tag: A tag is a piece of HTML code enclosed in angle brackets (e.g., <p>, </p>)
used to define the start and end of an HTML element.
Element: An HTML element consists of a start tag, content, and an end tag (e.g.,
<p>This is a paragraph.</p>). It represents a distinct piece of content or functionality
in the HTML document.
2. HTML Attributes:
Core Attributes: Fundamental attributes available for most HTML elements.
Examples include:
o id: Specifies a unique identifier for an element.
o class: Assigns one or more class names to an element for styling or
scripting.
o style: Applies inline CSS styles to an element.
o title: Provides additional information about an element, typically displayed
as a tooltip.
Class Attributes: Used to define one or more class names for an element,
allowing for grouping and styling multiple elements with the same class.
Internationalization Attributes: Attributes designed to support multiple
languages and regional settings. Examples include:
o lang: Specifies the language of the element's content (e.g., <p lang="en">).
o dir: Defines the text direction (e.g., ltr for left-to-right, rtl for right-to-left).
3. HTML Formatting:
Bold: <b> - Makes text bold.
Italic: <i> - Italicizes text.
Underlined: <u> - Underlines text.
Strike: <s> or <del> - Strikes through text (e.g., <s>strikethrough</s>).
Monospaced: <code> - Displays text in a monospaced font.
Superscript: <sup> - Renders text as superscript (e.g., H<sup>2</sup>O).
Subscript: <sub> - Renders text as subscript (e.g., H<sub>2</sub>O).
CDOE - ODL [Link].,(CS) – SEMESTER IV
Glossary:
1) HTML Tag: A piece of HTML code enclosed in angle brackets (e.g., <p>, </p>) used
to define the start and end of an HTML element.
2) HTML Element: A combination of a start tag, content, and an end tag that
represents a piece of content or functionality within an HTML document (e.g., <p>This
is a paragraph.</p>).
13)Inserted (<ins>): An HTML tag used to mark inserted text, often rendered with an
underline.
14)Deleted (<del>): An HTML tag used to mark deleted text, often rendered with a
strikethrough.
15)Large (<big>): An HTML tag used to increase the text size.
16)Smaller (<small>): An HTML tag used to decrease the text size.
17)Grouping Content (<div>): A block-level container element used to group and style
sections of content.
18)Inline Grouping (<span>): An inline container element used to group and style small
pieces of content.
19)Emphasized (<em>): An HTML tag used to emphasize text, typically rendered as
italic.
20)Marked (<mark>): An HTML tag used to highlight text.
21)Strong (<strong>): An HTML tag used to indicate strong importance, typically
rendered as bold.
22)Text Abbreviation (<abbr>): An HTML tag used to represent an abbreviation or
acronym.
23)Acronym Element (<acronym>): An HTML tag used for acronyms (deprecated in
HTML5; use <abbr> instead).
24)Text Direction (dir attribute): An attribute that defines the text direction, with
possible values like ltr (left-to-right) and rtl (right-to-left).
25)Special Terms (<dfn>): An HTML tag used to mark a term being defined.
26)Quoting Text (<q>): An HTML tag used to define a short inline quotation.
27)Block Quotations (<blockquote>): An HTML tag used to define a longer block
quotation.
28)Text Citations (<cite>): An HTML tag used to represent the title of a cited work.
29)Computer Code (<code>): An HTML tag used to display a single line of computer
code.
30)Keyboard Text (<kbd>): An HTML tag used to represent user input from a keyboard.
CDOE - ODL [Link].,(CS) – SEMESTER IV
8. Problem Solving
Given an HTML document with text that needs to be formatted in various styles
(bold, italic, and monospaced), how would you write the necessary HTML to
achieve this?
How would you ensure that your webpage displays correctly across different
languages and text directions?
Case Studies:
1. Case Study: Developing a Corporate Webpage:
o Objective: Apply HTML formatting, attributes, and meta tags in a real-
world scenario.
o Instructions: Design a corporate webpage that includes:
A header section with navigation links.
Main content sections with formatted text, lists, and highlighted key
information.
A footer with contact details, using the <address> tag.
Proper meta tags for SEO and responsive design.
CDOE - ODL [Link].,(CS) – SEMESTER IV
UNIT III
UNIT 3 - Lists
Types of lists: Ordered, Unordered– Nesting Lists– Other
TABLE OF CONTENTS
UNIT TOPICS PAGE
3.1. Lists 79
3.5.1. Hyperlinks 93
UNIT OBJECTIVES:
3.1. Lists
What is list?
In the context of HTML and web development, a list refers to a way of organizing
and presenting information in a structured format. Lists are fundamental elements
used to group related items together, making content more organized and easier
to read for users.
Example:
```html
<ol>
<li>First item</li>
<li>Second item</li>
<li>Third item</li>
</ol>
```
Renders as:
1. First item
2. Second item
CDOE - ODL [Link].,(CS) – SEMESTER IV
3. Third item
Example:
```html
<ul>
<li>Item A</li>
<li>Item B</li>
<li>Item C</li>
</ul>
```
Renders as:
- Item A
- Item B
- Item C
Example:
```html
<dl>
<dt>Term 1</dt>
<dd>Definition 1</dd>
<dt>Term 2</dt>
<dd>Definition 2</dd>
</dl>
```
Renders as:
CDOE - ODL [Link].,(CS) – SEMESTER IV
```
Term 1
Definition 1
Term 2
Definition 2
```
Lists in HTML are versatile and can be nested within each other to create more
complex structures. They are commonly used for navigation menus, content
summaries, itemized information, and other structured data presentations on web
pages. The choice between ordered, unordered, or definition lists depends on
how you want to organize and present your content to users.
HTML lists allow web developers to group a set of related items in lists.
Example
1. An ordered HTML list:
I. First item
II. Second item
III. Third item
IV. Fourth item
2. An unordered HTML list:
I. Item
II. Item
III. Item
IV. Item
Example
CDOE - ODL [Link].,(CS) – SEMESTER IV
<ol>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
Example
<ul>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>
Utilize the <li> tag to list individual items within the <ul> tag.
The <ul> tag serves as the parent container for <li> tags, establishing
the structure of the list.
Nested lists can be created by placing additional <ul> or <ol>
tags within <li> tags, enabling the creation of hierarchical structures.
Example: Implementation to create a nested unordered list.
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1.0">
<title>Nested Unordered List</title>
<style>
</style>
</head>
<body>
<ul>
<li>
<h2>Frontend</h2>
<ul>
<li>HTML</li>
<li>CSS
<ul>
<li>onsubmit Attribute</li>
<li>onclick Attribute</li>
</ul>
</li>
CDOE - ODL [Link].,(CS) – SEMESTER IV
<li>JavaScript</li>
</ul>
</li>
<li>
<h2>Library/Framework</h2>
<ul>
<li>ReactJS
<ul>
<li>Hoisting</li>
<li>Props</li>
</ul>
</li>
</ul>
</li>
</ul>
</body>
</html>
Output:
CDOE - ODL [Link].,(CS) – SEMESTER IV
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1.0">
<title>Nested Ordered List</title>
<style>
</style>
</head>
<body>
CDOE - ODL [Link].,(CS) – SEMESTER IV
<ol>
<li>Subjects</li>
<ol>
<li>Mathematics</li>
<li>Science</li>
<li>Literature</li>
</ol>
<li>Programming Languages</li>
<ol>
<li>C</li>
<li>Java</li>
<li>Python</li>
<li>Ruby</li>
<li>Swift</li>
</ol>
<li>Computer Science Concepts</li>
<ol>
<li>Data Structures</li>
<li>Algorithms</li>
<li>Operating Systems</li>
<li>Database Management</li>
<li>Networking</li>
</ol>
<li>Web Technologies</li>
<ol>
<li>HTML</li>
<li>CSS</li>
<li>JavaScript</li>
<ol>
CDOE - ODL [Link].,(CS) – SEMESTER IV
<li>React</li>
<li>Angular</li>
<li>Vue</li>
</ol>
<li>Bootstrap</li>
</ol>
</ol>
</body>
</html>
Output:
CDOE - ODL [Link].,(CS) – SEMESTER IV
</marquee>
Attributes :
Methods :
Method Description
Event Handlers :
html
<!DOCTYPE html>
<html>
<head>
<title>Marquee Tag</title>
<style>
.main {
text-align: center;
}
.marq {
padding-top: 30px;
padding-bottom: 30px;
}
.geek1 {
font-size: 36px;
font-weight: bold;
color: white;
padding-bottom: 10px;
}
</style>
</head>
<body>
<div class="main">
<marquee class="marq" bgcolor="Green"
direction="left" loop="">
<div class="geek1">
GeeksforGeeks
CDOE - ODL [Link].,(CS) – SEMESTER IV
</div>
<div class="geek2">
A computer science portal for geeks
</div>
</marquee>
</div>
</body>
</html>
Example
Use the <hr> tag to define thematic changes in the content:
<h1>The Main Languages of the Web</h1>
<p>HTML is the standard markup language for creating Web pages. HTML
describes the structure of a Web page, and consists of a series of elements.
HTML elements tell the browser how to display the content.</p>
<hr>
<hr>
can change HTML content and attribute values. JavaScript can change CSS.
JavaScript can hide and show HTML elements, and more.</p>
Example
Insert single line breaks in a text:
<p>To force<br> line breaks<br> in a text,<br> use the br<br> element.</p>
Note: Use the <br> tag to enter line breaks, not to add space between
paragraphs.
3.5. Links
Links are found in nearly all web pages. Links allow users to click their way from page
to page.
<h2>Relative URLs</h2>
<p><a href="html_images.asp">HTML Images</a></p>
<p><a href="/css/[Link]">CSS Tutorial</a></p>
Output:
Summary :
Lists: Types of Lists
1. Ordered Lists (<ol>):
o Description: Used to create a list of items where the order is significant.
Each item in the list is numbered automatically.
CDOE - ODL [Link].,(CS) – SEMESTER IV
o Example:
html
Copy code
<ol>
<li>First item</li>
<li>Second item</li>
<li>Third item</li>
</ol>
2. Unordered Lists (<ul>):
o Description: Used to create a list of items where the order is not
important. Each item is preceded by a bullet point.
o Example:
html
Copy code
<ul>
<li>Item A</li>
<li>Item B</li>
<li>Item C</li>
</ul>
3. Nesting Lists:
o Description: Lists can be nested within each other to create hierarchical
structures. An ordered list can contain an unordered list, and vice versa.
o Example:
html
Copy code
<ul>
<li>Parent item
<ul>
<li>Child item 1</li>
<li>Child item 2</li>
</ul>
</li>
</ul>
Other Tags
1. Marquee (<marquee>):
CDOE - ODL [Link].,(CS) – SEMESTER IV
html
Copy code
<a href="[Link] Text</a>
3. HTML Links Target Attribute:
o Description: Defines where the linked document will open. Common
values include:
"_self" (default, opens in the same frame)
"_blank" (opens in a new tab or window)
"_parent" (opens in the parent frame)
"_top" (opens in the full body of the window)
o Example:
html
Copy code
<a href="[Link] target="_blank">Open in new tab</a>
4. Absolute URLs vs. Relative URLs:
o Absolute URL: Includes the full path to the resource, including the
protocol (e.g., [Link]
Example: [Link]
o Relative URL: Provides a path relative to the current page or domain,
omitting the protocol and domain.
Example: /page or [Link]
5. HTML Links Using Images:
o Description: Links can be created using images as clickable elements by
nesting an <img> tag within an <a> tag.
o Example:
html
Copy code
<a href="[Link]
<img src="[Link]" alt="Example Logo">
</a>
Glossary :
1. Ordered List (<ol>):
CDOE - ODL [Link].,(CS) – SEMESTER IV
Self-Assessment Questions
1. Lists:
1.1. Ordered and Unordered Lists
What is the primary difference between an ordered list (<ol>) and an unordered
list (<ul>) in HTML?
Write an HTML snippet that demonstrates the use of an ordered list and an
unordered list in the same document.
CDOE - ODL [Link].,(CS) – SEMESTER IV
Activity: Build a webpage that includes both an ordered list and an unordered
list. The ordered list should contain steps for a recipe, and the unordered list
should include ingredients.
Instructions:
1. Use <ol> to create a numbered list for the recipe steps.
2. Use <ul> to list the ingredients with bullet points.
3. Include at least five items in each list.
1.2. Nested Lists
Exercise: Create a webpage with a nested list. The outer list should represent a
category of items, and the inner list should detail subcategories.
Instructions:
1. Use <ul> for the main category list.
2. Inside one of the <li> items, add another <ul> to list subcategories.
3. Ensure at least one nested level with several items.
2. Other Tags:
2.1. Marquee Tag
Activity: Use the <marquee> tag to create a scrolling text effect on a webpage.
Then, replace the <marquee> tag with CSS animations to achieve a similar effect.
Instructions:
1. Implement the scrolling text with <marquee>.
2. Write equivalent CSS to create a scrolling effect using keyframes.
2.2. Horizontal Rule and Line Break
Exercise: Design a webpage that uses <hr> to separate different sections of
content and <br> to format a block of text into multiple lines.
Instructions:
1. Add <hr> tags to separate three different sections of content.
2. Use <br> within a paragraph to break lines and format text properly.
3. Links:
3.1. Basic Hyperlink
CDOE - ODL [Link].,(CS) – SEMESTER IV
Description: Develop a product catalog page for an e-commerce site. Use both
ordered and unordered lists to display product categories and featured products.
Instructions:
1. Create an ordered list of product categories.
2. For each category, use an unordered list to list featured products.
3. Include links for each product that lead to detailed product pages.
4.2. Case Study: Event Page
Description: Create a webpage for an event with a timeline of activities and a list
of speakers. Use nested lists to organize the event schedule.
Instructions:
1. Design an ordered list for the event schedule, with each list item
representing a time slot.
2. Inside each time slot, use an unordered list to detail the activities or
speakers.
3. Add hyperlinks to speakers' names that link to their profiles or biographies.
4.3. Case Study: Personal Portfolio
Description: Build a personal portfolio website with a navigation menu. Include
sections for biography, projects, and contact information. Use links to navigate
between sections and external resources.
Instructions:
1. Create a navigation menu using an unordered list.
2. Link each menu item to different sections of the page using anchor links.
3. Include external links to social media profiles or other relevant sites.
4.4. Case Study: Blog Post Formatting
Description: Format a blog post with proper use of horizontal rules and line
breaks to separate sections and enhance readability.
Instructions:
1. Write a blog post with multiple sections.
2. Use <hr> tags to separate major sections or topics.
3. Apply <br> tags within paragraphs to break lines for better formatting.
CDOE - ODL [Link].,(CS) – SEMESTER IV
UNIT IV
UNIT 4 - Tables
HTML Tables- Definition and Usage- Define a HTML
table- Table Cells – Table rows – Table headers – HTML
Table tags- HTML Tables Colspan & Rowspan – HTML
Table Padding & Spacing.
TABLE OF CONTENTS
UNIT TOPICS PAGE
4.1. HTML Tables 107
4.1.1. Definition and Usage 107
4.1.2. Define a HTML table 107
4.2. Table Cells 108
4 4.3. Table rows 108
4.4. Table headers 109
4.5. HTML Table tags 110
4.6. HTML Tables Colspan & Rowspan 111
4.7. HTML Table Padding & Spacing. 113
CDOE - ODL [Link].,(CS) – SEMESTER IV
UNIT OBJECTIVES :
In this unit, learners are capable to use Tables in creating
webpages. The learners will use the cell alignment for each text effectively
and makes proper arrangements for the text. To make the content
attractive is necessary for the online purchases websites. By doing so the
learners are ready to develop a business and make more profits.
Tables
4.1. HTML Tables
HTML tables allow web developers to arrange data into rows and columns.
</tr>
<tr>
<td>Alfreds Futterkiste</td>
<td>Maria Anders</td>
<td>Germany</td>
</tr>
<tr>
<td>Centro comercial Moctezuma</td>
<td>Francisco Chang</td>
<td>Mexico</td>
</tr>
</table>
[Link] Rows
Each table row starts with a <tr> and ends with a </tr> tag.
tr stands for table row.
Example
CDOE - ODL [Link].,(CS) – SEMESTER IV
<table>
<tr>
<td>Emil</td>
<td>Tobias</td>
<td>Linus</td>
</tr>
<tr>
<td>16</td>
<td>14</td>
<td>10</td>
</tr>
</table>
You can have as many rows as you like in a table; just make sure that the number of
cells are the same in each row.
</tr>
<tr>
<td>16</td>
<td>14</td>
<td>10</td>
</tr>
</table>
By default, the text in <th> elements are bold and centered, but you can change that
with CSS.
Example
Company Contact Country
HTML tables can have cells that span over multiple rows and/or columns.
NAME
CDOE - ODL [Link].,(CS) – SEMESTER IV
APRIL
2022
FIESTA
Note: The value of the colspan attribute represents the number of columns to span.
CDOE - ODL [Link].,(CS) – SEMESTER IV
HTML tables can adjust the padding inside the cells, and also the space between the
cells.
With Padding
With Spacing
Example
th, td {
padding-top: 10px;
padding-bottom: 20px;
padding-left: 30px;
padding-right: 40px;
}
Summary:
HTML Tables: Overview
Basic Structure:
html
Copy code
<table>
<tr>
<th>Header 1</th>
<th>Header 2</th>
</tr>
<tr>
<td>Data 1</td>
<td>Data 2</td>
</tr>
</table>
o Explanation: The <table> element contains the entire table. Inside it, <tr>
elements define rows, <th> elements define header cells, and <td>
elements define data cells.
3. Table Cells:
Table Cells (<td>): Represent individual data points within a table. They are used
inside <tr> elements to display content.
o Example:
html
Copy code
<td>Cell Content</td>
4. Table Rows:
Table Rows (<tr>): Group together a set of table cells in a horizontal line. Each
row is a <tr> element, which contains one or more <td> or <th> elements.
o Example:
CDOE - ODL [Link].,(CS) – SEMESTER IV
html
Copy code
<tr>
<td>Row 1, Cell 1</td>
<td>Row 1, Cell 2</td>
</tr>
5. Table Headers:
Table Headers (<th>): Define the header cells in a table, which are typically bold
and centered by default. They are used to label the columns or rows.
o Example:
html
Copy code
<th>Header 1</th>
Key Tags:
o <table>: The container element for the table.
o <tr>: Defines a row in the table.
o <td>: Defines a data cell within a row.
o <th>: Defines a header cell within a row.
html
Copy code
<td colspan="2">Spans 2 columns</td>
html
Copy code
<td rowspan="2">Spans 2 rows</td>
Padding: Refers to the space inside the cell between the cell border and its
content. In HTML, padding can be controlled using CSS.
o Example:
css
Copy code
td {
padding: 10px;
}
css
Copy code
table {
border-spacing: 5px; /* Space between cells */
}
td {
padding: 10px; /* Space inside cells */
}
Summary:
HTML tables are essential for organizing data in a tabular format, with the ability to
define headers, rows, and cells. Attributes like colspan and rowspan enable more complex
table structures by merging cells across columns or rows. While HTML attributes for
CDOE - ODL [Link].,(CS) – SEMESTER IV
padding and spacing are deprecated, modern practice uses CSS for styling table
layouts.
Glossary :
7. Table Padding:
o Definition: The space between the content of a cell and its border.
Padding can be controlled with CSS using the padding property.
o Example (CSS): td { padding: 10px; }
8. Table Spacing:
o Definition: Historically, cellspacing (space between cells) and cellpadding
(space inside cells) attributes were used to control spacing. These
attributes are now deprecated and handled using CSS.
o Example (CSS): table { border-spacing: 5px; } (for spacing between cells)
9. Table Borders:
o Definition: The lines that outline the edges of the table, rows, and cells.
Borders can be styled using CSS.
o Example (CSS): table { border: 1px solid black; }
10. Table Caption (<caption>):
o Definition: An HTML element that provides a title or description for a
table. It is placed immediately after the <table> tag.
o Example: <caption>Table Title</caption>
11. Table Footer (<tfoot>):
o Definition: An optional HTML element used to group footer content in a
table, such as summary rows or totals.
o Example: <tfoot> ... </tfoot>
12. Table Body (<tbody>):
o Definition: An HTML element that groups the main content of a table,
including the table rows.
o Example: <tbody> ... </tbody>
13. Table Header Group (<thead>):
o Definition: An HTML element that groups header content in a table, such
as column headings.
o Example: <thead> ... </thead>
14. Table Alignment:
CDOE - ODL [Link].,(CS) – SEMESTER IV
o Definition: Refers to the alignment of the table itself and its content,
which can be controlled using CSS properties such as text-align, vertical-
align, and align.
o Example (CSS): td { text-align: center; }
15. Deprecated Attributes:
o Definition: Attributes like cellspacing and cellpadding that were used in HTML
4.01 but are no longer recommended. CSS should be used for layout and
styling.
o Example (HTML): <table cellspacing="5" cellpadding="10"> ... </table>
What are the essential HTML elements required to create a basic table
structure?
Write a simple HTML snippet that includes a table with two rows and two
columns.
How do <td> and <th> elements differ from each other in an HTML table?
Describe how you would use <tr>, <td>, and <th> to create a table with a header
row and two data rows.
2. Table Attributes:
Explain the rowspan attribute and provide an example of a cell that spans across
three rows.
How was cell padding traditionally controlled in HTML tables, and what is the
modern method to achieve this?
Describe how cellspacing and cellpadding were used in older HTML versions and
how CSS is used for table spacing and padding today.
3. Practical Implementation:
Create a table where one cell spans across two columns and another spans
across two rows. Provide the HTML code for this table.
How can you use CSS to style the borders of a table? Provide an example of
CSS rules that apply a solid border to the table, rows, and cells.
Explain how you would center-align the content of a table using CSS.
How do you add a caption to an HTML table? Write an example where a caption
is included to describe the table’s purpose.
Describe the role of <tfoot>, <thead>, and <tbody> elements in organizing table data.
Provide an example where each of these elements is used in a table.
What are some common issues that might arise when using colspan and rowspan
attributes, and how can they be resolved?
How can you ensure that your HTML table is accessible and properly structured
for screen readers?
What are some best practices for designing accessible and responsive tables?
How would you validate an HTML table to ensure it meets web standards?
Practical Exercises
Task: Create an HTML file with a table that includes headers for "Product",
"Price", and "Quantity". Populate the table with three rows of sample data.
Deliverable: An HTML snippet with the table structure and sample data.
Objective: Create a product catalog page for an e-commerce website using HTML
tables to display product information clearly.
Description: Design a table to showcase a list of products. Each product should have
the following details:
Product Name
Description
Price
Availability Status
Requirements:
1. Table Structure:
o The table should have a header row with columns for "Product Name,"
"Description," "Price," and "Availability."
o Include at least five rows of product data.
2. Attributes:
o Use colspan to create a cell that spans across multiple columns for special
announcements or promotions.
o Use rowspan if a product spans multiple rows due to a detailed description.
3. Styling:
CDOE - ODL [Link].,(CS) – SEMESTER IV
o Apply CSS to ensure that the table has a border, padding, and spacing for
readability.
o Highlight the header row with a different background color.
Deliverables:
Objective: Design a timetable for an academic semester using HTML tables to display
class schedules.
Description: Create a table to present a weekly class schedule. The schedule should
include:
Requirements:
1. Table Structure:
o Use <thead> to group the header information (days and time slots).
o Use <tbody> to list the schedule for each time slot and day.
2. Attributes:
o Use colspan for cells that span multiple time slots or days.
o Use rowspan to indicate class durations that span multiple time slots.
3. Styling:
CDOE - ODL [Link].,(CS) – SEMESTER IV
o Use CSS to define table borders, alternating row colors for better
readability, and padding for cell content.
o Ensure the table is responsive for different screen sizes.
Deliverables:
Suggested Readings:
Books:
"HTML and CSS: Design and Build Websites" by Jon Duckett
UNIT V
TABLE OF CONTENTS
UNIT TOPICS PAGE
[Link] iFrames 129
5.1.1. Frameset 129
5.2. Targeted Links 130
5.3. HTML iframe tag 130
5
5.4. Forms: Input, Text fields 131
5.5. the <label> element 133
5.6. the Name Attribute for<input> 135
5.7. HTML Input types 136
CDOE - ODL [Link].,(CS) – SEMESTER IV
UNIT OBJECTIVES:
In this unit, learners will be able to apply frames in developing new
projects. The learners will understand how to develop forms which helps
to create so many apps which are in current trends. By using the forms
the learners will provide security for their project since privacy plays a
major role in the digital world.
Syntax
<iframe src="url" title="description"></iframe>
Tip: It is a good practice to always include a title attribute for the <iframe>. This is used by
screen readers to read out what the content of the iframe is.
Example
<iframe src="demo_iframe.htm" height="200" width="300" title="Iframe
Example"></iframe>
Or you can add the style attribute and use the CSS height and width properties:
Example
CDOE - ODL [Link].,(CS) – SEMESTER IV
Example
<iframe src="demo_iframe.htm" style="border:none;" title="Iframe Example"></iframe>
With CSS, you can also change the size, style and color of the iframe's border:
Example
<iframe src="demo_iframe.htm" style="border:2px solid red;" title="Iframe
Example"></iframe>
Example
<iframe src="demo_iframe.htm" name="iframe_a" title="Iframe Example"></iframe>
An HTML form is used to collect user input. The user input is most often sent to a
server for processing.
Example
First name:
John
Last name:
Doe
Submit
Type Description
All the different input types are covered in this chapter: HTML Input Types.
Text Fields
The <input type="text"> defines a single-line input field for text input.
Example
A form with input fields for text:
<form>
<label for="fname">First name:</label><br>
<input type="text" id="fname" name="fname"><br>
<label for="lname">Last name:</label><br>
<input type="text" id="lname" name="lname">
</form>
This is how the HTML code above will be displayed in a browser:
First name:
dfg
Last name:
cv
CDOE - ODL [Link].,(CS) – SEMESTER IV
Note: The form itself is not visible. Also note that the default width of an input field is
20 characters.
Radio Buttons
The <input type="radio"> defines a radio button.
Radio buttons let a user select ONE of a limited number of choices.
Example
A form with radio buttons:
<p>Choose your favorite Web language:</p>
<form>
<input type="radio" id="html" name="fav_language" value="HTML">
<label for="html">HTML</label><br>
<input type="radio" id="css" name="fav_language" value="CSS">
<label for="css">CSS</label><br>
<input type="radio" id="javascript" name="fav_language" value="JavaScript">
<label for="javascript">JavaScript</label>
</form>
This is how the HTML code above will be displayed in a browser:
CDOE - ODL [Link].,(CS) – SEMESTER IV
HTML
CSS
JavaScript
Checkboxes
The <input type="checkbox"> defines a checkbox.
Checkboxes let a user select ZERO or MORE options of a limited number of choices.
Example
A form with checkboxes:
<form>
<input type="checkbox" id="vehicle1" name="vehicle1" value="Bike">
<label for="vehicle1"> I have a bike</label><br>
<input type="checkbox" id="vehicle2" name="vehicle2" value="Car">
<label for="vehicle2"> I have a car</label><br>
<input type="checkbox" id="vehicle3" name="vehicle3" value="Boat">
<label for="vehicle3"> I have a boat</label>
</form>
This is how the HTML code above will be displayed in a browser:
I have a bike
I have a car
I have a boat
Example
A form with a submit button:
<form action="/action_page.php">
<label for="fname">First name:</label><br>
<input type="text" id="fname" name="fname" value="John"><br>
<label for="lname">Last name:</label><br>
<input type="text" id="lname" name="lname" value="Doe"><br><br>
<input type="submit" value="Submit">
</form>
This is how the HTML code above will be displayed in a browser:
First name:
John
Last name:
Doe
Submit
Example
This example will not submit the value of the "First name" input field:
<form action="/action_page.php">
<label for="fname">First name:</label><br>
<input type="text" id="fname" value="John"><br><br>
<input type="submit" value="Submit">
</form>
Xeric
This chapter describes the different types for the HTML <input> element.
Example
<form>
<label for="fname">First name:</label><br>
<input type="text" id="fname" name="fname"><br>
<label for="lname">Last name:</label><br>
<input type="text" id="lname" name="lname">
</form>
This is how the HTML code above will be displayed in a browser:
First name:
Last name:
Example
<form>
<label for="username">Username:</label><br>
<input type="text" id="username" name="username"><br>
<label for="pwd">Password:</label><br>
<input type="password" id="pwd" name="pwd">
</form>
This is how the HTML code above will be displayed in a browser:
Username:
Password:
Summary :
HTML iFrames and Framesets
1. iFrames (Inline Frames):
html
Copy code
<iframe src="url" width="width" height="height" frameborder="border"></iframe>
Attributes:
o src: URL of the page to display within the iframe.
o width and height: Dimensions of the iframe.
o frameborder: Specifies whether to display a border around the iframe
(deprecated in HTML5, use CSS instead).
o sandbox: Provides security features to restrict the iframe's capabilities (e.g.,
sandbox="allow-scripts").
2. Frameset (Deprecated):
html
Copy code
<frameset cols="25%, 75%">
<frame src="[Link]">
CDOE - ODL [Link].,(CS) – SEMESTER IV
<frame src="[Link]">
</frameset>
Attributes:
o cols: Specifies the width of each frame.
o rows: Specifies the height of each frame.
Note: The <frameset> element is deprecated in HTML5 and should be avoided in
favor of using <iframe> or CSS for layout purposes.
3. Targeted Links:
Definition: Targeted links involve using the target attribute in anchor tags to
specify where the linked document should be opened.
Syntax:
html
Copy code
<a href="url" target="frameName">Link Text</a>
Attributes:
o target="_blank": Opens the link in a new tab or window.
o target="_self": Opens the link in the same frame (default).
o target="_parent": Opens the link in the parent frame.
o target="_top": Opens the link in the full window.
Forms in HTML
1. Input Fields:
Definition: Input fields are elements within a form where users can enter data.
They are created using the <input> tag.
Types: Various input types control the behavior and appearance of the input
field.
o text: A single-line text field.
CDOE - ODL [Link].,(CS) – SEMESTER IV
html
Copy code
<label for="inputId">Label Text</label>
<input type="text" id="inputId" name="inputName">
Attributes:
o for: Associates the label with a specific form control by matching the id of
the control.
Definition: The name attribute specifies the name of the input field, which is used
to identify the data when the form is submitted.
Syntax:
html
Copy code
<input type="text" name="username">
Definition: The type attribute of the <input> element defines the type of data the
field will accept and affects the input's appearance and behavior.
Common Input Types:
o text: Standard text input.
o password: Input for passwords.
o email: Input for email addresses with validation.
o number: Input for numerical values with optional restrictions.
o date: Input for selecting dates.
o file: Allows users to upload files.
o button: Creates a clickable button.
o submit: Submits the form data to the server.
o reset: Resets the form fields to their default values.
Glossary :
HTML iFrames
1. iFrame (<iframe>):
o Definition: An HTML element used to embed another HTML document
within the current document. It allows for displaying external content on a
webpage.
o Attributes:
src: URL of the document to display in the iframe.
width: Specifies the width of the iframe.
height: Specifies the height of the iframe.
frameborder: (Deprecated) Specifies whether to display a border
around the iframe.
sandbox: Restricts the iframe’s capabilities for security purposes.
2. Sandbox Attribute:
o Definition: An attribute for <iframe> that enables additional security
features by limiting the iframe's functionality.
o Example: sandbox="allow-scripts"
CDOE - ODL [Link].,(CS) – SEMESTER IV
Frameset (Deprecated)
3. Frameset (<frameset>):
o Definition: An HTML element used in earlier versions of HTML to create
multiple frames on a single webpage, allowing different HTML documents
to be displayed in separate sections of the browser window.
o Attributes:
cols: Defines the width of the frames in the frameset.
rows: Defines the height of the frames in the frameset.
4. Frame (<frame>):
o Definition: A child element of <frameset> that specifies the content to be
displayed in each frame.
o Attributes:
src: URL of the document to display in the frame.
Targeted Links
Forms
6. Form (<form>):
o Definition: An HTML element that contains input fields and controls to
collect user data and submit it to a server.
o Attributes:
CDOE - ODL [Link].,(CS) – SEMESTER IV
Self-Assessment Questions
1. iFrames:
2. Framesets (Deprecated):
3. Targeted Links:
6. How can the target attribute in a link be used to open the linked document in
a new window or tab?
o Explain the value _blank and its effect on link behavior.
7. Write an example of a hyperlink that opens the linked page in the parent
frame of a frameset.
CDOE - ODL [Link].,(CS) – SEMESTER IV
Forms:
4. Input Fields:
8. What are the different types of input fields available in HTML forms?
Provide examples of at least five different types and their use cases.
o Examples could include text, password, email, checkbox, and radio.
9. Write an HTML form that includes a text input field, a password field, and a
submit button.
o Ensure each field has a name attribute and the form includes the action and
method attributes.
10. What is the purpose of the <label> element in a form? How does it improve
accessibility?
o Describe how <label> enhances user experience and accessibility, and
provide an example of its usage with an <input> field.
11. Create a label for a text input field with the id username and provide a
descriptive label text.
o Write the HTML code including the for attribute.
14. How does the type attribute of an <input> element affect the behavior and
appearance of the input field?
o Describe the differences between text, password, number, and email input
types.
15. Write an HTML form that includes fields for name, email, and age, using
appropriate input types for each field.
o Ensure the name and type attributes are set correctly for each input.
Practical Exercises
1. iFrames:
2. Framesets:
Task: Create a simple HTML page using <frameset> to display two pages, one on
the top and one on the bottom. The top frame should be 25% of the height and
the bottom frame 75%.
Deliverable: An HTML file with <frameset> and <frame> code.
3. Forms:
Task: Design a registration form with fields for first name, last name, email
address, password, and a submit button. Use appropriate input types and include
<label> elements.
Deliverable: An HTML file with the complete form and associated labels.
CDOE - ODL [Link].,(CS) – SEMESTER IV
1. iFrames
Objective: Practice using the <iframe> element to embed external content within a
webpage.
Task:
o Create an HTML file that includes an iframe embedding a Google Map
showing a specific location of your choice (e.g., a famous landmark).
o Set the iframe to be 600 pixels wide and 400 pixels high.
o Add a border around the iframe using CSS for better visibility.
Deliverable: An HTML file with the iframe code and a CSS file for styling.
2. Framesets (Deprecated)
Objective: Understand the use of <frameset> and <frame> elements (note: for
educational purposes as <frameset> is deprecated).
Task:
CDOE - ODL [Link].,(CS) – SEMESTER IV
o Create an HTML file with a frameset that divides the window into two
vertical frames. The left frame should occupy 30% of the width and the
right frame 70%.
o Include different HTML documents in each frame.
Deliverable: An HTML file using <frameset> and <frame> elements.
3. Targeted Links
4. Forms
Case Studies
Objective: Design a product page for an e-commerce site using HTML tables and
forms.
Description:
Create a webpage that displays a product with details such as product name,
description, price, and availability using HTML tables.
Requirements:
1. Product Table:
o Use a table to display product details with headers for "Name,"
"Description," "Price," and "Availability."
2. iFrame:
o Embed a related video or review in an iframe on the page.
3. Form:
o Include a form with a quantity input field and a submit button to simulate
adding the product to a shopping cart.
Deliverables:
CDOE - ODL [Link].,(CS) – SEMESTER IV
An HTML file with the product details table, iframe, and form.
Description:
Design a registration form that includes fields for personal information, contact
details, and registration preferences.
Include form elements such as text fields, email fields, radio buttons,
checkboxes, and a submit button.
Use appropriate form validation attributes to ensure data is entered correctly.
Requirements:
1. Form Fields:
o Include fields for first name, last name, email address, phone number, and
registration preferences.
2. Validation:
o Use HTML5 validation attributes to ensure required fields are filled out and
data is in the correct format.
3. Submission:
o Set up the form to submit to a specific URL or server-side script.
Deliverables:
Suggested Readings:
Books