WT Unit-1(Extra)
WT Unit-1(Extra)
Topic Covered
1. Introduction to HTTP
2. HTML
3. Basic HTML Tags
4. Body Tags
5. Coding Style
6. Modifying & Formatting Text
7. Lists
a) Unordered List Definition
b) Ordered List Definition
8. Insert link
a) Linking to another Document
b) Internal Links
c) Email Link
d) Relative and absolute Link
9. Insert Images
a) Referencing Images
b) Clickable Images
c) Image Placement and Alignment
d) Image Size
e) Image margins
f) Image Formats
10. Image Maps
a) Defining an Image Map
b) Advanced Coloring Body Content
11.Working with Tables
a) Basic Tables
b) Table Attributes
c) Table Cell Attributes
d) Table Row Attributes
e) Table Inside of Tables
f) Invisible Spacers
12.Working with Frame
a) Based Pages – Creating Windows
b) Single Window Frames
c) Creating Column Frames
d) Creating Row Frames
e) Creating Complex Frames
HyperText Transfer Protocol (HTTP)
HTTP (Hypertext Transfer Protocol) is a protocol for fetching resources such as HTML
documents. It is the most popular application protocol used in the Internet (or The WEB).
HTTP is an asymmetric request-response client-server protocol as illustrated. An HTTP
client sends a request message to an HTTP server. The server returns a response
message. In other words, the client pulls information from the server (instead of
server pushes information down to the client).
HTTP is a stateless protocol. In other words, the current request does not know what has
Introduction to HTML
HTML stands for HyperText Markup Language. It is used to design web pages
using a markup language.
HTML is the combination of Hypertext and Markup language.
Hypertext defines the link between the web pages. A markup language is used to
define the text document within tag which defines the structure of web pages.
Most markup languages (e.g. HTML) are human-readable. The language uses tags
to define what manipulation has to be done on the text.
HTML is a markup language used by the browser to manipulate text, images, and
other content, in order to display it in the required format.
Characteristics of HTML:
Easy to understand: It is the easiest language you can say, very easy to grasp this
4. Save the file with a suitable name of your choice and .html extension.
5. Open the saved HTML file in your favourite browser (double click on the file, or
right-click – and choose “Open with”).
These are the tags you put at the beginning and end of an
<html> </html>
HTML file.
Elements and Tags:HTML uses predefined tags and elements which tell the browser
how to properly display the content. Remember to include closing tags. If omitted, the
browser applies the effect of the opening tag until the end of the page.
HTML page structure: The basic structure of an HTML page is laid out below. It
contains the essential building-block elements (i.e. doctype declaration, HTML, head, title,
and body elements) upon which all web pages are created.
(i)<DOCTYPE! html>: This is the document type declaration (not technically a tag).
It declares a document as being an HTML document. The doctype declaration is not
case-sensitive.
(ii) <html>: This is called the HTML root element. All other elements are contained
within it.
(iii) <head>: The head tag contains the “behind the scenes” elements for a webpage.
Elements within the head aren’t visible on the front-end of a webpage. HTML
elements used inside the <head> element include:
<style>
<title>
<base>
<noscript>
<script>
<meta>
<link>
( iv) <body>: The body tag is used to enclose all the visible content of a webpage. In
other words, the body content is what the browser will show on the front-end.
Example:This example illustrates the basic structure of HTML code.
HTML Code:
<!DOCTYPE html>
<html>
<head>
<title>Demo Web Page</title>
</head>
<body>
<h1>Introduction to HTML</h1>
<p>HTML stands for Hyper Text Markup Language</p>
</body>
</html>
Output:
Syntax
<body> Place your Content here........</body>
Display Inline
Usage Structural
Example
<!DOCTYPE html>
<html>
<head>
<title>Body Tag</title>
</head>
<body>
<h2>Example of body tag</h2>
<p>This paragraph is written between the body tag</p>
</body>
</html>
Output
Attribute
The following is a list of attributes that are specific to the <body> tag:
Text color It determines the color of the text in the document. (Not
supported in HTML5)
Global Attribute
The <body> attribute supports global attribute in HTML.
Event Attribute
The <body> attribute supports Event attributes in HTML.
Note
The HTML <body> element is found within the <html> tag.
Coding Style
The <code> tag in HTML is used to define the piece of computer code.
During the creation of web pages sometimes there is a need to display computer
programming code.
It could be done by any basic heading tag of HTML but HTML provides a separated tag
which is <code>.
The code tag is a specific type of text which represents computer output. HTML
provides many methods for text-formatting but <code> tag is displayed with fixed letter
size, font, and spacing.
Some points about <code> tag:
It is mainly used to display the code snippet into the web browser.
This tag styles its element to match the computer’s default text format.
The web browsers by default use a monospace font family for displaying <code< tags
element content.
Syntax:
<code> Contents... </code>
Example
<!DOCTYPE html>
<html>
<body>
<pre>
<!--code Tag starts here -->
<code>
#include<stdio.h>
int main() {
printf("Hello Geeks");
}
<!--code Tag starts here -->
</code>
</pre>
</body>
</html>
Output:
Note: <pre> tag is used to display code snippets because it always keeps the text formatting
as it.
HTML Style
The HTML style attribute is used to add styles to an element, such as color, font, size, and
more.
HTML Style Attribute
Setting the style of an HTML element can be done with the style attribute.
Syntax:
<tagname style="property:value;">
The property is a CSS property. The value is a CSS value.
1. Background Color
The CSS background-color property defines the background color for an HTML element.
Example: Set the background color for a page to powderblue
<!DOCTYPE html>
<html>
<body style="background-color:powderblue;">
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
Output
2. Text Color
The CSS color property defines the text color for an HTML element.
Example
<!DOCTYPE html>
<html>
<body>
<h1 style="color:blue;">This is a heading</h1>
<p style="color:red;">This is a paragraph.</p>
</body>
</html>
Output
3. Fonts
The CSS font-family property defines the font to be used for an HTML element.
Example
<!DOCTYPE html>
<html>
<body>
<h1 style="font-family:verdana;">This is a heading</h1>
<p style="font-family:courier;">This is a paragraph.</p>
</body>
</html>
Output
4. Text Size
The CSS font-size property defines the text size for an HTML element.
Example
<!DOCTYPE html>
<html>
<body>
<h1 style="font-size:300%;">This is a heading</h1>
<p style="font-size:160%;">This is a paragraph.</p>
</body>
</html>
Output
5. Text Alignment
The CSS text-align property defines the horizontal text alignment for an HTML element.
Example
<!DOCTYPE html>
<html>
<body>
<h1 style="text-align:center;">Centered Heading</h1>
<p style="text-align:center;">Centered paragraph.</p>
</body>
</html>
Output
6. HTML Headings
HTML headings are defined with the <h1> to <h6> tags.
<h1> defines the most important heading. <h6> defines the least important heading.
HTML headings are titles or subtitles that you want to display on a webpage.
Example
<!DOCTYPE html>
<html>
<body>
<h1>Heading 1</h1>
<h2>Heading 2</h2>
<h3>Heading 3</h3>
<h4>Heading 4</h4>
<h5>Heading 5</h5>
<h6>Heading 6</h6>
</body>
</html>
Output
7. HTML Paragraphs
The HTML <p> element defines a paragraph.
A paragraph always starts on a new line, and browsers automatically add some white
space (a margin) before and after a paragraph.
Example
<!DOCTYPE html>
<html>
<body>
<p>This is a paragraph.</p>
<p>This is a paragraph.</p>
<p>This is a paragraph.</p>
</body>
</html>
Output
This is a paragraph.
This is a paragraph.
This is a paragraph.
8. HTML Horizontal Rules
The <hr> tag defines a thematic break in an HTML page, and is displayed as a horizontal
rule.
The <hr> element is used to separate content (or define a change) in an HTML page.
Example
<!DOCTYPE html>
<html>
<body>
<h1>This is heading 1</h1>
<p>This is some text.</p>
<hr>
<h2>This is heading 2</h2>
<p>This is some other text.</p>
<hr>
<h2>This is heading 2</h2>
<p>This is some other text.</p>
</body>
</html>
Output
<!DOCTYPE html>
<html>
<body>
<p>This is <sup>superscripted</sup>text.</p>
</body>
</html>
HTML Lists
HTML lists allow web developers to group a set of related items in lists.
Types of lists
In Html, we can create three types of Lists:
1. Unordered List <ul>
2. Ordered List <ol>
3. Description List <dl>
Unordered HTML List:An unordered list starts with the <ul> tag. Each list item starts
with the <li> tag.The list items will be marked with bullets (small black circles) by default.
Example
<!DOCTYPE html>
<html>
<body>
<h2>An unordered HTML list</h2>
<ul>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>
</body>
</html>
Output
Ordered HTML List:An ordered list starts with the <ol> tag. Each list item starts with
the <li> tag.The list items will be marked with numbers by default.
Example
<!DOCTYPE html>
<html>
<body>
<h2>An ordered HTML list</h2>
<ol>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
</body>
</html>
Output
HTML Description Lists: HTML also supports 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.
Example
<!DOCTYPE html>
<html>
<body>
<h2>A Description List</h2>
<dl>
<dt>Coffee</dt>
<dd>- black hot drink</dd>
<dt>Milk</dt>
<dd>- white cold drink</dd>
</dl>
</body>
</html>
Output
Nested Lists
Youcan nest a list inside another list, the browser automatically indents nested list levels.
You can nest the same or different kinds of lists.
Example
<!DOCTYPE html>
<html>
<body>
<h2>A Nested List</h2>
<ul>
<li> Software
<ol>
<li> Computer Concept
<li> MS – Windows
<li> MS – Excel
<li> MS - Word
</ol>
<li>Hardware
<ol>
<li> CPU
<li> Input Devices
<li> Output Devices
</ol>
</ul>
</body>
</html>
Output
HTML Links
Links are found in nearly all web pages. Links allow users to click their way from page
to page.
HTML links are hyperlinks.
You can click on a link and jump to another document.
When you move the mouse over a link, the mouse arrow will turn into a little hand.
Note: A link can be an image or any other HTML element.
Syntax
The HTML <a> tag defines a hyperlink. It has the following syntax:
<a href="url">link text</a>
The most important attribute of the <a> element is the href attribute, which indicates the
link's destination.The link text is the part that will be visible to the reader.Clicking on the
link text, will send the reader to the specified URL address.
Example
<!DOCTYPE html>
<html>
<body>
<h1>HTML Links</h1>
<p>
<a href="https://www.google.com/">Visit Google.com!</a>
</p>
</body>
</html>
Output
Example
<!DOCTYPE html>
<html>
<body>
<h2>The target Attribute</h2>
<a href="https://www.google.com/" target="_blank">Visit Google!</a>
<p>If target="_blank", the link will open in a new browser window or tab.</p>
</body>
</html>
Output
Insert Image
The HTML <img> tag is used to embed an image in a web page. Images are linked to web
pages. The <img> tag creates a holding space for the referenced image.The <img> tag is
empty, it contains attributes only, and does not have a closing tag.
The <img> tag has two required attributes:
src - Specifies the path to the image
Syntax
<img src="url" alt="alternatetext">
The src Attribute: The required src attribute specifies the path (URL) to the image.
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
<!DOCTYPE html>
<html>
<body>
<h2>Alternative text</h2>
<p>The alt attribute should reflect the image content, so users who cannot see the image
gets an understanding of what the image contains:</p>
<imgsrc="img_chania.jpg" alt="Flowers in Chania" width="460" height="345">
</body>
</html>
Output
The alt Attribute: 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
<!DOCTYPE html>
<html>
<body>
<h2>Alternative text</h2>
<p>The alt attribute should reflect the image content, so users who cannot see the image
gets an understanding of what the image contains:</p>
<imgsrc="img_chania.jpg" alt="Flowers in Chania" width="460" height="345">
</body>
</html>
Output
Note: If a browser cannot find an image, it will display the value of the alt attribute.
Image Size - Width and Height:You can use the style attribute to specify the width
and height of an image.
Example
<!DOCTYPE html>
<html>
<body>
<h2>Image Size</h2>
<p>Here we specify the width and height of an image with the width and height
attributes:</p>
<imgsrc="img_girl.jpg" alt="Girl in a jacket" width="500" height="600">
</body>
</html>
Output
Note: The width and height attributes always define the width and height of the image in
pixels.
Image as a Link:To use an image as a link, put the <img> tag inside the <a> tag.
Example
<!DOCTYPE html>
<html>
<body>
<h2>Image as a Link</h2>
<p>The image is a link. You can click on it.</p>
<a href="default.asp">
<imgsrc="smiley.gif" alt="HTML tutorial" width= “420” height= “420”>
</a>
</body>
</html>
Output
Images in Another Folder: If you have your images in a sub-folder, you must include
the folder name in the src attribute.
Example
<!DOCTYPE html>
<html>
<body>
<h2>Images in Another Folder</h2>
<p>It is common to store images in a sub-folder. You must then include the folder name in
the src attribute:</p>
<imgsrc="/images/html5.gif" alt="HTML5 Icon" style="width:128px;height:128px;">
</body>
</html>
Output
Common Image Formats:The most common image file types, which are supported in
all browsers (Chrome, Edge, Firefox, Safari, Opera). There are three image formats in
constant use on the net – GIF, JPG and PNG. Each is suited to a specific type of image and
matching your image to the correct format should result in a small, fast – loading graphics.
Saving and exporting into these formats will require a decent image editor.
When you are choosing the format for your image, you should always be
conscious of both the image’s quality and file size.
JPEG Joint Photographic Expert Group image .jpg, .jpeg, .jfif, .pjpeg, .pjp
GIF ( Graphics Interchange Format): GIF format has long been the most
popular on the internet because of its small size. It is ideal for small navigational icons and
simple diagrams and illustration where accuracy is required or graphics with large blocks of
a single colour. GIF’s use a simple technique called LZW compression to reduce the
filesize of images by finding repeated patterns of pixel but this compression never degrades
the image quality.
Features of GIF:
1. GIF files can be saved with a maximum of 256 colours.
2. GIF can be animated which is another reason they became so successful. GIF allow
single – bit transparency which means when you are creating your image, you can
specify one colour to be transparent. This allows the background colours of the web page
to show through the image.
3. GIF can also be interlaced which is a way of saving a graphics so that it loads
progressively – first a blurry, low – detail version is loaded.
Image Map
With HTML image maps, you can create clickable areas on an image.
Image Maps
The HTML <map> tag defines an image map. An image map is an image with clickable
areas. The areas are defined with one or more <area> tags.
How Does it Work?
The idea behind an image map is that you should be able to perform different actions
depending on where in the image you click.
To create an image map you need an image, and some HTML code that describes the
clickable areas.
The Image
The image is inserted using the <img> tag. The only difference from other images is that
you must add a usemap attribute:
<img src="workplace.jpg" alt="Workplace" usemap="#workmap">
The usemap value starts with a hash tag # followed by the name of the image map, and is
used to create a relationship between the image and the image map.
Note: You can use any image as an image map!
Create Image Map
Then, add a <map> element.
The <map> element is used to create an image map, and is linked to the image by using the
required name attribute:
<map name="workmap">
The name attribute must have the same value as the <img>'s usemap attribute .
The Areas
Then, add the clickable areas.
A clickable area is defined using an <area> element.
Shape
You must define the shape of the clickable area, and you can choose one of these values:
rect - defines a rectangular region
circle - defines a circular region
poly - defines a polygonal region
default - defines the entire region
You must also define some coordinates to be able to place the clickable area onto the
image.
Shape="rect"
The coordinates for shape="rect" come in pairs, one for the x-axis and one for the y-axis.
So, the coordinates 34,44 is located 34 pixels from the left margin and 44 pixels from the
top.
The coordinates 270,350 is located 270 pixels from the left margin and 350 pixels from the
top.
Shape="circle"
To add a circle area, first locate the coordinates of the center of the circle:
337,300
vlink − sets a color for visited links − means, for linked text that you have already
clicked on.
HTML Color Coding Methods
There are following three different methods to set colors in your web page −
Color names − You can specify color names directly like green, blue or red.
Hex codes − A six-digit code representing the amount of red, green, and blue that
Here is the list ofStandard 16 Colors names and it is recommended to use them.
#000000
#FF0000
#00FF00
#0000FF
#FFFF00
#00FFFF
#FF00FF
#C0C0C0
#FFFFFF
rgb(0,0,0)
rgb(255,0,0)
rgb(0,255,0)
rgb(0,0,255)
rgb(255,255,0)
rgb(0,255,255)
rgb(255,0,255)
rgb(192,192,192)
rgb(255,255,255)
Example: To set background of an HTML tag by color code using rgb() values.
<!DOCTYPE html>
<html>
<head>
<title>HTML Colors by RGB code</title>
</head>
<body text = "rgb(0,0,255)" bgcolor = "rgb(0,255,0)">
<p>Use different color code for for body and table and see the result.</p>
<table bgcolor = "rgb(0,0,0)">
<tr>
<td>
<font color = "rgb(255,255,255)">This text will appear white on black
background.</font>
</td>
</tr>
</table>
</body>
</html>
HTML Tables
HTML tables allow web developers to arrange data into rows and columns.
The <table> tag defines an HTML table.
Each table row is defined with a <tr> tag.
Each table header is defined with a <th> tag. Each table data/cell is defined with
a <td> tag.
By default, the text in <th> elements are bold and centered.
By default, the text in <td> elements are regular and left-aligned.
Example:
Code
<!DOCTYPE html>
<html>
<head>
<title>HTML Tables</title>
</head>
<body>
<table border = "1">
<tr>
<td>Row 1, Column 1</td>
<td>Row 1, Column 2</td>
</tr>
<tr>
<td>Row 2, Column 1</td>
<td>Row 2, Column 2</td>
</tr>
</table>
</body>
</html>
Output
Here, the border is an attribute of <table> tag and it is used to put a border across all the cells.
If you do not need a border, then you can use border = "0".
Table Heading
Table heading can be defined using <th> tag. This tag will be put to replace <td> tag, which
is used to represent actual data cell. Headings, which are defined in <th> tag are centered and
bold by default.
Example
<!DOCTYPE html>
<html>
<head>
<title>HTML Table Header</title>
</head>
<body>
<table border = "1">
<tr>
<th>Name</th>
<th>Salary</th>
</tr>
<tr>
<td>Ramesh Raman</td>
<td>5000</td>
</tr>
<tr>
<td>Shabbir Hussein</td>
<td>7000</td>
</tr>
</table>
</body>
</html>
Output
Example
<!DOCTYPE html>
<html>
<head>
<title>HTML Table Colspan/Rowspan</title>
</head>
<body>
<table border = "1">
<tr>
<th>Column 1</th>
<th>Column 2</th>
<th>Column 3</th>
</tr>
<tr>
<td rowspan = "2">Row 1 Cell 1</td>
<td>Row 1 Cell 2</td>
<td>Row 1 Cell 3</td>
</tr>
<tr>
<td>Row 2 Cell 2</td>
<td>Row 2 Cell 3</td>
</tr>
<tr>
<td colspan = "3">Row 3 Cell 1</td>
</tr>
</table>
</body>
</html>
Output
Tables Backgrounds
You can set table background using one of the following two ways −
i) bgcolor attribute − You can set background color for whole table or just for one cell.
ii) background attribute − You can set background image for whole table or just for one
cell.
You can also set border color also using bordercolor attribute.
Note − The bgcolor, background, and bordercolor attributes deprecated in HTML5. Do not
use these attributes.
Example
<!DOCTYPE html>
<html>
<head>
<title>HTML Table Background</title>
</head>
<body>
<table border = "1" bordercolor = "green" bgcolor = "yellow">
<tr>
<th>Column 1</th>
<th>Column 2</th>
<th>Column 3</th>
</tr>
<tr>
<td rowspan = "2">Row 1 Cell 1</td>
<td>Row 1 Cell 2</td>
<td>Row 1 Cell 3</td>
</tr>
<tr>
<td>Row 2 Cell 2</td>
<td>Row 2 Cell 3</td>
</tr>
<tr>
<td colspan = "3">Row 3 Cell 1</td>
</tr>
</table>
</body>
</html>
Output
Here is an example of using background attribute. Here we will use an image available in
/images directory.
Example
<!DOCTYPE html>
<html>
<head>
<title>HTML Table Background</title>
</head>
<body>
<table border = "1" bordercolor = "green" background = "/images/test.png">
<tr>
<th>Column 1</th>
<th>Column 2</th>
<th>Column 3</th>
</tr>
<tr>
<td rowspan = "2">Row 1 Cell 1</td>
<td>Row 1 Cell 2</td><td>Row 1 Cell 3</td>
</tr>
<tr>
<td>Row 2 Cell 2</td>
<td>Row 2 Cell 3</td>
</tr>
<tr>
<td colspan = "3">Row 3 Cell 1</td>
</tr>
</table>
</body>
</html>
Output
This will produce the following result. Here background image did not apply to table's
header.
Table Height and Width
You can set a table width and height using width and height attributes. You can specify table
width or height in terms of pixels or in terms of percentage of available screen area.
Example
<!DOCTYPE html>
<html>
<head>
<title>HTML Table Width/Height</title>
</head>
<body>
<table border = "1" width = "400" height = "150">
<tr>
<td>Row 1, Column 1</td>
<td>Row 1, Column 2</td>
</tr>
<tr>
<td>Row 2, Column 1</td>
<td>Row 2, Column 2</td>
</tr>
</table>
</body>
</html>
Output
Table Caption
The caption tag will serve as a title or explanation for the table and it shows up at the top of
the table. This tag is deprecated in newer version of HTML/XHTML.
Example
<!DOCTYPE html>
<html>
<head>
<title>HTML Table Caption</title>
</head>
<body>
<table border = "1" width = "100%">
<caption>This is the caption</caption>
<tr>
<td>row 1, column 1</td><td>row 1, columnn 2</td>
</tr>
<tr>
<td>row 2, column 1</td><td>row 2, columnn 2</td>
</tr>
</table>
</body>
</html>
Output
Output
Nested Tables
You can use one table inside another table. Not only tables you can use almost all the tags
inside table data tag <td>.
Example
Following is the example of using another table and other tags inside a table cell.
<!DOCTYPE html>
<html>
<head>
<title>HTML Table</title>
</head>
<body>
<table border = "1" width = "100%">
<tr>
<td>
<table border = "1" width = "100%">
<tr>
<th>Name</th>
<th>Salary</th>
</tr>
<tr>
<td>Ramesh Raman</td>
<td>5000</td>
</tr>
<tr>
<td>Shabbir Hussein</td>
<td>7000</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
Output
HTML Frame
Frame is used to divide your browser window into multiple sections where each section can
load a separate HTML document.A collection of frames in the browser window is called
frameset. Window is divided into frames like a table: rows & columns.
Creating Frames
To use frames on a page we use <frameset> tag instead of <body> tag. The <frameset> tag
defines, how to divide the window into frames. The rows attribute of <frameset> tag defines
horizontal frames and cols attribute defines vertical frames. Each frame is indicated by
<frame> tag and it defines which HTML document shall open into the frame.
Example
<html>
<head>
<title>Example for Frame</title>
</head>
<frameset cols="20%,*">
<frame src="Ol.html"> 1st FRAME
<frame src="marquee.html"> 2nd FRAME
</frameset>
</html>
The <frameset> Tag Attributes
Following are important attributes of the <frameset> tag −
1. cols: Specifies how many columns are contained in the frameset and the size of each
column. You can specify the width of each column in one of the four ways −
(i) Absolute values in pixels. For example, to create three vertical frames, use cols = "100,
500, 100".
(ii) A percentage of the browser window. For example, to create three vertical frames, use
cols = "10%, 80%, 10%".
(iii) Using a wildcard symbol. For example, to create three vertical frames, use cols =
"10%, *, 10%". In this case wildcard takes remainder of the window.
(iv) As relative widths of the browser window. For example, to create three vertical
frames, use cols = "3*, 2*, 1*".
2. rows:This attribute works just like the cols attribute and takes the same values, but it is
used to specify the rows in the frameset. For example, to create two horizontal frames, use
rows = "10%, 90%". You can specify the height of each row in the same way as explained
above for columns.
3 border: This attribute specifies the width of the border of each frame in pixels. For
example, border = "5". A value of zero means no border.
4 frameborder: This attribute specifies whether a three-dimensional border should be
displayed between frames. This attribute takes value either 1 (yes) or 0 (no). For example
frameborder = "0" specifies no border.
5 framespacing: This attribute specifies the amount of space between frames in a frameset.
This can take any integer value. For exampleframespacing = "10" means there should be
10 pixels spacing between each frames.
various Attributes of <frame> tag
src: is implemented for fetching the HTML file that needs to be loaded in one of the
using, and you can assign values either: 1 (yes) or 0 (no) for it.
marginwidth: facilitates in specifying the frame borders width spacing in the left and
frame borders. But this attribute helps users stop resizing the frames. It is written
something like: noresize = "noresize".
scrolling: is used for activating and deactivating the scroll-bar appearance in your frame
and takes either yes, no, or auto as values to be assigned to it within double-quotes.
Disadvantages of Frame:
Using frames has some disadvantages, these are:
There are small devices (mobile or other smartphones) that cannot cope with the size and
features of frames mostly because these device-screens aren't large enough for making this
splitting up, which is done by <frame>.
Screen resolution has an adverse effect on frames that you will create in some devices.
In many cases, the back button of the browser may also stop working.
In many browsers, frame technology is not supported, and hence HTML script is unable to
Nesting frameset
One of the most popular uses for frames is the "title bar and side menu" method.
frameset is like a "table of documents" with rows and columns. This is done by
nesting framesets, putting one frameset inside another.
Example : Create a page of recipes. The title of the page, "Great Recipes" stays stationary
in a frame at top, a contents list is on the left, and the recipes themselves are in the large box
on the right. As you click on the name of a recipe in the contents list, that recipe appears on
the right.
Code
<HTML>
<HEAD>
<TITLE>Great Recipes</TITLE>
</HEAD>
<FRAMESET ROWS="15%,*">
<FRAME SRC="recipetitlebar.html" NAME=TITLE SCROLLING=NO>
<FRAMESET COLS="20%,*">
<FRAME SRC="recipesidebar.html" NAME=SIDEBAR>
<FRAME SRC="recipes.html" NAME=RECIPES>
</FRAMESET>
<NOFRAMES>
<H1>Great Recipes</H1>
No frames? No Problem! Take a look at our
<A HREF="recipes.html">no-frames</A> version.
</NOFRAMES>
</FRAMESET>
</HTML>
Output
Explanation:
The first <FRAMESET ...> tag says "this frameset will have two rows" (and, implicitly,
only one column, since COLS was left out). The first <FRAME ...> tag puts a document in
the first frame.
The second frame is filled in not by a document but by another frameset. The
second <FRAMESET ...> is creating a "table within a table", or, to be more correct, a
frameset within a frameset.
Targeting other frames
Each frame is given a name using <FRAME NAME="...">. These names uniquely
identify each frame. Using these names, links in other frames can tell the browser which
frame the link targets.
There is some distinction between the frames; for example, one is a table of
contents, and the other presents documents chosen from there. Or, one presents
a question and the other gives the correct answer.
To have a link update another frame, use the TARGET attribute.
<A HREF="other-document.html" TARGET=bar>this other document</A>
Example: Creates a framed page, naming the frames TITLE, SIDEBAR, and MAIN:
<FRAMESET ROWS="15%,*">
<FRAME SRC="tfetitle.html" NAME=TITLE SCROLLING=NO MARGINHEIGHT=1>
<FRAMESET COLS="20%,*">
<FRAME SRC="tfesidebar.html" NAME=SIDEBAR>
<FRAME SRC="tfemain.html" NAME=MAIN>
</FRAMESET>
</FRAMESET>
Explanation:
To target one of these frames, the link should have a TARGET attribute set to the name of
the frame where the linked page should appear.
this code creates a link to tfetacos.html and targets that link to the MAIN frame: