Unit 2
Unit 2
(EIT-401)
Unit II
Lecture No. 4
Introduction to HTML
HTML is a language for describing web pages.
HTML stands for Hyper Text Markup Language
HTML is a markup language
A markup language is a set of markup tags
The tags describe document content
HTML documents contain HTML tags and plain text
HTML documents are also called web pages
HTML Versions
Since the early days of the web, there have been many versions of HTML:
Version
Year
HTML
1991
HTML+
1993
HTML 2.0
1995
HTML 3.2
1997
HTML 4.01
1999
XHTML 1.0
2000
HTML5
2012
XHTML5
2013
Common Declarations
HTML5
<!DOCTYPE html>
HTML 4.01
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
XHTML 1.0
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
(EIT-401)
Lecture No. 5
HTML Lists
The most common HTML lists are ordered and unordered lists:
An unordered list:
An ordered list:
1.
2.
3.
List item
List item
List item
<ul>
<li>Coffee</li>
<li>Milk</li>
</ul>
How the HTML code above looks in a browser:
Coffee
Milk
<ol>
<li>Coffee</li>
<li>Milk</li>
</ol>
How the HTML code above looks in a browser:
1.
2.
Coffee
Milk
(EIT-401)
The <dl> tag is used in conjunction with <dt> (defines terms/names) and <dd> (describes each term/name):
<dl>
<dt>Coffee</dt>
<dd>- black hot drink</dd>
<dt>Milk</dt>
<dd>- white cold drink</dd>
</dl>
How the HTML code above looks in a browser:
Coffee
Milk
Lecture No. 6
HTML Tables
HTML Tables
Tables are defined with the <table> tag.
A table is divided into rows (with the <tr> tag), and each row is divided into data cells (with the <td> tag). td stands
for "table data," and holds the content of a data cell. A <td> tag can contain text, links, images, lists, forms, other
tables, etc.
Table Example
<table border="1">
<tr>
<td>row 1, cell 1</td>
<td>row 1, cell 2</td>
</tr>
<tr>
<td>row 2, cell 1</td>
<td>row 2, cell 2</td>
</tr>
</table>
How the HTML code above looks in a browser:
row 1, cell 1 row 1, cell 2
row 2, cell 1 row 2, cell 2
<table border="1">
<tr>
<td>Row 1, cell 1</td>
(EIT-401)
<table border="1">
<tr>
<th>Header 1</th>
<th>Header 2</th>
</tr>
<tr>
<td>row 1, cell 1</td>
<td>row 1, cell 2</td>
</tr>
<tr>
<td>row 2, cell 1</td>
<td>row 2, cell 2</td>
</tr>
</table>
How the HTML code above looks in your browser:
Header 1
Header 2
Description
<table>
Defines a table
<th>
<tr>
<td>
<caption>
<colgroup>
<col>
Lecture No. 7
(EIT-401)
HTML Images
HTML Images - The <img> Tag and the Src Attribute
In HTML, images are defined with the <img> tag.
The <img> tag is empty, which means that it contains attributes only, and has no closing tag.
To display an image on a page, you need to use the src attribute. Src stands for "source". The value of the src
attribute is the URL of the image you want to display.
Syntax for defining an image:
(EIT-401)
Lecture No. 8
HTML Forms
HTML forms are used to pass data to a server.
An HTML form can contain input elements like text fields, checkboxes, radio-buttons, submit buttons and more. A
form can also contain select lists, textarea, fieldset, legend, and label elements.
The <form> tag is used to create an HTML form:
<form>
.
input elements
.
</form>
Text Fields
<input type="text"> defines a one-line input field that a user can enter text into:
<form>
First name: <input type="text" name="firstname"><br>
Last name: <input type="text" name="lastname">
</form>
How the HTML code above looks in a browser:
First name:
Last name:
Note: The form itself is not visible. Also note that the default width of a text field is 20 characters.
Password Field
<input type="password"> defines a password field:
<form>
Password: <input type="password" name="pwd">
</form>
(EIT-401)
Password:
Note: The characters in a password field are masked (shown as asterisks or circles).
Radio Buttons
<input type="radio"> defines a radio button. Radio buttons let a user select ONLY ONE of a limited number of
choices:
<form>
<input type="radio" name="sex" value="male">Male<br>
<input type="radio" name="sex" value="female">Female
</form>
How the HTML code above looks in a browser:
Male
Female
Checkboxes
<input type="checkbox"> defines a checkbox. Checkboxes let a user select ZERO or MORE options of a limited
number of choices.
<form>
<input type="checkbox" name="vehicle" value="Bike">I have a bike<br>
<input type="checkbox" name="vehicle" value="Car">I have a car
</form>
How the HTML code above looks in a browser:
I have a bike
I have a car
Submit Button
<input type="submit"> defines a submit button.
A submit button is used to send form data to a server. The data is sent to the page specified in the form's action
attribute. The file defined in the action attribute usually does something with the received input:
(EIT-401)
Lecture No. 9
HTML Frames
Frames divide a browser window into several pieces or panes, each pane containing a separate XHTML/HTML
document. One of the key advantages that frames offer is that you can then load and reload single panes
without having to reload the entire contents of the browser window. A collection of frames in the browser
window is known as a frameset.
The window is divided up into frames in a similar pattern to the way tables are organized: into rows and
columns. The simplest of framesets might just divide the screen into two rows, while a complex frameset could
use several rows and columns.
There are few drawbacks also you should be aware of with frames are as follows:
Some browsers do not print well from framesets.
Some smaller devices cannot cope with frames, often because their screen is not big enough to be
divided up.
Some time your page will be displayed differently on different computers due to different screen
resolution.
The browser's back button might not work as the user hopes.
There are still few browsers who do not support farme technology.
To create a frameset document, first you need the <frameset> element, which is used instead of the <body>
element. The frameset defines the rows and columns your page is divided into, which in turn specify where
each individual frame will go. Each frame is then represented by a <frame> element.
You also need to learn the <noframes> element, which provides a message for users whose browsers do not
support frames.
Now we will discuss these tags in detail one by one.
Example:
Following is the example to create three horizontal frames:
<html>
<head>
<title>Frames example</title>
</head>
<frameset rows="10%,80%,10%">
<frame src="/html/top_frame.htm" />
<frame src="/html/main_frame.htm" />
<frame src="/html/bottom_frame.htm" />
<noframes>
<body>
Your browser does not support frames.
</body>
</noframes>
</frameset>
(EIT-401)
</html>
10
(EIT-401)
longdesc: allows you to provide a link to another page containing a long description of the contents of
the frame. For example longdesc="framedescription.htm"