30
Oct 6 html @ university of wa shington 1 The Information School of the University of Washington Hypertext Markup Language INFO/CSE 100, Fall 2006 Fluency in Information Technology http://courses.washington.edu/info100/

The Information School of the University of Washington Oct 6html @ university of washington1 Hypertext Markup Language INFO/CSE 100, Fall 2006 Fluency

  • View
    214

  • Download
    0

Embed Size (px)

Citation preview

Page 1: The Information School of the University of Washington Oct 6html @ university of washington1 Hypertext Markup Language INFO/CSE 100, Fall 2006 Fluency

Oct 6 html @ university of washington 1

Th

e I

nfo

rmati

on

Sch

ool

of

the

Un

ivers

ity o

f W

ash

ing

ton

Hypertext Markup Language

INFO/CSE 100, Fall 2006Fluency in Information Technology

http://courses.washington.edu/info100/

Page 2: The Information School of the University of Washington Oct 6html @ university of washington1 Hypertext Markup Language INFO/CSE 100, Fall 2006 Fluency

Oct 6 html @ university of washington 2

Th

e I

nfo

rmati

on

Sch

ool

of

the U

niv

ers

ity o

f W

ash

ing

ton

Readings and References• Reading

– Fluency with Information Technology»Chapter 4, Marking up with HTML

• References– World Wide Web Consortium

»"The World Wide Web Consortium (W3C) develops interoperable technologies (specifications, guidelines, software, and tools) to lead the Web to its full potential."

»http://www.w3.org/»http://w3c.org/MarkUp/Activity»http://w3c.org/MarkUp/Guide/

Page 3: The Information School of the University of Washington Oct 6html @ university of washington1 Hypertext Markup Language INFO/CSE 100, Fall 2006 Fluency

Oct 6 html @ university of washington 3

Th

e I

nfo

rmati

on

Sch

ool

of

the U

niv

ers

ity o

f W

ash

ing

ton

Client/Server Interaction

• For Web pages, the client requests a page the server returns it: there’s no permanent connection, just a short conversation– Details of the conversation are specified

by HTTPClient

Server Client

ClientClient

Client

Client Client

Server

Client

ServerServer

Server

ServerServer

Server

requestreply

Page 4: The Information School of the University of Washington Oct 6html @ university of washington1 Hypertext Markup Language INFO/CSE 100, Fall 2006 Fluency

Oct 6 html @ university of washington 4

Th

e I

nfo

rmati

on

Sch

ool

of

the U

niv

ers

ity o

f W

ash

ing

ton

Simple HTTP Request

GET /pub/WWW/TheProject.html HTTP/1.1

Host: www.w3.org

methodrequest

protocol

host

Page 5: The Information School of the University of Washington Oct 6html @ university of washington1 Hypertext Markup Language INFO/CSE 100, Fall 2006 Fluency

Oct 6 html @ university of washington 5

Th

e I

nfo

rmati

on

Sch

ool

of

the U

niv

ers

ity o

f W

ash

ing

tonA Typical Browser

RequestGET /pub/WWW/TheProject.html HTTP/1.1

Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, application/x-shockwave-flash, */*

Accept-Language: en-us

Accept-Encoding: gzip, dflate

User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; APC)

Host: www.w3.org

Connection: Keep-Alive

Page 6: The Information School of the University of Washington Oct 6html @ university of washington1 Hypertext Markup Language INFO/CSE 100, Fall 2006 Fluency

Oct 6 html @ university of washington 6

Th

e I

nfo

rmati

on

Sch

ool

of

the U

niv

ers

ity o

f W

ash

ing

ton

Server ResponseHTTP/1.1 200 OKDate: Monday, 23 May 2005 22:38:34 GMTServer: Apache/1.3.27 (Unix) (Red-Hat/Linux)Last-Modified: Wed, 08 Jan 2003 23:11:55 GMTEtag: "3f80f-1b6-3e1cv03b"Accept-Ranges: bytesContent-Length: 438Connection: closeContent-Type: text/html

<html><head><title>A Sample Page</title></head><body>…

Page 7: The Information School of the University of Washington Oct 6html @ university of washington1 Hypertext Markup Language INFO/CSE 100, Fall 2006 Fluency

Web Pages in HTML

<html> <head><title>Writer's Anecdotes</title></head> <body bgcolor="white" text="black"><font face="Helvetica"> <img src="images/awa.png"v> <table> <tr> <td><a href="hdt.html">Thoreau</a></td> <td><a href="ed.html">Dickinson</a></td>

<td><a href="hwl.html">Longfellow</a></td> <td><a href="lma.html">Alcott</a></td>

<td><a href="sc.html">Twain</a></td> <td><a href="wf.html">Faulkner</a></td> <td><a href="rf.html">Frost</a></td>

<td><a href="eh.html">Hemingway</a></td> <td><a href="js.html">Steinbeck</a></td> </tr> </table> <h2>Steinbeck</h2>

<p>Steinbeck traveled to Russia several times, butnever mastered the langauge. Traveling withphotographer Robert Capa in 1947 he wrote, "...Iadmit our Russian is limited, but we can say hello,come in, you are beautiful, oh no you don't, and onewhich charms us but seems to have an applicationrarely needed, 'The thumb is second cousin to theleft foot.' We don't use that one much."</p>

</body></html>

Page 8: The Information School of the University of Washington Oct 6html @ university of washington1 Hypertext Markup Language INFO/CSE 100, Fall 2006 Fluency

Oct 6 html @ university of washington 8

Th

e I

nfo

rmati

on

Sch

ool

of

the U

niv

ers

ity o

f W

ash

ing

ton

Web Page Viewers - All Different Formats

Page 9: The Information School of the University of Washington Oct 6html @ university of washington1 Hypertext Markup Language INFO/CSE 100, Fall 2006 Fluency

Oct 6 html @ university of washington 9

Th

e I

nfo

rmati

on

Sch

ool

of

the U

niv

ers

ity o

f W

ash

ing

ton

HTML Must Be Text

• Word processors insert formatting tags, confusing browsers

»Create source in NotePad, jEdit, etc.»Save in Text or txt format»Save with file extension .html

Avoid Confusion

Page 10: The Information School of the University of Washington Oct 6html @ university of washington1 Hypertext Markup Language INFO/CSE 100, Fall 2006 Fluency

Oct 6 html @ university of washington 10

Th

e I

nfo

rmati

on

Sch

ool

of

the U

niv

ers

ity o

f W

ash

ing

ton

The SourceThe HTML code producing a page is the source which can always be viewed, either in the browser or in an editor

Page 11: The Information School of the University of Washington Oct 6html @ university of washington1 Hypertext Markup Language INFO/CSE 100, Fall 2006 Fluency

Oct 6 html @ university of washington 11

Th

e I

nfo

rmati

on

Sch

ool

of

the U

niv

ers

ity o

f W

ash

ing

ton

HTML Structure• All HTML files use the same basic

structure: <html> <head> <title>Name of Page Goes Here </title> Heading content goes here </head> <body> Body content goes here </body></html>

Page 12: The Information School of the University of Washington Oct 6html @ university of washington1 Hypertext Markup Language INFO/CSE 100, Fall 2006 Fluency
Page 13: The Information School of the University of Washington Oct 6html @ university of washington1 Hypertext Markup Language INFO/CSE 100, Fall 2006 Fluency

Oct 6 html @ university of washington 13

Th

e I

nfo

rmati

on

Sch

ool

of

the U

niv

ers

ity o

f W

ash

ing

ton

HTML Tags

• Anatomy of an HTML tag– <element attribute=“value”></element>– <img src=“mypic.jpg” alt=“my pic” />

• Types of tags– Normally has an open AND a close element– Some can open and close at the same time– Some tags do not close at all (ex. Comment

tag)

• Sometimes have Attributes– Name-value pairs, values in quotes– Some are required, some optional

Page 14: The Information School of the University of Washington Oct 6html @ university of washington1 Hypertext Markup Language INFO/CSE 100, Fall 2006 Fluency

Oct 6 html @ university of washington 14

Th

e I

nfo

rmati

on

Sch

ool

of

the U

niv

ers

ity o

f W

ash

ing

ton

More HTML Tags• Styles Tags

– <b> bold, <i> italic, <big> big, <small> small

• Spacing Tags– <p> paragraph, <br /> line break, <hr /> horizontal rule

• Heading tags– <h1>, <h2>, <h3> header format

• List tags– <ol> ordered list, <li> list item– <ul> unordered (bulleted) list, <li> list item

• References– < a href=“http://www.cnn.com”> anchor reference– <img src=“…” alt=“…” /> image reference

• Comments– <!-- --> Comments

Page 15: The Information School of the University of Washington Oct 6html @ university of washington1 Hypertext Markup Language INFO/CSE 100, Fall 2006 Fluency

Oct 6 html @ university of washington 15

Th

e I

nfo

rmati

on

Sch

ool

of

the U

niv

ers

ity o

f W

ash

ing

ton

First HTML Web Page

This HTML code produces this result

Page 16: The Information School of the University of Washington Oct 6html @ university of washington1 Hypertext Markup Language INFO/CSE 100, Fall 2006 Fluency

Oct 6 html @ university of washington 16

Th

e I

nfo

rmati

on

Sch

ool

of

the U

niv

ers

ity o

f W

ash

ing

ton

Add An Image

• Images are encoded many ways:– GIF -- Graphics Interchange Format -- is for

diagrams and simple drawings– PNG -- Portable Network Graphics - GIF

without patent problems– JPEG -- Joint Photographic Experts Group -- is

for high resolution photos, complex art

• Image tags for placing images– <img src=”ski.jpg" alt=”I like to ski" />

tag attribute name attribute value

Page 17: The Information School of the University of Washington Oct 6html @ university of washington1 Hypertext Markup Language INFO/CSE 100, Fall 2006 Fluency

Oct 6 html @ university of washington 17

Th

e I

nfo

rmati

on

Sch

ool

of

the U

niv

ers

ity o

f W

ash

ing

ton

File Locations

• The path must say how to reach the file– When the file is in the directory as the web

page, just give the file name, ski.jpg– If the file is in a subdirectory, say how to

navigate to it, pix/ski.jpg– If the file is in a superdirectory, move up

using dot-dot notation, ../ski.jpgThe most common reason that an image is not displayed is the path is wrong … check!

Page 18: The Information School of the University of Washington Oct 6html @ university of washington1 Hypertext Markup Language INFO/CSE 100, Fall 2006 Fluency

Oct 6 html @ university of washington 18

Th

e I

nfo

rmati

on

Sch

ool

of

the U

niv

ers

ity o

f W

ash

ing

ton

Anchors• The link starts with an a tag…

<a href=" ... ">

• The value of the href attribute is a URL. <a href="http://www.cs.washington.edu">

• The link encloses some text, and ends with… <a href=" ... ">CSE home page</a>

Page 19: The Information School of the University of Washington Oct 6html @ university of washington1 Hypertext Markup Language INFO/CSE 100, Fall 2006 Fluency

Oct 6 html @ university of washington 19

Th

e I

nfo

rmati

on

Sch

ool

of

the U

niv

ers

ity o

f W

ash

ing

ton

Types of URLS

• http://www.site.com/dir/file.html• http://www.site.com/dir/• ftp://ftp.site.come/pub/• news:soc.culture.religion• mailto:[email protected]

du• file:///hardisk/path/file.html

Page 20: The Information School of the University of Washington Oct 6html @ university of washington1 Hypertext Markup Language INFO/CSE 100, Fall 2006 Fluency
Page 21: The Information School of the University of Washington Oct 6html @ university of washington1 Hypertext Markup Language INFO/CSE 100, Fall 2006 Fluency

Oct 6 html @ university of washington 21

Th

e I

nfo

rmati

on

Sch

ool

of

the U

niv

ers

ity o

f W

ash

ing

ton

Simple HTML• What we’ve seen here is very simple HTML• HTML is changing

– Each document should start with a “DOCTYPE” comment telling which version of HTML it follows

» http://www.w3.org/QA/2002/04/valid-dtd-list.html » We used HTML 4.01 Transitional

– There is a validator service that will check your page

» http://validator.w3.org/

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

Page 22: The Information School of the University of Washington Oct 6html @ university of washington1 Hypertext Markup Language INFO/CSE 100, Fall 2006 Fluency
Page 23: The Information School of the University of Washington Oct 6html @ university of washington1 Hypertext Markup Language INFO/CSE 100, Fall 2006 Fluency

Oct 6 html @ university of washington 23

Th

e I

nfo

rmati

on

Sch

ool

of

the U

niv

ers

ity o

f W

ash

ing

ton

Editing byHand vs. a Tool

• WYSIWYG type tools– What you see is what you get

• Tools for editing web pages:– Microsoft FrontPage - $$$– Macromedia DreamWeaver - $$$– Amaya - Free

»http://www.w3.org/Amaya/

– And MANY MANY others!• Pick the right tool for you!

Page 24: The Information School of the University of Washington Oct 6html @ university of washington1 Hypertext Markup Language INFO/CSE 100, Fall 2006 Fluency

Oct 6 html @ university of washington 24

Th

e I

nfo

rmati

on

Sch

ool

of

the U

niv

ers

ity o

f W

ash

ing

ton

Questions

• Explain why a page needs to be reloaded in a browser to see the results of editing changes made in the text editor of an HTML document.

Page 25: The Information School of the University of Washington Oct 6html @ university of washington1 Hypertext Markup Language INFO/CSE 100, Fall 2006 Fluency

Oct 6 html @ university of washington 25

Th

e I

nfo

rmati

on

Sch

ool

of

the U

niv

ers

ity o

f W

ash

ing

ton

Questions

• Why learn HTML at all if authoring tools will do the work for you?

• Give other examples of where you are expected to learn something when there are tools available that will do the work.

Page 26: The Information School of the University of Washington Oct 6html @ university of washington1 Hypertext Markup Language INFO/CSE 100, Fall 2006 Fluency

Oct 6 html @ university of washington 26

Th

e I

nfo

rmati

on

Sch

ool

of

the U

niv

ers

ity o

f W

ash

ing

ton

Questions

• Why do we need to end a tag?

Page 27: The Information School of the University of Washington Oct 6html @ university of washington1 Hypertext Markup Language INFO/CSE 100, Fall 2006 Fluency

Oct 6 html @ university of washington 27

Th

e I

nfo

rmati

on

Sch

ool

of

the U

niv

ers

ity o

f W

ash

ing

ton

Questions

• Why were the characters < and > chosen to denote tags?

Page 28: The Information School of the University of Washington Oct 6html @ university of washington1 Hypertext Markup Language INFO/CSE 100, Fall 2006 Fluency

Oct 6 html @ university of washington 28

Th

e I

nfo

rmati

on

Sch

ool

of

the U

niv

ers

ity o

f W

ash

ing

ton

Questions

• How does a web browser know where to get an image from to display on a web page?

Page 29: The Information School of the University of Washington Oct 6html @ university of washington1 Hypertext Markup Language INFO/CSE 100, Fall 2006 Fluency

Oct 6 html @ university of washington 29

Th

e I

nfo

rmati

on

Sch

ool

of

the U

niv

ers

ity o

f W

ash

ing

ton

Wrap-up• HTML forms the basic structure for web pages

– Modern trends are to separate» the structural description of the data» the presentation of the data to the user

– process the information according to the content– display the information as appropriate to the user

Page 30: The Information School of the University of Washington Oct 6html @ university of washington1 Hypertext Markup Language INFO/CSE 100, Fall 2006 Fluency

Oct 6 html @ university of washington 30

Th

e I

nfo

rmati

on

Sch

ool

of

the U

niv

ers

ity o

f W

ash

ing

ton

Summary

• Web pages are written in HTML»The files must be text»The file extension must be .html

• Tags enclose content like parentheses

»Control look with attributes on tags

• Use a change-and-test process• Images have various formats and

you must specify the explicit path to the picture