HTML
HTML
2
Structure of the Internet
This figure shows the physical structure of the Internet, which uses fiber-optic
cables, satellites, phone lines, and other telecommunications media to send data
back and forth.
3
The Development of the World
Wide Web
4
Hypertext Documents
5
Linear Versus Hypertext
Documents
This figure shows how topics can be related in a hypertext fashion,
as opposed to a linear fashion.
6
Hypertext Documents
Continued
7
Web Pages and Web Browsers
8
Using a Browser to View a Web
Document on a Server
This figure shows to view web pages, the user runs a Web browser,
a software program that retrieves the page and displays it.
9
What is HTML?
11
Hypertext Markup Language
(HTML)
12
Tools for Creating HTML
Documents
13
HTML Syntax
14
HTML Tags
Tags can be one-sided or two-sided.
two-sided tags contain an opening tag <tag> that tells
the browser to turn on a feature and apply it to the
contact that follows, and a closing tag </tag> that turns
off the feature
one-sided tags are usually used to insert noncharacter
data into the Web page, such as a graphic image
</body>
</html>
Creating Heading Tags
20
Six Heading Levels
This figure
illustrates the
general appearance
of the six heading
styles. Your
browser might use
slightly different
fonts and sizes.
21
Basic Tags
<center>: to position a certain block in the middle of the
web page
<hr>: horizontal ruler, splits the webpage by a graphical
horizontal ruler, has no closing tag, includes attributes:
color: presented in hexadecimal code or name, like
color=“#FFFFFF” or color=“white”.
width
Align
size
Basic Tags
24
Common Logical Character
Tags
Tag Description
<em></em> Indicates that characters should be
emphasized
<strong></strong> Indicates a text in bold font
<code></code> Indicates a sample code
<kbd></kbd> Indicates a text in monospace font
<var></var> Indicates a variable
<cite></cite> Indicates a short quote or citation
25
Common Physical Character
Tags
Tag Description
<b></b> Bold Text
<i></i> Italicized Text
<u></u> Underlined Text
<tt></tt> Typewriter Text in monospace
font
<sub></sub> Subscript Text
<sup></sup> Superscript Text
26
Logical Character Tags as They
Appear in the Browser
examples of
individual
tags
example of
combined
tags
27
Physical Character Tags as
They Appear in the Browser
28
Special Characters
29
Special Characters and Codes
30
Creating a Hypertext
Document
Hypertext documents contain hypertext links,
items that you can select to view another topic or
document, often called the destination of the
link.
These links can point to:
another section to the same document or another document
the same document
to a different document
to a different Web page
to a variety of other Web objects
31
Adding Hypertext Links
32
Creating Anchors
The <a> tag creates an anchor, text that is specially marked so
that you can link to it from other points in a document.
Text that is anchored is the destination of a link; it is not the text
you click on.
Each anchor has its own anchor name, using the “name”
attribute i.e.
<a name=“cc”>Classes</a>.
An anchor doesn’t have to be text. You can mark an inline
image as an anchor.
Adding an anchor does not change your document’s
appearance in any way. It merely creates locations in your Web
page that become destinations of links. 33
Creating Hyperlinks
To create a link to an anchor, use the same <a> tag you
used to create the anchor.
The <a> tags used to create links are sometimes called link
tags.
Use the href attribute, which is short for Hypertext
Reference, to indicate the location to jump to.
href can refer to an anchor that you place in the document or to a
different Web page or a resource anywhere on the Internet
it is important to note that the href attribute is case sensitive
35
Text Links in the Browser
If the headings do
not appear as text
links, check your
code to make sure
that you are using the
<a> and </a> tags
around the
appropriate text, the
href attribute
within the tag, and
the quotes and #
symbols.
Text formatted as
links
36
Linking to another document
37
HTML Code that
Links to Other Documents
<a> tags to
point to
other
documents
38
Linking to a Section of a
Document
39
Linking to Documents
in Other Folders
40
Linking to Documents on the
Internet
To create a hypertext link to a document on the Internet, you need
to know its URL.
A URL, or Uniform Resource Locator, specifies a precise location on
the Web for a file.
You can find the URL of a Web page in the Location or Address box
of your browser’s document window.
Once you know a document’s URL, you can create a link to it by
adding the URL to the <a> tag along with the href attribute in your text
file i.e.
<a href http://www.mwu.edu/course/info.html>Course
Information</a>.
41
Displaying Linked Documents
in a New Window
42
Linking to E-mail
Many Web designers include their e-mail addresses on
their Web pages, so that users who access the page
can send feedback.
You can identify e-mail addresses as hypertext links.
when a user clicks the e-mail address, the browser starts a mail program
and automatically inserts the e-mail address into the “To” field of the
outgoing message
44
HTML Code for using
Color in a Web Page Continued
bgcolor attribute sets the background color
the value of color will be either one of the accepted color names or
the color’s hexadecimal value
if you use the hexadecimal value, you must preface the
hexadecimal string with the pound symbol (#) and enclose the
string in double or single quotation marks i.e. <body
bgcolor=“#FFC088”>
46
The Page with the New Color
Scheme
47
Modifying Text
48
Using the <font> Tag
The <font> tag allows you to specify the color, the
size, and the font to be used for text on a Web page.
The syntax for the <font> tag is:
<font size=“size” color=“color” face=“face”> text
</font>
size attribute allows you to specify the font size of the text
color attribute allows you to change the color of individual
characters or words
face attribute specifies a particular font for a section of text
49
Examples of Different Font Sizes
This figure shows a representation of the various font sizes for a typical browser.
50
Examples of Heading Tags
and Font Sizes
This figure shows a complete comparison of header tags and font sizes.
51
Changing the Font Color
The color attribute of the <font> tag allows you to
change the color of individual characters or words.
Specify the color in the <font> tag by using either a
color name or color value.
for example, to change the color of the word “Aracadium”
to the hexadecimal color value 8000C0, you would enter
the following HTML tag: <font
color=“#8000C0”>Arcadium</font>
If there is no color specified in the <body> tag, the
default colors of the Web browser is used.
52
Changing the Font Face
54
Fonts and Browsers
55
Applying a Sans-
Serif Font to a
Section of Text text will appear in a
sans-serif font
56
Creating Lists
HTML supports three kinds of lists:
an ordered list, which is used to display information in a
numeric order
an unordered list, which list items are not listed in a
particular order i.e. bullets
a definition list, which is a list of terms, each followed by
a definition line that is typically indented slightly to the
right
57
Ordered Lists
61
A Text Table
62
A Graphical Table
This figure shows a graphical table
63
Considerations for
Text and Graphical Tables
64
Using Fixed-Width Fonts
When you create a text table, the font you use is important.
A text table relies on space and the characters that fill those
spaces to create its column boundaries.
Use a fixed-width, or mono-space, font so that the columns align
properly.
Fixed-width fonts use the same amount of space for each
character.
65
Using Proportional Fonts
66
Column Alignment
Problems
with Proportional Columns look
Fonts aligned
Columns lose
alignment
67
Column Alignment
with Fixed-Width
Fonts Columns align
regardless of font
This figure shows fixed- size
width fonts, which the
columns remain aligned
regardless of font size.
68
Using the <pre> Tag
70
Text Table as it Appears
in the Browser
table text
appears in a
fixed width
font
71
Defining a Table Structure
72
Using the <table>,
<tr>, and <td> Tags
73
The Graphical Table Syntax
The general syntax of a graphical table is:
<table>
<tr>
<td> First Cell </td>
<td> Second Cell </td>
</tr>
<tr>
<td> Third Cell </td>
<td> Fourth Cell </td>
</tr>
</table> 74
A Simple Table
two rows
two columns
75
Columns within a Table
76
HTML Structure of a Table
beginning of the
table structure
table cells
You do not need to
indent the <td> tags
or place them on
first row of six separate lines, but you
in the table may find it easier to
interpret your code if
you do so.
77
Completed HTML Table Tags
78
Creating Headings with the
<th> Tag
79
Adding Table Headings to the
Table
Text in cells
formatted with the
<th> tag is bold and
centered above each table headings
table column.
80
Result of Table Headings
as Displayed in the Browser
table headings
appear bold and
centered over their
columns
81
Creating a Table Caption
82
Inserting a Table Caption
caption text
83
Result of a Table Caption
table caption
84
Modifying the Appearance of
a Table
85
Adding a Table Border
86
Tables with Different Borders
Values
This figure shows the effect on a table’s border when the border size is varied.
87
Adding a 5-Pixel
Border to a Table
88
Controlling Cell Spacing
89
Tables with Different
Cell Spacing Values
This figure shows how different cell spacing values affect a table’s appearance.
90
Setting the Cell
Spacing to 0 Pixels
91
Defining Cell Padding
To control the space between the table text and the cell borders,
add the cellpadding attribute to the table tag.
The syntax for this attribute is: <table cellpadding=“value”>
value is the distance from the table text to the cell border, as
measured in pixels
the default cell padding value is 1 pixel
Cell padding refers to the space within the cells.
This figure shows the effect of changing the cell padding value for a table.
93
Setting the Cell
Padding to 4 Pixels
94
Table Frames and Rules
Two additional table attributes introduced in
HTML 4.0 are the frames and rules attributes.
With the frame and rule attributes you can
control how borders and gridlines are applied to
the table.
The frames attribute allows you to determine
which sides of the table will have borders.
The frame attribute syntax is: <table
frame=“type”>
type is either “box” (the default), “above”,
“below”, “hsides”, “vsides”, “lhs”, “rhs”, or “void”
95
Values of the Frame Attribute
This figure describes each of the values of the frame attribute.
96
Effect of Different Frame Values
This figure shows the effect of each of the frame values on the table grid.
97
Creating Frames and Rules
Continued
98
Effect of Different Rules Values
This figure shows the effect of each of the rules attribute values on a table.
99
Working with Table and Cell
Size
100
Working with Table
and Cell Size Continued
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.
It is important to manually define the size of the table cells and the table as a
whole.
101
An Example of
Changing
a Table and Cell
Size
102
Defining the Table Size
103
Defining Cell and Column Sizes
104
Defining Cell and
Column Sizes Continued
105
Aligning a Table on the Web
Page
To align a table with the surrounding text, use the align
attribute as follows: align=“alignment”
alignment equals “left”, “right”, or “center”
left or right alignment places the table on the margin of the
Web page and wraps surrounding text to the side
center alignment places the table in the horizontal center of
the page, but does not allow text to wrap around it
The align attribute is similar to the align attribute used with
the <img> tag.
106
Results of a Right-
Aligned Table
This figure
shows a right-
aligned table.
107
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.
108
Values of the Align
and Valign
Attributes
109
Right-Aligning the
Values
in a Column
right-aligned column
110
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
111
Spanning Rows and
Columns Continued
112
Example of Spanning Cells
This figure shows a table of opinion poll data in which some
of the cells span several rows and/or columns.
This cell spans
two columns this cell
and two rows spans three
columns
113
A Table Structure with a
Row-Spanning Cell
four table cells in
the first row
HTML code
resulting table
114
Results of a Table with
Spanning Cells
This figure shows a table with spanning cells.
spanning cells
115
Applying a Background Color
Table elements support the bgcolor attribute.
To specify a background color for all of the cells in a table, all of the cells in
a row, or for individual cells, by adding the bgcolor attribute to either the
<table>, <tr>, <td>, or <th> tags as follows:
<table bgcolor=“color”>
<tr bgcolor=“color”>
<td bgcolor=“color”>
<th bgcolor=“color”>
color is either a color name or hexadecimal color value
116
Results of a Table
with a Colored Background
117
The bordercolor Attribute
118
Applying a Table Background
119
Applying a Background Image
to a Table, Row, and Cell
This figure shows examples of the background attribute applied to three sample tables.
120
Images