Web Programming Step by Step, 2nd Edition
Lecture 1: Internet/WWW; Basic HTML
Reading: Ch. 1; 2.1
Except where otherwise noted, the contents of this document are
Copyright 2012 Marty Stepp, Jessica Miller, and Victoria Kirst.
All rights reserved.
Any redistribution, reproduction, transmission, or storage of part
or all of the contents in any form is prohibited without the author's
expressed written permission.
1.1: The Internet
-
1.1: The Internet
-
1.2: The World Wide Web (WWW)
The Internet
- Wikipedia: http://en.wikipedia.org/wiki/Internet
- a connection of computer networks using the Internet Protocol (IP)
- layers of communication protocols: IP → TCP/UDP → HTTP/FTP/POP/SMTP/SSH...
- What's the difference between the Internet and the World Wide Web (WWW)?
- the Web is the collection of web sites and pages around the world; the Internet is larger and also includes other services such as email, chat, online games, etc.
Brief history
- began as a US Department of Defense network called ARPANET (1960s-70s)
- initial services: electronic mail, file transfer
- opened to commercial interests in late 80s
- WWW created in 1989-91 by Tim Berners-Lee
- popular web browsers released: Netscape 1994, IE 1995
- Amazon.com opens in 1995; Google January 1996
- Hamster Dance web page created in 1999

Key aspects of the internet
- subnetworks can stand on their own
- computers can dynamically join and leave the network
- built on open standards; anyone can create a new internet device
- lack of centralized control (mostly)
- everyone can use it with simple, commonly available software
Question
Who "runs" the internet?
Who is responsible for overseeing it?
People and organizations
- Internet Engineering Task Force (IETF): internet protocol standards
- Internet Corporation for Assigned Names and Numbers (ICANN):
decides top-level domain names
- World Wide Web Consortium (W3C): web standards
Internet Protocol (IP)
- a simple protocol for attempting to send data between two computers
- each device has a 32-bit IP address written as four 8-bit numbers (0-255)
- find out your internet IP address: whatismyip.com
- find out your local IP address:
- in a terminal, type:
ipconfig
(Windows) or ifconfig
(Mac/Linux)
Transmission Control Protocol (TCP)
- adds multiplexing, guaranteed message delivery on top of IP
-
multiplexing: multiple programs using the same IP address
- port: a number given to each program or service
- port 80: web browser (port 443 for secure browsing)
- port 25: email
- port 22: ssh
- port 5190: AOL Instant Messenger
- more common ports
- some programs (games, streaming media programs) use simpler UDP protocol instead of TCP
1.2: The World Wide Web (WWW)
-
1.1: The Internet
-
1.2: The World Wide Web (WWW)
-
web server: software that listens for web page requests
- web browser: fetches/displays documents from web servers
Domain Name System (DNS)
- a set of servers that map written names to IP addresses
- Example:
www.cs.washington.edu
→ 128.208.3.88
- many systems maintain a local cache called a hosts file
Question
What is a URL?
- What is an example of a URL you type a lot?
- Why are URLs useful?
Uniform Resource Locator (URL)
Hypertext Transport Protocol
(HTTP)
HTTP error codes
- when something goes wrong, the web server returns a special "error code" number to the browser, possibly followed by an HTML document
- common error codes:
Number | Meaning |
200 |
OK |
301-303 |
page has moved (permanently or temporarily) |
403 |
you are forbidden to access this page |
404 |
page not found |
500 |
internal server error |
complete list |
Web languages / technologies
- Hypertext Markup Language (HTML): used for writing web pages
- Cascading Style Sheets (CSS): stylistic info for web pages
- PHP Hypertext Processor (PHP): dynamically create pages on a web server
- JavaScript: interactive and programmable web pages
- Asynchronous JavaScript and XML (Ajax): accessing data for web applications
- eXtensible Markup Language (XML): metalanguage for organizing data
- Structured Query Language (SQL): interaction with databases
2.1: Basic HTML
-
2.1: Basic HTML
-
2.2: More HTML Elements
-
2.3: Web Standards
Hypertext Markup Language (HTML)
- describes the content and structure of information on a web page
- not the same as the presentation (appearance on screen)
- surrounds text content with opening and closing tags
- each tag's name is called an element
- syntax:
<
element>
content </
element>
- example:
<p>This is a paragraph</p>
- most whitespace is insignificant in HTML (ignored or collapsed to a single space)
- we will use a newer version called HTML5
Structure of an HTML page
<!DOCTYPE html>
<html>
<head>
information about the page
</head>
<body>
page contents
</body>
</html>
- the header describes the page and the body contains the page's contents
- an HTML page is saved into a file ending with extension
.html
DOCTYPE
tag tells browser to interpret our page's code as HTML5, the latest/greatest version of the language
describes the title of the web page
<title>Chapter 2: HTML Basics</title>
- placed within the
head
of the page
- displayed in the web browser's title bar and when bookmarking the page
Paragraph:
<p>
paragraphs of text (block)
<p>You're not your job.
You're not how much money you have in the bank.
You're not the car you drive. You're not the contents
of your wallet. You're not your khakis. You're
the all-singing, all-dancing crap of the world.</p>
headings to separate major areas of the page (block)
<h1>University of Whoville</h1>
<h2>Department of Computer Science</h2>
<h3>Sponsored by Micro$oft</h3>
Horizontal rule:
<hr>
a horizontal line to visually separate sections of a page (block)
<p>First paragraph</p>
<hr />
<p>Second paragraph</p>
- should be immediately closed with
/>
More about HTML tags
- some tags can contain additional information called attributes
- syntax:
<
element attribute="
value"
attribute="
value">
content </
element>
- example:
<a href="page2.html">Next page</a>
- some tags don't contain content; can be opened and closed in one tag
- syntax:
<
element attribute="
value"
attribute="
value" />
- example:
<hr />
- example:
<img src="bunny.jpg" alt="pic from Easter" />
Links:
<a>
links, or "anchors", to other pages (inline)
<p>
Search
<a href="http://www.google.com/">Google</a> or our
<a href="lectures.html">Lecture Notes</a>.
</p>
- uses the
href
attribute to specify the destination URL
-
can be absolute (to another web site) or
relative (to another page on this site)
- anchors are inline elements; must be placed in a block element such as
p
or h1
Block and inline elements (explanation)
- block elements contain an entire large region of content
- examples: paragraphs, lists, table cells
- the browser places a margin of whitespace between block elements for separation
- inline elements affect a small amount of content
- examples: bold text, code fragments, images
- the browser allows many inline elements to appear on the same line
- must be nested inside a block element
inserts a graphical image into the page (inline)
<img src="images/gollum.jpg" alt="Gollum from LOTR" />
- the
src
attribute specifies the image URL
- HTML5 also requires an
alt
attribute describing the image
More about images
<a href="http://theonering.net/">
<img src="images/gandalf.jpg" alt="Gandalf from LOTR"
title="You shall not pass!" />
</a>
- if placed in an
a
anchor, the image becomes a link
title
attribute is an optional tooltip (on ANY element)
Line break:
<br>
forces a line break in the middle of a block element (inline)
<p>Teddy said it was a hat, <br /> So I put it on.</p>
<p>Now Daddy's sayin', <br /> Where the
heck's the toilet plunger gone?</p>
-
Warning: Don't over-use
br
(guideline: more than one in a row is bad)
br
should not be used to separate paragraphs or used multiple times in a row to create spacing
em
: emphasized text (usually rendered in italic)
strong
: strongly emphasized text (usually rendered in bold)
<p>
HTML is <em>really</em>,
<strong>REALLY</strong> fun!
</p>
- as usual, the tags must be properly nested for a valid page
Nesting tags
<p>
HTML is <em>really,
<strong>REALLY</em> lots of</strong> fun!
</p>
- tags must be correctly nested
- (a closing tag must match the most recently opened tag)
- the browser may render it correctly anyway, but it is invalid HTML
-
(how would we get the above effect in a valid way?)
comments to document your HTML file or "comment out" text
<p>CSE courses are a lot of fun!</p>
- many web pages are not thoroughly commented (or at all)
- still useful at top of page and for disabling code
- comments cannot be nested and cannot contain a
--