IP - Lecture 3, 4,5 Chapter-2
IP - Lecture 3, 4,5 Chapter-2
Types of Lists
There are a number of tags for building lists.
Serves the purpose of improving the readability of the text.
Depending on the way the list items are displayed, lists
may be divided into three types:
Unordered list(unnumbered list)- This will list
items using plain bullets (there is no special order
between items)
list of examples, names, components…
Ordered list (numbered list)- This will use
different schemes of numbers to list your items.
Items occur in a particular order, such as step-by-
step instructions or driving directions
Definition list- This arranges your items in the
same way as they are arranged in a dictionary
1
UNORDERED LIST
Used to display a set of related items that appear in no
particular order.
◦ Each item is indented with a preceding bullet symbol.
Specified using the tag:
<UL> ……… </UL>
The individual items in the list are specified using the <LI> tag.
Attributes:
type = disc | circle | square (not supported in HTML 5)
style=“list-style-type: disk|circle|square” (HTML 5)
The <LI> items can contain multiple paragraphs, specified using
<P>.
Example:
<UL>
<LI> <p> First item of the list</p></li>
<LI> <p>Second item of the list</p></li>
<LI> <p>Third item of the list</p></li> 2
</UL>
EXAMPLE 1
<!DOCTYPE html>
<html>
<head><title> Bulleted list 1 </title></head>
<body>
<h2> The flowers I like: </h2>
<h3>
<UL>
<LI> Rose </LI>
<LI> Lotus </LI>
<LI> Daffodil </LI>
<LI> Marigold </LI>
</UL>
</h3>
</body> 3
</html>
EXAMPLE 2
<!DOCTYPE html>
<html>
<head><title> Bulleted list 2 </title></head>
<body >
<h2> The flowers I like: </h2>
<h3>
<UL style="list-style-type:square">
<li> Rose</li>
<li> Lotus</li>
<li> Daffodil</li>
<li> Marigold</li>
</UL>
</h3>
4
</body>
</html>
ORDERED LIST(NUMBERED LIST)
i,ii,iii,…
6
EXAMPLE 1
<!DOCTYPE html>
<html>
<head><title> Numbered list 1 </title></head>
<body>
<h2> To cook Maggi you must: </h2>
<h3>
<OL>
<LI> Put some water to boil </LI>
<LI> Put in noodles and masala </LI>
<LI> Wait for 2 minutes </LI>
<LI> Serve in a plate </LI>
</OL>
</h3>
7
</body>
</html>
EXAMPLE 2
<!DOCTYPE html>
<html>
<head><title> Numbered list 2 </title></head>
<body>
<h2> To cook Maggi you must: </h2>
<h3>
<OL type =A>
<LI> Put some water to boil </LI>
<LI> Put in noodles and masala </LI>
<LI> Wait for 2 minutes </LI>
<LI> Serve in a plate </LI>
</OL>
</h3> 8
</body>
</html>
EXAMPLE 3
<!DOCTYPE html>
<html>
<head><title> Numbered list 3 </title></head>
<body>
<h2> To cook Maggi you must: </h2>
<h3>
<OL type =I>
<LI> Put some water to boil </LI>
<LI> Put in noodles and masala </LI>
<LI type=1> Wait for 2 minutes </LI>
<LI> Serve in a plate </LI>
</OL>
</h3> 9
</body>
</html>
DESCRIPTION LIST( HTML 4-DEFINITION
LIST)
<!DOCTYPE html>
<html>
<head><title>HTML Definition List</title></head>
<body>
<dl>
<dt><b>HTML</b></dt>
<dd>This stands for Hyper Text Markup
Language</dd>
<dt><b>HTTP</b></dt>
<dd>This stands for Hyper Text Transfer
Protocol</dd>
</dl>
</body> 11
</html>
EXAMPLE 2
<html>
<head><title> Definition list 1 </title></head>
<body >
<h2> Some important protocols: </h2>
<h3><DL>
<DT> TCP</DT>
<DD> Transmission Control
Protocol</DD>
<DT> UDP</DT>
<DD> User Datagram Protocol</DD>
<DT> IP</DT>
<DD> Internet Protocol</DD>
</DL></h3> 12
</body>
</html>
NESTING OF LISTS
13
EXAMPLE 1
<html><head><title> List Nesting 1 </title></head>
<body>
<H3> My favorite languages are:
<UL>
<LI> Java </LI>
<UL>
<LI> object-oriented </LI>
<LI> platform independent </LI>
<LI> can be embedded within HTML </LI>
</UL>
<LI> Perl </LI>
<UL>
<LI> a scripting language </LI>
<LI> powerful string handling capabilities </LI>
<LI> widely used for writing CGI scripts </LI>
</UL>
</UL> </H3> 14
</body></html>
EXAMPLE 2
<html><head><title> List Nesting 2 </title></head>
<body>
<H3> My favorite programming languages are:
<OL>
<LI> Java </LI>
<UL>
<LI> object-oriented</LI>
<LI> platform independent</LI>
<LI> can be embedded within HTML</LI>
</UL>
<LI> Perl </LI>
<OL>
<LI> a scripting language</LI>
<LI> powerful string handling capabilities</LI>
<LI> widely used for writing CGI scripts</LI>
</OL> 15
</OL> </H3>
</body></html>
HORIZONTAL LIST
Lists can be styled to be aligned horizontally by
using simple CSS
Example
<!DOCTYPE html>
<html><head>
<style>
ul#menu li { display:inline; }
</style></head>
<body>
<h2>Horizontal List</h2>
<ul id="menu">
<li>HTML|</li>
<li>CSS|</li>
<li>JavaScript|</li>
<li>PHP</li>
</ul> 16
</body>
</html>
SPECIFYING HYPERLINKS
Hyperlinks
Chief power of HTML comes from its ability to
link text and/or image to another document or
section of a document.
A webpage can contain various links that take
you directly to other pages and even specific
parts of a given page.
These links are called hyperlinks.
Browser by default highlights the hyperlinks
with color and/or underline.
Hyperlinks allow visitors to navigate between
Web sites by clicking on words, phrases, and
images. Thus you can create hyperlinks using 17
text or images available on a webpage.
…CONT
Specified using the anchor tag:
<A> ……. </A>
Attribute: HREF- specifies the path of the resource
to be linked.
Syntax: <a href="url">link text</a>
Anchors can be used to go to a particular section in a
document.
Within the same (or different) document.
Example:
<A href=“face.jpg”> portrait </A>
<a href=“www.google.com”> search </a>
<a href="mailto:[email protected]">Link
text</a> 18
Also called file path and full path, contains the root
directory and all other subdirectories that contain a
file or folder
Necessary when linking to documents on another
servers.
The complete path name of the document in the server
is specified.
Example:
<a href=“www.bdu.edu.et/slides/Ip/paper5.pdf”> One of my
recent papers </a>
21
HTML ID ATTRIBUTE(LINKING TO SPECIFIC
SECTION)
<!DOCTYPE html>
<html>
<body>
<p>
<a href="#C4">See also Chapter 4.</a>
</p>
<h2>Chapter 1</h2>
<p>This chapter explains ba bla bla</p>
<h2>Chapter 2</h2>
<p>This chapter explains ba bla bla</p>
<h2>Chapter 3</h2>
<p>This chapter explains ba bla bla</p>
<h2><a id="C4">Chapter 4</a></h2>
<p>This chapter explains ba bla bla</p>
23
</body>
</html>
LOCAL HYPERLINKS
When two pages are on the same directory you can
link from one to the other by using only the filename.
A local link (link to the same web site) is specified
with a relative URL
<!DOCTYPE html>
<html>
<body>
<p>
<a href="html_images.html">HTML Images</a> is a link to a page on
this website.
</p>
<p>
<a href="http://www.w3.org/">W3C</a> is a link to a website on the
World Wide Web.
</p>
</body>
</html>
LOCAL HYPERLINKS
Pros:
• If you upload the whole directory on another
server, the links will still work.
Cons:
• If you copy a part of your web pages on a local
disk, the links may not work.
HYPERLINKS (EXAMPLE)
28
EXAMPLE 1
<html>
<body>
<p>
<img src =xyz.gif align ="left" width="48"
height="48">A paragraph with an image. The
image will float to the left of this text.</p>
<p>
<img src =xyz.gif align ="right" width="48“
height="48">
A paragraph with an image. The image will float to
the right of this text. </p>
</body>
</html>
29
EXAMPLE 2
<html>
<body>
<img src= x.gif" width="20" height="20"> <p>
<img src= x.gif" width="45" height="45"> <p>
<img src= x.gif" width="70" height="70"> <p>
Resizing an image by changing the values in
the "height" and "width" attributes of the
img tag.
</body>
</html>
30
EXAMPLE 3
<html>
<body>
It is possible to use an image as a link. Click on
the image below to go to google.
<P>
<a href=“www.google.com"><img src=x.gif></a>
</body>
</html>
31
HTML TABLES
Tables are made up of cells, arranged into rows.
<table></table> marks the start and end of table contents
<tr></tr> marks the start and end of each table row
<td></td> marks the start and the end of the contents of a
data cell
A table row can also be divided into table headings with
the <th> tag.
<caption></caption> formats text to appear as a table
caption
Example:
<table> Good Bad
<tr>
<td> Good </td><td> Bad </td> cute ugly
</tr>
<tr>
<td> Cute </td> <td> Ugly </td>
32
</tr>
</table>
THE TABLE TAGS
<TABLE> …… </TABLE>
Defines the beginning and the end of a table.
Can have several attributes:
• bgcolor = #rrggbb or color name : background
table
• height = number, percentage 33
needs to be span
<TH> …….. </TH>
Defines a table header cell.
Browsers generally display the contents of the
header cells in bold, and centered.
Same attributes as the <TD> tag.
35
EXAMPLE 1
Good Day 36
EXAMPLE 2
Hello Good
37
Day
EXAMPLE 3
<table border=1>
<caption> Students Result </caption>
<tr> <th> Name </th> <th> Marks </th> </tr>
<tr> <td> Ayele</td> <td> 86</td> </tr>
<tr> <td> Kebede</td> <td> 65</td> </tr>
</table>
Students Result
Name marks
Ayele 86
Kebede 65
38
HTML FRAMES (IFRAME-HTML5)
What are frames?
A method for dividing the browser window into smaller
subwindows.
Each subwindow displaying a different HTML document.
An iframe is used to display a web page within a web
page
Syntax: <iframe src="URL"></iframe> where
the src attribute specifies the URL (web address) of the
iframe page
Uses the height and width attributes to specify the size.
<iframe src="demo_iframe.htm" width="200" height="200">
</iframe>
The frameborder attribute specifies whether or not to display
a border around the iframe. Set the attribute value to "0" to 39
remove the border
<iframe src="demo_iframe.htm" frameborder="0"></iframe>
HOW DOES A PAGE WITH IFRAME LOOK LIKE?
40
MERITS AND DEMERITS
Merits:
Allow parts of the page to remain stationary while
other parts scroll.
They can unify resources that reside on separate web
servers.
Demerits:
All browsers do not support frames.
Documents nested in a frame is more difficult to
bookmark.
Load on the server can be significantly increased, if
there are a large number of frames in the page.
Frames are very difficult to handle for search
engines.
41
<IFRAME> tag specifies an inline frame.
An inline frame is used to embed another document
within the current HTML document.
Attributes:
frameborder = 1 | 0 : This attribute specifies
whether or not the borders of that frame are
shown (not supported in HTML 5)
• We can use CSS instead
<iframe src=“url” style=“border:none |5px solid
black></iframe>
src = url : this attribute is used to give the file
name that should be loaded in the frame
name = text :This attribute allows you to give a
name to a frame. It is used to indicate which
frame a document should be loaded into 42
<!DOCTYPE html>
<html>
<body>
<iframe src="demo_iframe.htm" name="iframe_a">
<p>Your browser does not support iframes.</p>
</iframe>
<a href="http://www.google.com"
target="iframe_a">Google Search</a>
<p><b>Note:</b> Because the target of the link
matches the name of the iframe, the link will open in
the iframe.</p>
</body>
45
</html>
HTML FORMS
Registration
Syntax:
<form action="Script URL" method="GET|POST">
form elements like input, textarea etc.
</form>
47
Form Tags and Attributes
48
<FORM> …… </FORM> TAG
E.t.c
58
…CONT
MULTIPLE: specifies that multiple selections
from the list can be made.
<FORM ………….>
……..
Languages known:
<SELECT NAME=“lang” SIZE=3 MULTIPLE>
<OPTION> English
<OPTION> Amharic
<OPTION> Afan Oromo
<OPTION> Tigrigna
</SELECT>
</FORM>
59
GROUPING FORM DATA WITH <FIELDSET>
The <fieldset> element groups related data in a
form.
The <legend> element defines a caption for the
<fieldset> element.
E.g
<form action=“registration.php">
<fieldset>
<legend>Personal information:</legend>
First name:<br>
<input type="text" name="firstname" ><br>
Last name:<br><input type="text" name="lastname">
<br><br>
<input type="submit" value=“Register">
</fieldset>
</form> 60
EXAMPLE 1
<HTML>
<HEAD>
<TITLE> Using HTML Forms </TITLE>
</HEAD>
<BODY background="bg.gif" LINK="#FF9900"
VLINK="#FF9900“ ALINK="#FF9900">
<CENTER><H3> Student Registration Form </H3>
</CENTER>
61
<FORM METHOD="POST" ACTION="registration.php">
<P> Name: <INPUT NAME="name" TYPE="TEXT"
SIZE="30" MAXLENGTH="50">
<P> Id_Number: <INPUT NAME="rollno" TYPE="TEXT"
SIZE="30">
<P> Password: <INPUT NAME="passw" type="password"
SIZE="30">
<P> Email: <INPUT NAME="email" TYPE="email"
SIZE="30">
<P> <INPUT TYPE="SUBMIT" Name="Submit">
<INPUT TYPE="RESET" Name="Reset">
</FORM> </BODY> </HTML>
62
READING ASSIGNMENT
63