HTML
HTML
HTML
Web Application
Development
HTML
(Hyper Text Markup Language)
Markup Language
• A language that has codes for
indicating layout and styling (such as
boldface, italics, paragraphs,
placement of graphics, etc.) within a
text file.
• Ex: Markup languages
– SGML (Standard General Markup
Language)
– HTML (Hypertext Markup
Language)
– XML (Extensible Markup Language)
Hypertext Markup Language (HTML)
• Tag statements
• Attributes
• Text
Usually appearing on the page
• Scripting language
Capable of manipulating the document
HTML Document Structure
<html>
<head>
</head> Head
HTML
<body> Document
</body> Body
</html>
HTML Structure
• HTML Tag
Tells the Web browser where the HTML in your
document begins and ends
Head Section
10/31/2024 24
<P> … </P>
<em></em> or <i></i>
Italicizes the tagged text
Text Display
Elements <pre></pre>
Preserves white space and
breaks and stands for
“preformatted”
<br>
<hr>
<marquee>
Common Tags
Attributes
Sometimes, we need more
information for an element in
order to control the way the
content displays
<elementName attribute=“value”>
Target content
</elementName>
Character: Entity:
< <
> >
& &
[space]
HTML Comments
An HTML Comment which is NOT displayed in the page is
done like this:
39
10/31/2024
HTML LISTS
• An unordered List
• An ordered List
• Tags
– <ul>- Define an unordered list
– <ol>- Define an ordered list
– <li> - Define a list item
Creating Lists
▪ Unordered Lists: Unordered (bulleted) lists <UL> can use a disc, circle, or
square
Ordered Lists
• Ordered (numbered) lists <OL>
can use numbers (1), capital
letters (A), lowercase letters (a),
or Roman numerals (i)
Ordered Lists
<OL TYPE=1 START=5> • Additional
<LI>Matara – <ol type="A">
<LI>Galle – <ol type="a">
</OL> – <ol type="I">
– <ol type="i">
Inserting Images
44
10/31/2024
<img> Defines an image
Attributes: SRC, ALT, HEIGHT, WIDTH, ALIGN, ………
Inserting Image from Other Location
ALT Attribute & Sizing Graphics and borders
HTML Background
Background Color / Graphics
Tag <a>
HTML Link Tag
Link to
Other sites
Between your own pages
To e-mail
Linking within one document
Link to a mail
Tables and Table Formatting
54
10/31/2024
Uses of Tables
• Tables should be used primarily to hold tabular data
• Many existing Web pages use tables to create the page
layout
Defining a Table Structure
• The first step to creating a table is to specify the table
structure:
– the number of rows and columns
– the location of column headings
– the placement of a table caption
• Once the table structure is in place, you can start
entering data into the table.
56
Using the <table>, <tr>, and <td> Tags
57
The General Table Syntax
two rows
two columns
58
Columns within a Table
• HTML does not provide a tag for table columns.
• In the original HTML specifications, the number of
columns is determined by how many cells are inserted
within each row.
– for example, if you have four <td> tags in each table
row, that table has four columns
59
HTML Structure of a Table
beginning of
the table
structure
table cells
end of the
table structure
60
Creating Headings with the <th> Tag
• HTML provides the <th> tag for table headings.
• Text formatted with the <th> tag is centered within the
cell and displayed in a boldface font.
• The <th> tag is most often used for column headings,
but you can use it for any cell that you want to contain
centered boldfaced text.
61
Adding Table Headings to the Table
Text in cells formatted
with the <th> tag is
bold and centered
above each table
column.
table
headings
62
Creating a Table Caption
• HTML allows you to specify a caption for a
table.
• The syntax for creating a caption is: <caption
align=“alignment”>caption text</caption>
– alignment indicates the caption placement
– a value of “bottom” centers the caption
below the table
– a value of “top” or “center” centers the
caption above the table
63
Table Captions
64
Result of a Table Caption
65
Modifying the Appearance of a Table
• You can modify the appearance of a table by adding:
– borders
– background color
• HTML also provides tags and attributes to control the
placement and size of a table.
66
Adding a Table Border
• By default, browsers display tables without table
borders.
• A table border can be added using the border attribute
to the <table> tag.
• The syntax for creating a table border is: <table
border=“value”>
– value is the width of the border in pixels
67
Tables with Different Borders Values
This figure shows the effect on a table’s border when the border size is varied.
68
Adding a 5-Pixel Border to a Table
69
Working with Table and Cell Size
• The size of a table is determined by text it contains in its cells.
• By default, HTML places text on a single line.
• As you add text in a cell, the width of the column and table expands
to the edge of the page.
– once the page edge is reached, the browser reduces the size of
the remaining columns to keep the text to a single line
• You can insert line break, paragraph, or other tags within a cell.
• When the browser can no longer increase or decrease the size of
the column and table it wraps the text to a second line.
• As more text is added, the height of the table expands to
accommodate the additional text.
• But, you can manually define the size of the table and its cells.
70
Defining the Table Size
71
Defining Cell and Column Sizes
72
Aligning a Table on the Web Page
73
Aligning the Contents of a Table
• By default, cell text is placed in the middle of the cell,
aligned with the cell’s left edge.
• By using the align and valign attributes, you can specify
the text’s horizontal and vertical placement.
• To align the text for a single column, you must apply
the align attribute to every cell in that column.
74
Values of the Align and Valign Attributes
75
Spanning Rows and Columns
• To merge several cells into one, you need to create a
spanning cell.
• A spanning cell is a cell that occupies more than one row
or column in a table.
• Spanning cells are created by inserting the rowspan and
colspan attribute in a <td> or <th> tag.
• The syntax for these attributes is: rowspan=“value”
colspan=“value”
– value is the number of rows or columns that the cell spans in the
table
76
Example of Spanning Cells
77
A Table Structure with a Row-Spanning Cell
four table
cells in the
first row
HTML code
resulting table
78
Example of Spanning Cells
This cell
spans two this cell
columns spans
and two three
rows columns
This cell
spans three
rows
79
Adding Spanning Cells to a Table
80
Another Example of Spanning Cells
81
Another Example of Spanning Cells
82
Applying a Background Color
83
Specifying Table, Row, and Cell Colors
Specifying Table, Row, and Cell Colors
The bordercolor Attribute
• By default, table borders are displayed in two shades of gray
that create a three-dimensional effect.
• The syntax for the bordercolor attribute is:
<table bordercolor=“color”>
– color is an HTML color name or hexadecimal color value
87
Designing a Page Layout with Tables
• HTML tables are most often used to define the layout
of an entire Web page.
• If you want to design a page that displays text in
newspaper style columns, or separates the page into
distinct sections, you’ll find tables an essential and
useful tool.
88
Table Layout of a Web Page
620 pixels
1) logo
89
Using Nested Table
• Tables can be created within another table, making the
Web page easier to manage.
a sketch of a web
page using nested
tables
90
Using Nested Table
91
10/31/2024
The Result of the Web Page
using Nested Tables
a sample web page
using nested
tables
92
Sample Template based on Class Web Page
Designing forms
10/31/2024
94
Introduction
• Forms provide a method for true interaction between
users and the publisher of a website, with an
immediacy that could never be achieved in any other
medium.
• With forms, you can solicit input from a user in order
to provide a customized response on-the-fly or just
collect the data for later used.
• Forms can be used for functions as simple as surveys
and guestbook, or as complex as online commerce
systems.
Introduction to forms