Unit I
Unit I
Unit I
INTRODUCTION:
HTML, which stands for HyperText Markup Language, is the predominant markup language for
web pages.
A markup language is a set of markup tags, and HTML uses markup tags to describe web pages.
HTML is an interpreted programming language.
HTML is written in the form of HTML elements consisting of "tags" surrounded by angle brackets
(<html>) within the web page content. HTML tags normally come in pairs.
The first tag in a pair is the start tag; the second tag is the end tag (they are also called opening tags
and closing tags respectively).
The purpose of a web browser is to read HTML documents and display them as web pages.
The browser does not display the HTML tags, but uses the tags to interpret the content of the page.
HTML elements form the building blocks of all websites.
HTML allows images and objects to be embedded and can be used to create interactive forms.
It provides a means to create structured documents by denoting structural semantics for text such
as headings, paragraphs, lists, links, quotes and other items.
It can embed scripts in languages such as JavaScript which affect the behavior of HTML webpages.
HTML can also be used to include Cascading Style Sheets (CSS) to define the appearance and
layout of text and other material.
HTML tags are not case sensitive.
UNDERSTANDING HTML:
A web page is a plain text file encoded using Hypertext Markup Language (HTML).
HTML means word by word:
Hypertext – Text that helps to jump from document to document.
Markup – Tags that apply layout and formatting conventions to plain text
Language – A reference to the fact that HTML is considered as a programming language.
WORKING OF HTML:
o The code within an HTML file is enclosed in tags.
o These tags indicate where the formatting should be applied, how the layout should appear, what
pictures should be placed in certain location.
Ex:
<i> Everything </i> is on sale.
This is a two- sided tag which encloses text between opening and closing tags.
o A person may connect to Internet by using a dial-up modem at speeds ranging 2400bps –
28.8 kbps.
o The text files transfer much faster than binary files.
o Instead of sending the formatted pages over the Internet, they created an application a web
browser that could interpret plain text code (HTML tags) as formatting instructions.
o The text could be sent quickly and efficiently in plain text format and then be processed and
displayed attractively and graphically on the local PC.
o The <img> tag was created to refer to a graphic stored on a server.
o It is one-sided meaning it does not have a closing tag, and it takes arguments.
o An argument is a text within the tag that contains information about how the tag should behave.
Ex: <img src=”tree.gif”>
o Where src = argument and specifies that the file tree.gif be displayed.
o Many tags accept arguments, either optional or required.
o With HTML, we can also create hyperlinks from one page to another.
o When a visitor to a web site clicks a hyperlink, the web browser loads the referenced page or
jumps to a marked section within the same page.
o To create hyperlinks the tag used is <a> a two sided tag.
Ex: <a href=”index.html”> Click here </a>
o Plain text is marked up with tags that indicate where elements such as formatting, hyperlinks and
graphics should be placed, and a web browser interprets those tags and displays the page in its
formatted state.
EX: <!doctype html>
<html>
<!- - Created 2011-01-01- - >
<head>
<title>Sample</title>
</head>
<body>
<p>Hello World! </p>
</body>
</html>
HTML ELEMENTS
An HTML element is everything from the start tag to the end tag:
HTML Attributes
HTML elements can have attributes
Attributes provide additional information about an element
Attributes are always specified in the start tag
Attributes come in name/value pairs like: name="value"
Attribute Example
HTML links are defined with the <a> tag. The link address is specified in the href attribute:
Example
2
Always Quote Attribute Values:
Attribute values should always be enclosed in quotes. Double style quotes are the most common, but
single style quotes are also allowed.
Use Lowercase Attributes:
Attribute names and attribute values are case-insensitive. However, the World Wide Web
Consortium (W3C) recommends lowercase attributes/attribute values in their HTML 4
recommendation.
Tag Description
Example:
<html>
<head>
<title> mcas college</title>
</head>
<body>
<b> SACHIN</b> </br>
<i> ABDULKALAM </i> </br>
<big> GANDHIJI</big> </br>
3
H<sub>2</sub>SO<sub>4 </sub> </br>
AREA OF SQUARE:A<sup>2</sup> </br>
<em> hello</em> </br>
</body>
</html>
OUTPUT:
Caution: Not all search engines refer to <Meta> tags. Google does not for example it indexes only
the text contained in the <body> area.
Ex: <Meta name =” keywords” content =” flowers, vegetables”/>
The <Meta> tag in this code is a single-sided tag that contains two arguments:
name = and content=.
The values for each of those arguments are contained in quotation marks and ends with a
space and a slash (/).
4
Tips: The <meta> tag can also be used to redirect visitors to another page.
Creating headings:
Headings are used on web pages and used in printed documents.
They breakup text into sections.
The HTML standard defines six levels of headings <h1> through <h6>
<h1> defines the largest heading and <h6> defines the smallest heading.
There are no sizes or fonts assigned to the heading tags.
The lower heading styles can be used for special purpose, such as tagline or mottos
IIIII
Most web pages use proportional fonts are attractive and professional looking. A monospace font is
one in which each letter occupies the same amount of horizontal space, regardless of its actual size and
shape.
Common uses for monospace text include:
Lines of programming code.
Text that you are instructing a user to type.
ASCII art (artwork created by using text characters)
To apply monospace you can use any of these tags.
Tag Description
<tt> TyperWriter text
<tbd> Keyboard
5
<code> Code
<samp> Sample
Monospace don’t work with ASCII art. ASCII is a code set representing English character as
numbers. 128 characters in the standard ASCII character set and 256 in the extended character set.
The problem with displaying ASCII art on a page is that a web browser removes any extra spaces.
Each line in the graphics has a number of blank spaces at the beginning.
Use the <pre> tag, which stands for “preformatted”. The <pre> tag not only displays the text in
mono space, but also preserves all the spaces and line breaks.
One common use for the <pre> tag is in poetry achieves.
Ex:1
` <p> 1. Loging box <br/>
2. <tt> premium </tt><br/>
3. Click in the password box <br/>
4. Type <tt> Customer </tt> <p/>
Ex:2
<p> 1. Loging box <br/>
2. <tt> <b> premium </b></tt><br/>
3. Click in the password box <br/>
4. Type <tt> <b> Customer </b> </tt> <p/>
4. UNORDEREDLIST&NESTEDAND ORDERLIST
To create several types of lists with HTML bulleted lists numbered lists and definition lists.
We know how to create nested lists within lists, how to use styles to specify the bullet character or
numbering style and how to create horizontal lines that further helps to divide a page.
TYPE OF LIST:
The most common HTML lists are ordered and unordered lists
6
<dt> Defines an item in a definition list
<dd> Defines a description of an item in a definition list
Syntax of order list:
<ol>
<li>text </li>
<li>text</li>
</ol>
optional arguments:
type= specifies the number style; valid values are decimal, decimal leading zero, lower
roman ,upper-roman, lower-alpha, upper-alpha, and none.
Start= specifies the starting number ,deprecated
ORDERED LIST:
An ordered list starts with the <ol> tag. Each list item starts with the <li> tag.The list items are
marked with numbers.
EXAMPLE
<html>
<head>
<title> mcasCOLLEGE</title>
</head>
<body>
<ol>
<li>Coffee</li>
<li>Milk</li>
<li>Tea</li>
</ol>
</body></html>
7
DIFFERENT TYPE OF ORDER LIST:
EXAMPLE:
<html>
<head>
<title> mcasCOLLEGE</title>
</head>
<body>
<h4>Numbered list:</h4>
<ol>
<li>Apples</li>
<li>Bananas</li>
<li>Lemons</li>
<li>Oranges</li>
</ol>
<h4>Letters list:</h4>
<ol type="A">
<li>Apples</li>
<li>Bananas</li>
<li>Lemons</li>
<li>Oranges</li>
</ol>
<li>Oranges</li>
</ol>
</body>
</html>
8
OUTPUT:
NESTED LIST
Lists can also be nested within one another. A bulleted list embedded within a numbered list. The
bulleted list is placed within one of the <li> tags within the numbered <ol> list.
EX:
<ol> <li> Year : 2011 </li>
1. Year: 2011
<li> Months
2. Months
<ul> <li> January </li>
January
<li> February </li>
February
<li> March </li>
March
3. Days
</ul><\li> <li> Days
Saturday
<ul> <li>Saturday<\li>
Sunday
<li> Saturday <\li>
</ul> </li></ol>
EXAMPLE PROGRAM
<html>
<head>
<title>MCAS COLLEGE</title>
</head>
<body>
<ol>
<li>Coffece</li>
<li>Tea</li>
<ul> <li>Black tea</li>
<li>Green tea</li>
</ul>
<li> Milk</li>
9
</ol>
</body> </html>
OUTPUT
An unordered list starts with the <ul> tag. Each list item starts with the <li> tag.The list items are
marked with bullets (typically small black circles).
<html>
<head>
<title> MCAS COLLEGE</title>
</head>
<body>
<ul>
<li>Coffee</li>
<li>Milk</li>
<li>Tea</li>
</ul>
</body>
</html>
10
DIFFERENCE TYPE OF UNORDERED LIST
<html>
<head>
<title> MUTHAYAMMAL COLLEGE</title>
</head>
<body>
<h4>Disc bullets list:</h4>
<ul type="disc">
<li>Apples</li>
<li>Bananas</li>
<li>Lemons</li>
<li>Oranges</li>
</ul>
<h4>Circle bullets list:</h4>
<ul type="circle">
<li>Apples</li>
<li>Bananas</li>
<li>Lemons</li>
<li>Oranges</li>
11
</ul>
<h4>Square bullets list:</h4>
<ul type="square">
<li>Apples</li>
<li>Bananas</li>
<li>Lemons</li>
<li>Oranges</li>
</ul>
</body></html>
OUTPUT:
Program:
<html>
<head>
<title> MUTHAYAMMAL COLLEGE</title>
</head>
12
<body>
<dl>
<dt>Coffee</dt>
<dd>- black hot drink</dd>
<dt>Milk</dt>
<dd>- white cold drink</dd>
</dl>
</body>
</html>
Output:
Use of table
Html handles tables very well and you can use tables to organize complex data to be presented to
your site visitors.
Syntax of a table:
<table>
<tr>
<td> data</td>
<td> data </td>
</tr>
</table>
13
creating simple table:
<html>
<head>
<title> MUTHAYAMMAL COLLEGE</title>
</head>
<body>
<table>
<tr>
<td> cell 1</td>
<td> cell 2</td>
</tr>
<tr>
<td> cell 3</td>
<td> cell 4</td>
</body>
</html>
15
HTML TABLE HEADERS
Header information in a table are defined with the <th> tag.
The text in a th element will be bold and centered.
<html>
<head>
<title> MUTHAYAMMAL COLLEGE</title>
</head>
<body>
<h4>Table headers:</h4>
<table border="1">
<tr>
<th>Name</th>
<th>Telephone</th>
<th>Telephone</th>
</tr>
<tr>
<td>Bill Gates</td>
<td>555 77 854</td>
<td>555 77 855</td>
</tr>
</table>
<h4>Vertical headers:</h4>
<table border="1">
<tr>
<th>First Name:</th>
<td>Bill Gates</td>
</tr>
<tr>
<th>Telephone:</th>
<td>555 77 854</td>
</tr>
<tr>
<th>Telephone:</th>
<td>555 77 855</td>
</tr>
16
</table>
</body>
</html>
OUTPUT:
FORMATTING TABLES
TABLE CELLS THAT SPAN MORE THAN ONE ROW/COLUMN
How to define table cells that span more than one row or one column
Merging table cells:
Every cell in a given row must be the same height and every cell in a give column must be the same
width. you can’t make individual cells different heights or widths ,but you can span two or more
adjacent cells so that one cell spans multiple rows and /or columns.
<html>
<head>
<title> MUTHAYAMMAL COLEGE</title>
</head>
<body>
<h4>Cell that spans two columns:</h4>
<table border="1">
18
<tr>
<th>Name</th>
<th colspan="2">Telephone</th>
</tr>
<tr>
<td>Bill Gates</td>
<td>555 77 854</td>
<td>555 77 855</td>
</tr>
</table>
<h4>Cell that spans two rows:</h4>
<table border="1">
<tr>
<th>First Name:</th>
<td>Bill Gates</td>
</tr>
<tr>
<th rowspan="2">Telephone:</th>
<td>555 77 854</td>
</tr>
<tr>
<td>555 77 855</td>
</tr>
</table>
</body>
</html>
19
OUTPUT:
HTML FORMS&FORMATTING
HYPERLINK:
A hyperlink is a bit of text or a graphic that we can click to move to a different location on the page,
start an email message download a file, view a movie, listen to a sound clip, active a web based program and
so on. The <a> tag used to create various types of hyperlinks.
Not all browsers support live email hyperlinks. It’s a good idea to also include the actual email
address in text form on the page.
Ex: Contact < a href=”mailto: support @ adaterm.com </a>
To add a default subject line to the email add ? subject= subject after the email address, like this
Ex: <a href=”mailto: subject=comment”> contact </a>
Another optional argument, title= specifies a screen tip for the hyperlink, by default, the screen tip for a
hyperlink shows the address of the link. Screen tips are visible in most browsers including IE4.0 and higher.
To make the screen tip say please contact as with questions or comments add the following code:
Ex: <a href=”mail:support@adatum.com title=”pleasecontact”> support @ adatum.com<a>
If the anchor were in the another file it would look like this,
<a herf=”report.htm#conclusion”> view the conclusion </a>
If the document is not in the same folder, we must refer to the folder either absolutely or relatively.
21
Hyper linking to other content:
A hyperlink can reference any file not just a web document but it links to other content such as
Microsoft office document, compressed archive files such as .zip files and even executable program files
such as setup utilities.
Some of the popular viewers and the address where they can be downloaded.
Adobe Reader
Ms-PowerPoint 2003
Ms-Word Processor 2003
<form>
.
input elements
.
</form>
<form>
First name: <input type="text" name="firstname" /><br />
Last name: <input type="text" name="lastname" />
</form>
Password Field
<input type="password" /> defines a password field:
<form>
Password: <input type="password" name="pwd" />
</form>
22
EXAMPLE:
<html>
<head>
<title> MUTHAYAMMAL COLLEGE</title></head>
<form>
firstname:<input type="text"name="firstname"\><br/>
lastname:<input type=""text"name="lastname"\><br/>
Password: <input type="password" name="pwd" />
</form>
</html>
OUTPUT:
Frame 1
Frame 2 frame3
Benefits:
Allows user to scroll independently in one frame without affecting the content of
an adjoining frame.
The frames can be scrolled independently; the table of contents and search tool are
always visible to the user.
Frames group information; visitors can more easily find what they want.
It is widely used on the Internet and often perceived as a hallmark (trade mark) of
a technically sophisticated site.
It reduces downloading time.
It can improve site usability.
Frames separate content from navigation elements and structural elements, users
can easily and quickly update pages and provide new content.
Designing two or three frames per frameset should be enough to accommodate the
information needs.
Ex:
<HTML>
<HEAD> 50%
<TITLE> FRAME ROWS</TITLE>
</HEAD>
<FRAMESET ROWS = “50%, 50%”>
<FRAME SRC= “top.htm”> 50%
<FRAME SRC= “bottom.htm”>
</FRAMESET>
</HTML>
Restricting resizing:
Ex: <FRAMESET ROWS = “50%,*”>
<FRAME SRC= “search.htm” noresize>
<FRAMESET COLS = “135*”>
<FRAME SRC= “contents.htm” noresize>
<FRAME SRC= “article.htm” noresize>
</FRAMESET>
</FRAMESET>
26
</frameset>
Targeting named frames:
To do this, we must edit the HTML document that contain the <A> elements and provide target
attributes that tell the browser which frame displays the content. This target attribute is used either in
<base> or <a> element.
Targeting in the <base> element:
Adding the base element lets you set the default target frame for all of the links in the document.
<base> is an empty tag that resides in the <head> section of the document.
<head><title> frame links </title>
<base target =”main”>
</head>
Name Description
_self This is the default behavior for link in a frameset. The linked
Using content is loaded into the same window as the <a>element _blank:
_Blank This name opens a new browser window to display the linked It is a
special content. This result can cause navigation confusion for the users, target
name who neither may nor relative that they are looking at a new lets you
to load instance of the browser. the
linked _Parent This name lets to breakout of a child frameset and displays the content
in to a link in the parent frameset one level up in the frameset hierarchy. new
instance This name only is useful when a link in a frameset displays an of
embedded frameset.
_Top The most useful of all the special names, top lets the user to
remove frames and display the linked content in a fresh browser
window.
Netscape navigator.
Using _top:
Use _top to load the lotus web page to the top of the existing window.
Planning Frame Content:
Planning on building a framed site, must prepare content for display within a frameset. Frameset
display is affected by the base screen resolution, it must be decided to display the frameset effectively.
Frames and Screen Resolution:
Frame scroll bars and borders add to the screen space requirements of frames.
Many web sites that use frames build them for a base resolution of 800*600, forcing users to change
their screen resolutions in order to view the content.
Even when coded in higher resolution, it is necessary to test at lower resolution because some users
will view web sites at this resolution. Small differences between the ways browsers display frames
can affect the look significantly.
The additional scroll bars in IE distract from the seamless nature of the frameset.
Designing effective frames:
Build web pages to fit within the frames in which it is displayed.
Accommodate different screen resolutions that can affect the size of the frame within the frameset.
Decide whether to use fixed or relative framesets.
27
Mixing Fixed and Variable Frames:
Examine the following sample frameset that mixes a fixed frame and a variable frame to
accommodate different resolutions.
The code for a sample frameset:
<HTML>
<HEAD>
<TITLE>Designing Frame Content</TITLE>
</HEAD>
<FRAMESET COLS=“125, *”>
<FRAME SRC=“X.htm>
<FRAME SRC=“Y.htm” NAME=”MAIN”>
</FRAMESET>
</HTML>
It should be noticed that the code for the left column is fixed at 125 pixels. The asterisk (*) wild
character sets the right column to a variable width that changes, based on the browser size.
[UNIT-I COMPLETED]
28