HTML Modified Final
HTML Modified Final
Web Technology
What is HTML?
• HTML stands for Hyper Text Markup Language
• Basic tool for designing a web page.
• Documentation language to mark the headings, title,
table and forms.
• An HTML file is a text file containing small markup
tags
• The markup tags tell the Web browser how to display
the page
• An HTML file must have an htm or html file
extension
• An HTML file can be created using a simple text
editor (notepad)
2
Web Technology
3
Web Technology
4
HTML Tags and Basic Page Structure
Web Technology
HTML Tags
• HTML tags are used to mark-up HTML elements
• HTML tags are surrounded by the two characters < and >
• The surrounding characters are called angle brackets
• HTML tags normally come in pairs like <b> and </b>
• exceptions: <P>, <br>, <li> tags …
• The first tag in a pair is the start tag, the second tag is the
end tag
• The text between the start and end tags is the element
content
• HTML tags are not case sensitive, <b> means the same as
<B>
6
How to Create and View an HTML
document?
1.Use an text editor such as Notepad to write the
document.
2.Save the file as filename.html on a PC. This is called
the Document Source.
3.Open Internet Explorer (or any browser) Off-Line.
4.Click on File, Open File and select the filename.html
document that you just created.
5.Your HTML page should now appear just like any
other Web page in explorer.
How to Create and View an HTML
document?
7.You may now switch back and forth between the
Source and the HTML Document
• switch to Notepad with the Document Source
• make changes
• save the document again
• switch back to explorer.
• click on REFRESH and view the new HTML
Document
• switch to Notepad with the Document Source......
Web Technology
HTML Elements
• Example:1
• This is an HTML element:
<b>This text is bold</b>
• Example:2
• This HTML element starts with the start tag <body>,
and ends with the end tag </body>.
• The purpose of the <body> tag is to define the HTML
element that contains the body of the HTML
document.
9
Web Technology
Headings
• Defined with the <h1> to <h6> tags
• <h1> defines the largest heading
• <h6> defines the smallest heading
<h1>This is a heading</h1>
<h2>This is a heading</h2>
<h3>This is a heading</h3>
<h4>This is a heading</h4>
<h5>This is a heading</h5>
<h6>This is a heading</h6>
10
Web Technology
Paragraphs
• Defined with the <p> tag
<p>This is a paragraph</p>
<p>This is another paragraph</p>
• Note: Paragraphs can be written without end tags
</p>
<p>This is a paragraph
<p>This is another paragraph
11
Web Technology
Line Breaks
• <br> tag is used when you want to break a line, but
don't want to start a new paragraph
<p>This <br> is a para<br>graph with line breaks</p>
• The <br> tag is an empty tag. It has no end tag
• <br> tag written like this: <br /> Because the <br>
tag has no end tag
12
Web Technology
Horizontal Rule
• The <hr> tag is used to insert a horizontal rule (line)
<p>The hr tag defines a horizontal rule:</p>
<hr>
<p>This is a paragraph</p>
13
Web Technology
Single Space
• The is used when you want to insert a space
between words.
<p>The hr tag defines a horizontal rule:</p>
• Example:3
14
HTML Attributes
Web Technology
16
HTML Fonts
Web Technology
18
Web Technology
Font Colors
• Example:17
• Example:18
19
HTML Character Entities
Web Technology
Character Entities
• Characters like the < character, have a special
meaning in HTML, and therefore cannot be used in
the text.
• To display a less than sign (<) in HTML, we have to
use a character entity.
• A character entity has three parts: an amp
WEersand (&), an entity name or a # and an entity
number, and finally a semicolon (;)
• To display a less than sign in an HTML document we
must write: < or <
• Note that the entities are case sensitive.
21
Web Technology
Example:19
22
Web Technology
Some Other Commonly Used Character
Entities
Result Description Entity Name Entity Number
¢ Cent ¢ ¢
£ Pound £ £
¥ Yen ¥ ¥
€ Euro € €
§ Section § §
© copyright © ©
registered
® ® ®
trademark
× multiplication × ×
÷ division ÷ ÷
23
HTML Lists
Web Technology
Types of List
• Unordered List
• Ordered Lists
• Definition lists
25
Web Technology
Unordered Lists
• An unordered list is a list of items.
• The list items are marked with bullets (typically small
black circles).
• An unordered list starts with the <ul> tag.
• Each list item starts with the <li> tag.
<ul>
<li>Coffee</li>
<li>Milk</li>
</ul>
26
Web Technology
Unordered Lists
• Here is how it looks in a browser:
• Coffee
• Milk
• Example:27
27
Web Technology
Ordered Lists
• An ordered list is also a list of items. The list items are marked
with numbers.
• An ordered list starts with the <ol> tag. Each list item starts
with the <li> tag.
<ol>
<li>Coffee</li>
<li>Milk</li>
</ol>
• Here is how it looks in a browser:
1. Coffee
2. Milk
28
Web Technology
Ordered Lists
• Inside a list item you can put paragraphs, line breaks,
images, links, other lists, etc.
• Example:28
29
Web Technology
Definition Lists
• A definition list is not a list of items. This is a list of
terms and explanation of the terms.
• A definition list starts with the <dl> tag.
• Each definition-list term starts with the <dt> tag.
• Each definition-list definition starts with the <dd>
tag.
30
Web Technology
Definition Lists
<dl>
<dt>Coffee</dt>
<dd>Black hot drink</dd>
<dt>Milk</dt>
<dd>White cold drink</dd>
</dl>
Here is how it looks in a browser:
Coffee
Black hot drink
Milk
White cold drink
31
Web Technology
Definition Lists
• Inside a definition-list definition (the <dd> tag) you
can put paragraphs, line breaks, images, links, other
lists, etc.
• Example:29
• Example:30
• Example:31
• Example:32
32
HTML Background
Web Technology
34
Web Technology
Backgrounds
• The <body> tag has two attributes where you can
specify backgrounds.
• The background can be a color or an image.
35
Web Technology
Bgcolor
• The bgcolor attribute specifies a background-color for
an HTML page.
• The value of this attribute can be a hexadecimal
number, an RGB value, or a color name:
<body bgcolor="#000000">
<body bgcolor="rgb(0,0,0)">
<body bgcolor="black">
• The lines above all set the background-color to
black.
36
Web Technology
Background
• The background attribute specifies a background-
image for an HTML page.
• The value of this attribute is the URL of the image
you want to use.
• If the image is smaller than the browser window, the
image will repeat itself until it fills the entire browser
window.
37
Background (cont…)
<body background="clouds.gif">
<body
background="http://www.w3schools.com/clouds.
gif">
• The URL can be relative (as in the first line above) or
absolute (as in the second line above).
• Example:45
• Example:46
• Example:47
38
HTML Links
Web Technology
Hyperlinks
• HTML uses a hyperlink to link to another document
on the Web.
• It is used to create links in an HTML document.
• Example:20
• Images as a link
• Example:21
40
Web Technology
41
Web Technology
The Anchor Tag and the Href Attribute
(cont…)
42
Web Technology
43
Web Technology
44
HTML Images
Web Technology
46
Web Technology
• Example:33
• Insert Images from different locations
• Example:34
47
Web Technology
Background Image
• Example:35
• Aligning images
• Example:36
• Let the image float
• Example:37
• Adjust images to different sizes
• Example:38
• Display an alternate text for an image
• Example:39
48
Web Technology
49
HTML Tables
HTML Tables
• With HTML you can create 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).
• The letters td stands for "table data," which is the
content of a data cell.
• A data cell can contain text, images, lists, paragraphs,
forms, horizontal rules, tables, etc.
• Example:48
51
Web Technology
• bordercolor attribute
52
Web Technology
Headings in a Table
• Headings in a table are defined with the <th> tag
• Example:50
53
Web Technology
More Examples…
• Table with no borders
• Example:55
• Headings in Table
• Example:56
• Empty Cells
• Example:57
• Table with a caption
• Example:58
54
Web Technology
More Examples…
• Table cells that span more than one row/column
• Example:59
• Tags inside a table
• Example:60
• Cell padding
• Example:61
• Cell spacing
• Example:62
55
HTML Frames
Web Technology
Frames
• With frames, you can display more than one Web
page in the same browser window.
• With frames, you can display more than one HTML
document in the same browser window.
• Each HTML document is called a frame, and each
frame is independent of the others.
• The disadvantages of using frames are:
• The web developer must keep track of more HTML
documents
• It is difficult to print the entire page
57
Web Technology
58
Web Technology
59
Web Technology
60
Web Technology
Frameset
• Vertical Frameset
• Example:68
• Horizontal Frameset
• Example:69
61
Web Technology
Mixed frameset
• Example:71
62
HTML Forms
Web Technology
Form
• Form is an area that can contain form elements.
• Form elements are elements that allow the user to
enter information (like text fields, textarea fields,
drop-down menus, radio buttons, checkboxes, etc.) in
a form.
• A form is defined with the <form> tag.
<form>
<input>
<input>
</form>
64
Web Technology
Input
• The most used form tag is the <input> tag.
• The type of input is specified with the type attribute.
• The most commonly used input types are explained
below.
65
Web Technology
Text Fields
• Text fields are used when you want the user to type
letters, numbers, etc. in a form.
<form>
First name:
<input type="text" name="firstname">
<br>
Last name:
<input type="text" name="lastname">
</form>
66
Web Technology
Text Fields
• How it looks in a browser:
First name:
Last name:
• Note that the form itself is not visible. Also note that
in most browsers, the width of the text field is 20
characters by default.
67
Web Technology
Radio Buttons
• Radio Buttons are used when you want the user to
select 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>
68
Web Technology
Radio Buttons
• How it looks in a browser:
Male
Female
• Note that only one option can be chosen.
69
Web Technology
Check Boxes
• Checkboxes are used when you want the user to
select one or more options of a limited number of
choices.
<form>
I have a bike:
<input type="checkbox" name="vehicle" value="Bike">
<br>
I have a car:
<input type="checkbox" name="vehicle" value="Car">
<br>
I have an airplane:
<input type="checkbox" name="vehicle" value="Airplane">
</form> 70
Web Technology
Check Boxes
<form>
I have a bike:
<input type="checkbox" name="vehicle"
value="Bike">
<br>
I have a car:
<input type="checkbox" name="vehicle" value="Car">
<br>
I have an airplane:
<input type="checkbox" name="vehicle"
value="Airplane">
</form>
71
Web Technology
Check Boxes
• How it looks in a browser:
I have a bike:
I have a car:
I have an airplane:
72
Web Technology
Form’s Action Attribute and Submit
Button
• When the user clicks on the "Submit" button, the
content of the form is sent to another file.
• The form's action attribute defines the name of the
file to send the content to.
• The file defined in the action attribute usually does
something with the received input.
73
Web Technology
Form’s Action Attribute and Submit
Button
<form name="input"
action="html_form_action.asp"
method="get">
Username:
<input type="text" name="user">
<input type="submit" value="Submit">
</form>
• How it looks in a browser:
Username: Submit
74
Web Technology
More Examples
• Create Button
Example:82
• Input Fields and Submit button
Example:83
• Form with Checkbox
Example:84
• Form with Radio Buttons
Example:85
• Send E-Mail from a form
• Example:86
75