Ch. 4: HTML
Mississippi College
Computer Science
Dr. Bennet
Schedule
Ch. 1: Computation's Greatest Hits
Ch. 2: User Interface
Ch. 3: Networking
Ch. 4: HTML
Ch. 5: Web Searching
Ch. 7: Bits and Bytes
Ch. 8: Multimedia Encoding
Ch. 6: Debugging
Ch. 9: Executing Instructions
Ch. 10: Algorithms
Programming and Python
Ch. 11: Computers and Society
Ch. 12: Privacy and Security
Ch. 13: Spreadsheets
Ch. 15: Database Introduction
Ch. 22: Limits
HTML = HyperText Markup Language.
Plain text is simply formatted. Example:
Source
Page
Basic markup
Most tags have start and end versions enclosing text.
<tag> . . . </tag>.
Tags are
case-insensitive
.
Spaces and line breaks are ignored; indenting does not matter.
The contents of the file should be enclosed in <html> tags.
Within the <html> pair should be <head> and <body> pairs.
The <title> is displayed on the browser stripe.
<p>, <i>, <b>, <tt>.
The browser has great freedom formatting HTML
Example:
Source
Page
Headings: <h1>, <h2>, <h3>.
Entities.
Starts with
&
.
Stuff that's markup otherwise: Say
<
for
<
Stuff not on the keyboard.
ö
for
ö
.
÷
for
÷
.
λ
for
λ
.
Complete List
.
Example:
Source
Page
Attributes
Specified inside the opening tag.
name=“value”
Modify the behavior of the tag.
Example:
Source
Page
Links
This is the hyper in hypertext: Links take you somewhere else when clicked.
<a href="
URL
">
displayed text
</a>
Displays the text; clicking takes you to the URL
Example:
Source
Page
Style attribute.
The style attribute applies a list of settings that control how the item appears.
Style can contain one setting or a list separated by semicolon.
Alternative to some of the tags we've seen.
Example:
Source
Page
Span and div tags.
CSS
The style attribute is one use of Cascading Style Sheets (CSS). Style can be specified in a number of ways.
A style section in the header applies to the whole document.
Can apply a style to a tag of a given type.
Can assign classes to tags, and styles to classes.
A page can link to a style sheet document.
Allows common styles for all the pages at a site.
Reduces number of bytes the browser must download.
The closest specification wins.
Example:
Source
Page
,
Style Document
,
Images.
<img src="
URL
">
Image stored in a separate file.
Formats: GIF, JPEG, others.
Inserted as a particularly large character.
No </img>.
Example:
Source
Page
URLs for links or images have several forms.
Absolute URL:
http://www.example.com/some/place/there.html
Just goes there.
Others depend on the URL of the page you're coming from. Suppose we're coming from
http://www.example.com/some/random/place/there.html
Relative URLs (file names) are in the same directory. Replace just the last part with the URL.
other.html
goes to
http://www.example.com/some/random/place/other.html
pics/dia.png
goes to
http://www.example.com/some/random/place/pics/dia.png
Starting with a slash just keep the server name.
/a/whole/different/folder.html
goes to
http://www.example.com/a/whole/different/folder.html
.
The
..
goes to the parent folder.
../upper.jpg
goes to
http://www.example.com/some/random/upper.jpg
. Notice that the folder name
place
was removed.
../../meese/moose.html
goes to
http://www.example.com/some/meese/moose.html
Using
..
is the middle is allowed, but generally useless. Do you see why?
Colors.
Sixteen standard HTML color names:
black
silver
white
gray
red
fuchsia
maroon
purple
blue
navy
aqua
teal
lime
green
yellow
olive
Plus 130 CSS standard color names for a total of
147 color names available on all browsers
.
Numeric colors
Specify intensities for each red, blue and green, 0-255.
Can specify the actual number, the percentage, or hexadecimal.
#
=
rgb(
,
,
)
=
rgb(
%,
%,
%)
Hex represents each range as 00 to FF, without separators. More on this in Chapter 7.
The hex form is most commonly used; older browers may not work with the others.
Commonly used in style settings:
color:
,
background-color:
.
Example:
Source
Page
Lists.
<ul> for un-ordered (bullet) lists.
<ol> for ordered (numbered) lists.
List members denoted with <li>.
Example:
Source
Page
Tables
Enclose in <table>.
Tables a sequence of <tr>.
Rows a sequence of <td>.
Various attributes.
Example:
Source
Page