WT & Ecommerce Unit II
WT & Ecommerce Unit II
HTML
1. Explain the working of frames with example.
2. What is HTML? Explain versions of HTML and basic tags of HTML with example.
3. Explain the working of Image tag with example.
4. Explain internal and external hyperlinking with example.
5. Explain <from> tag with example.
6. Explain <table> tag with example.
7. Explain any 8 HTML tags.
8. How can we create hyperlink in a Web Page? Write step to apply Hyperlink Targets to a
frame.
9. Write short note on the following-
Frame
HTML Control
What is HTML
HTML is an acronym which stands for Hyper Text Markup Language which is used for creating web pages and
web applications. Let's see what is meant by Hypertext Markup Language, and Web page.
Hyper Text: HyperText simply means "Text within Text." A text has a link within it, is a hypertext. Whenever you
click on a link which brings you to a new webpage, you have clicked on a hypertext. HyperText 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.
Web Page: A web page is a document which is commonly written in HTML and translated by a web browser. A
web page can be identified by entering an URL. A Web page can be of the static or dynamic type. With the help of
HTML only, we can create static web pages.
Hence, HTML is a markup language which is used for creating attractive web pages with the help of styling, and
which looks in a nice format on a web browser. An HTML document is made of many HTML tags and each HTML
tag contains different content.
1. <!DOCTYPE>
2. <html>
3. <head>
4. <title>Web page title</title>
5. </head>
6. <body>
7. <h1>Write Your First Heading</h1>
8. <p>Write Your First Paragraph.</p>
9. </body>
10. </html>
Test it Now
Description of HTML Example
<!DOCTYPE>: It defines the document type or it instruct the browser about the version of HTML.
<html > :This tag informs the browser that it is an HTML document. Text between html tag describes the web
document. It is a container for all other elements of HTML except <!DOCTYPE>
<head>: It should be the first element inside the <html> element, which contains the metadata(information about
the document). It must be closed before the body tag opens.
<title>: As its name suggested, it is used to add title of that HTML page which appears at the top of the browser
window. It must be placed inside the head tag and should close immediately. (Optional)
<body> : Text between body tag describes the body content of the page that is visible to the end user. This tag
contains the main content of the HTML document.
<h1> : Text between <h1> tag describes the first level heading of the webpage.
<p> : Text between <p> tag describes the paragraph of the webpage.
Tim Berners-Lee is known as the father of HTML. The first available description of HTML was a document called
"HTML Tags" proposed by Tim in late 1991. The latest version of HTML is HTML5, which we will learn later in
this tutorial.
HTML Versions
Since the time HTML was invented there are lots of HTML versions in market, the brief introduction about the
HTML version is given below:
HTML 1.0: The first version of HTML was 1.0, which was the barebones version of HTML language, and it was
released in1991.
HTML 2.0: This was the next version which was released in 1995, and it was standard language version for website
design. HTML 2.0 was able to support extra features such as form-based file upload, form elements such as text box,
option button, etc.
HTML 3.2: HTML 3.2 version was published by W3C in early 1997. This version was capable of creating tables
and providing support for extra options for form elements. It can also support a web page with complex
mathematical equations. It became an official standard for any browser till January 1997. Today it is practically
supported by most of the browsers.
HTML 4.01: HTML 4.01 version was released on December 1999, and it is a very stable version of HTML
language. This version is the current official standard, and it provides added support for stylesheets (CSS) and
scripting ability for various multimedia elements.
HTML5 : HTML5 is the newest version of HyperText Markup language. The first draft of this version was
announced in January 2008. There are two major organizations one is W3C (World Wide Web Consortium), and
another one is WHATWG( Web Hypertext Application Technology Working Group) which are involved in the
development of HTML 5 version, and still, it is under development.
Features of HTML
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.
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.
Technically <!DOCTYPE > is not a tag/element, it just an instruction to the browser about the document type. It is a
null element which does not contain the closing tag, and must not include any content within it.
Actually, there are many type of HTML e.g. HTML 4.01 Strict, HTML 4.01 Transitional, HTML 4.01 Frameset,
XHTML 1.0 Strict, XHTML 1.0 Transitional, XHTML 1.0 Frameset, XHTML 1.1 etc.
The doctype declaration differs between HTML versions. The HTML 5 doctype declaration is given below.
Syntax
<!DOCTYPE html>
Display None
Usage Structural
1. <!DOCTYPE html>
2. <html>
3. <head>
4. <title>This is the title</title>
5. </head>
6. <body>
7. This is the content of the document.
8. </body>
9. </html>
Example 1:
• HTML
<!DOCTYPE html>
<!-- html tag starts here -->
<html>
<body>
<h1>GeeksforGeeks</h1>
<h2><html> Tag</h2>
</body>
</html>
<!-- html tag ends here -->
Output:
<style>,
<meta>,
<link>
<script>
<base>.
The HTML <head> Element
The <head> element is a container for metadata (data about data) and is placed between the <html> tag
and the <body> tag.
HTML metadata is data about the HTML document. Metadata is not displayed.
Metadata typically define the document title, character set, styles, scripts, and other meta information.
The <title> element defines the title of the document. The title must be text-only, and it is shown in the
browser's title bar or in the page's tab.
The content of a page title is very important for search engine optimization (SEO)! The page title is used
by search engine algorithms to decide the order when listing pages in search results.
Example
<!DOCTYPE html>
<html>
<head>
<title>A Meaningful Page Title</title>
</head>
<body>
The content of the document......
</body>
</html>
The <style> element is used to define style information for a single HTML page:
Example
<style>
body {background-color: powderblue;}
h1 {color: red;}
p {color: blue;}
</style>
The HTML <link> Element
The <link> element defines the relationship between the current document and an external resource.
The <link> tag is most often used to link to external style sheets:
Example
The <meta> element is typically used to specify the character set, page description, keywords, author of
the document, and viewport settings.
The metadata will not be displayed on the page, but is used by browsers (how to display content or reload
page), by search engines (keywords), and other web services.
Examples
<meta charset="UTF-8">
Example
<meta charset="UTF-8">
<meta name="description" content="Free Web tutorials">
<meta name="keywords" content="HTML, CSS, JavaScript">
<meta name="author" content="John Doe">
The following JavaScript writes "Hello JavaScript!" into an HTML element with id="demo":
Example
<script>
function myFunction()
{
document.getElementById("demo").innerHTML = "Hello JavaScript!";
}
</script>
The <base> element specifies the base URL and/or target for all relative URLs in a page.
The <base> tag must have either an href or a target attribute present, or both.
There can only be one single <base> element in a document!
Example
Specify a default URL and a default target for all links on a page:
<head>
<base href="https://www.w3schools.com/" target="_blank">
</head>
<body>
<img src="images/stickman.gif" width="24" height="39" alt="Stickman">
<a href="tags/tag_base.asp">HTML base Tag</a>
</body>
Tag Description
<base> Defines a default address or a default target for all links on a page
<body> tag
The <body> element contains all the contents of an HTML document, such as headings, paragraphs,
images, hyperlinks, tables, lists, etc.
Example
<html>
<head>
<title>Title of the document</title>
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
HTML Headings
HTML headings are defined with the <h1> to <h6> tags.
<h1> defines the most important heading. <h6> defines the least important heading.
Example
<h1>Heading 1</h1>
<h2>Heading 2</h2>
<h3>Heading 3</h3>
<h4>Heading 4</h4>
<h5>Heading 5</h5>
<h6>Heading 6</h6>
Search engines use the headings to index the structure and content of your web pages.
Users often skim a page by its headings. It is important to use headings to show the document structure.
<h1> headings should be used for main headings, followed by <h2> headings, then the less important <h3>,
and so on.
Note: Use HTML headings for headings only. Don't use headings to make text BIG or bold.
Bigger Headings
Each HTML heading has a default size. However, you can specify the size for any heading with
the style attribute, using the CSS font-size property:
Example
Example
Following is the example program for the heading alignment in the center.
<!DOCTYPE html>
<html>
<body>
<h1 align="center">Tutorials point </h1>
</body>
</html>
HTML Lists
HTML lists allow web developers to group a set of related items in lists.
Example
An unordered HTML list:
• Item
• Item
• Item
• Item
An ordered HTML list:
1. First item
2. Second item
3. Third item
4. Fourth item
Example
<ul>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>
Example
<ol>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
HTML Links
What is a link?
It is a connection from one web resource to another. A link has two ends, An anchor and direction. The link
starts at the “source” anchor and points to the “destination” anchor, which may be any Web resource such as
an image, a video clip, a sound bite, a program, an HTML document or an element within an HTML
document. You will find many websites or social media platforms ( Like YouTube, and Instagram ) which
link an image to a URL or a text to a URL etc.
This basically means that by using the ‘a’ tag, you can link 1 element of the code to another element that
may/may not be in your code.
Text link : The text link is the visible part of the link.
It is what the viewer clicks on.
Input :
<!DOCTYPE html>
<html>
<h3>Example Of Adding a link</h3>
<body>
<p>Click on the following link</p>
<a href="https://www.geeksforgeeks.org">GeeksforGeeks</a>
</body>
</html>
Output :
Internal Links
An internal link is a type of hyperlink whose target or destination is a resource, such as an image or
document, on the same website or domain.
Input:
<!DOCTYPE html>
<html>
<h3>Internal Link And External Link Example</h3>
<body>
<!--internal link-->
<p>
<a href="https://www.geeksforgeeks.org/html-links/?ref=gcse">
GeeksforGeeks Contribute
</a>
It is a link to the contribute page on GeeksforGeeks' website.
</p>
<!--external link-->
<p>
<a href="https://www.geeksforgeeks.org">
GeeksforGeeks
</a>
It is a link to the GeeksforGeeks website on the World Wide Web.
</p>
</body>
</html>
Output :
<style>
a:link {
color: green;
background-color: transparent;
text-decoration: none;
}
a:visited {
color: pink;
background-color: transparent;
text-decoration: none;
}
a:hover {
color: red;
background-color: transparent;
text-decoration: underline;
}
a:active {
color: yellow;
background-color: transparent;
text-decoration: underline;
}
</style>
It appears within the body text, in content. It appears in website navigation as well as in the content.
It passes SEO authority from other site to your site, It passes SEO authority pages on your site, increasing
increasing your “domain authority”. the “page authority” of specific pages.
It improves the quality of web pages. It helps bots to find other web pages on your site.
It helps in increasing traffic to your website. It also helps in increasing traffic to your website.
HTML Images
Images can improve the design and the appearance of a web page.
Example
<img src="pic_trulli.jpg" alt="Italian Trulli">
Example
<img src="img_girl.jpg" alt="Girl in a jacket">
Example
<img src="img_chania.jpg" alt="Flowers in Chania">
The <img> tag is empty, it contains attributes only, and does not have a closing tag.
Syntax
<img src="url" alt="alternatetext">
Note: When a web page loads, it is the browser, at that moment, that gets the image from a web server and inserts it into
the page. Therefore, make sure that the image actually stays in the same spot in relation to the web page, otherwise your
visitors will get a broken link icon. The broken link icon and the alt text are shown if the browser cannot find the image.
Example
The required alt attribute provides an alternate text for an image, if the user for some reason cannot view it (because of
slow connection, an error in the src attribute, or if the user uses a screen reader).
The value of the alt attribute should describe the image:
Example
<img src="img_chania.jpg" alt="Flowers in Chania">
If a browser cannot find an image, it will display the value of the alt attribute:
Example
<img src="wrongname.gif" alt="Flowers in Chania">
You can use the style attribute to specify the width and height of an image.
Example
<img src="img_girl.jpg" alt="Girl in a jacket" style="width:500px;height:600px;">
Image alignment is used to move the image at different locations (top, bottom, right, left, middle) in our web
pages. We use <img> align attribute to align the image. It is an inline element.
<img align=”left|right|middle|top|bottom”>
<!DOCTYPE html>
<html>
<head>
<style>
img
{
border: 5px solid;
}
</style>
</head>
<body>
<h2>Border Around Image</h2>
<p>Use the border property to add a border to an image:</p>
<img align = "right" src="img_snow.jpg" alt="Snow" style="width:150px">
</body>
</html>
To use an image as a link, just put the <img> tag inside the <a> tag:
Example
<!DOCTYPE html>
<html>
<head>
<style>
img
{
border: 5px solid;
}
</style>
</head>
<body>
<a href="https://www.geeksforgeeks.org">">
<img src="smiley.jpeg" alt="HTML tutorial" style="width:42px;height:42px;">
</a>
</body>
</html>
HTML Tables
HTML tables allow web developers to arrange data into rows and columns.
Example
Example
A simple HTML table:
<table>
<tr>
<th>Company</th>
<th>Contact</th>
<th>Country</th>
</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>
Table Cells
Each table cell is defined by a <td> and a </td> tag.
td stands for table data.
Everything between <td> and </td> are the content of the table cell.
Table Rows
Each table row starts with a <tr> and ends with a </tr> tag.
tr stands for table row.
Table Headers
Sometimes you want your cells to be table header cells. In those cases use the <th> tag instead of the <td> tag:
th stands for table header.
Example
A table with a caption:
<table>
<caption>Monthly savings</caption>
<tr>
<th>Company</th>
<th>Contact</th>
<th>Country</th>
</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>
HTML tables can have headers for each column or row, or for many columns/rows.
<table>
<caption>Monthly savings</caption>
<tr>
<th>Company</th>
<th>Contact</th>
<th>Country</th>
</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>
To avoid having double borders like in the example above, set the CSS border-collapse property to collapse.
This will make the borders collapse into a single border:
Example
table, th, td
{
border: 1px solid black;
border-collapse: collapse;
}
The HTML <table> align Attribute is used to specify the alignment of the table and its content.
Syntax:
<table align="left | right | center">
Example
<table align=”center”>
<caption>Monthly savings</caption>
<tr>
<th>Company</th>
<th>Contact</th>
<th>Country</th>
</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>
If you set a background color of each cell, and give the border a white color (the same as the document background),
you get the impression of an invisible border:
Example
<table align=”center” bgcolor="green">
<caption>Monthly savings</caption>
<tr>
<th>Company</th>
<th>Contact</th>
<th>Country</th>
</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>
Cell Padding
The cell padding is used to define the spaces between the cells and its border. If cell padding
property is not applied then it will be set as the default value.
Example:
th, td {
padding: 20px;
background-color:none;
}
Cell Spacing
The cell spacing is used to define the space between the cells.
Example:
table
{
border-spacing: 30px;
}
To make a cell span over multiple rows, use the rowspan attribute:
To do this, use the colspan attribute on the <th> element:
<table>
<tr>
<th rowspan="2">Name</th>
<th>Age</th>
</tr>
<tr>
<td>Jill</td>
<td>Smith</td>
<td>50</td>
</tr>
<tr>
<td>Eve</td>
<td>Jackson</td>
<td>94</td>
</tr>
</table>
<table>
<tr>
<th colspan="2">Name</th>
<th>Age</th>
</tr>
<tr>
<td>Jill</td>
<td>Smith</td>
<td>50</td>
</tr>
<tr>
<td>Eve</td>
<td>Jackson</td>
<td>94</td>
</tr>
</table>
Name Age
Jill Smith 50
Eve Jackson 94
HTML <frame> tag define the particular area within an HTML file where another HTML web page
can be displayed.
A <frame> tag is used with <frameset>, and it divides a webpage into multiple sections or frames,
and each frame can contain different web pages.
Syntax
1. < frame src = "URL" >
Display Block
Usage Frames
1. <!DOCTYPE html>
2. <html>
3. <head>
4. <title>Frame tag</title>
5. </head>
6. <frameset cols="25%,50%,25%">
7. <frame src="https://www.w3schools.com">
8. <frame src="https://www.w3schools.com">
9. <frame src="https://www.w3schools.com">
10. </frameset>
11. </html>
The HTML <frame> frameborder attribute is used to specify whether or not a border should be
displayed between the frames. For this, we use two values 0 and 1, where 0 defines no border and 1
defines the border.
Syntax
<frame frameborder="1|0">
Attribute Values:
• 0: It has a default value. It sets the border on one state.
• 1: It sets the border off state.
Example:
1. <!DOCTYPE html>
2. <html>
3. <head>
4. <title>Frame tag</title>
5. </head>
6. <frameset cols="25%,50%,25%">
7. <frame src="https://www.w3schools.com" frameborder="1" />
8. <frame src="https://www.w3schools.com" frameborder="1" />
9. <frame src="https://www.w3schools.com" frameborder="1" />
10. </frameset>
11. </html>
Applying Hyperlink target to a frame
Syntax
<iframe src="url" title="description"></iframe>
Use the height and width attributes to specify the size of the iframe.
The height and width are specified in pixels by default:
Example
<iframe src="demo_iframe.htm" height="200" width="300" title="Iframe Example"></iframe>
Example
<!DOCTYPE html>
<html>
<body>
<p><a href="https://www.w3schools.com"
target="iframe_a">W3Schools.com</a></p>
<p>When the target attribute of a link matches the name of an iframe, the link will open
in the iframe.</p>
</body>
</html>