Top Banner
1 20-753: Fundamentals of Web Programming Lecture 4: HTML Basics I Copyright © 1999, Carnegie Mellon. All Rights Reserved. Fundamentals of Web Programming Lecture 4: HTML Basics I
43

Fundamentals of Web Programming

Jan 07, 2016

Download

Documents

Fundamentals of Web Programming. Lecture 4: HTML Basics I. Today’s Topics. Tag Anatomy 101 Specific HTML Tags Document Structure Text-level Formatting. HTML: H yper T ext M arkup L anguage. Web pages are written in HTML HTML is plain text containing: HTML tags user-defined text fields - PowerPoint PPT Presentation
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Fundamentals of Web Programming

120-753: Fundamentals of Web Programming

Lecture 4: HTML Basics I

Copyright © 1999, Carnegie Mellon. All Rights Reserved.

Fundamentals ofWeb Programming

Lecture 4: HTML Basics I

Page 2: Fundamentals of Web Programming

220-753: Fundamentals of Web Programming

Lecture 4: HTML Basics I

Copyright © 1999, Carnegie Mellon. All Rights Reserved.

Today’s Topics

• Tag Anatomy 101• Specific HTML Tags

– Document Structure– Text-level Formatting

Page 3: Fundamentals of Web Programming

320-753: Fundamentals of Web Programming

Lecture 4: HTML Basics I

Copyright © 1999, Carnegie Mellon. All Rights Reserved.

HTML: HyperText Markup Language

• Web pages are written in HTML• HTML is plain text containing:

– HTML tags– user-defined text fields

• Tags = Markup• Hypertext = Tagged Text

– specifically, with anchor <A> tags linking to other documents

Page 4: Fundamentals of Web Programming

420-753: Fundamentals of Web Programming

Lecture 4: HTML Basics I

Copyright © 1999, Carnegie Mellon. All Rights Reserved.

Anatomy of a Tag

• Keyword: the tag’s name– e.g., the keyword of the <I> tag is ‘I’

• Type: container or standalone– container: turn an effect on/off

e.g. <I>italic text</I>– standalone: a single element

e.g. <IMG SRC=“pic.gif”>

• Function: describe element / effect

Page 5: Fundamentals of Web Programming

520-753: Fundamentals of Web Programming

Lecture 4: HTML Basics I

Copyright © 1999, Carnegie Mellon. All Rights Reserved.

Anatomy [2]

• Syntax: rules which define how the tag is constructed

• Attributes– modify the tag’s effect or element– closed-value vs. user-defined values– required vs. optional

• Sample Use• Related Tags

Page 6: Fundamentals of Web Programming

620-753: Fundamentals of Web Programming

Lecture 4: HTML Basics I

Copyright © 1999, Carnegie Mellon. All Rights Reserved.

Attributes

• Define content<IMG SRC=“pic.gif”>

• Modify effect<IMG SRC=“pic.gif” ALIGN=LEFT>

• Closed-valueTOP|MIDDLE|BOTTOM|LEFT|RIGHT

• User-defined values– character strings, integers, etc.

Page 7: Fundamentals of Web Programming

720-753: Fundamentals of Web Programming

Lecture 4: HTML Basics I

Copyright © 1999, Carnegie Mellon. All Rights Reserved.

Document Structure Tags

• <HTML>, <HEAD>, <BODY>• <BASE>, <META>, <LINK>,

<SCRIPT>, <STYLE>, <TITLE>

Page 8: Fundamentals of Web Programming

820-753: Fundamentals of Web Programming

Lecture 4: HTML Basics I

Copyright © 1999, Carnegie Mellon. All Rights Reserved.

Tag: <HTML>

• Type: container• Function: declares document to be

HTML; all content contained inside• Syntax: <HTML>…</HTML>• Attributes: none• Related Tags: <!DOCTYPE>

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0//EN”>

Page 9: Fundamentals of Web Programming

920-753: Fundamentals of Web Programming

Lecture 4: HTML Basics I

Copyright © 1999, Carnegie Mellon. All Rights Reserved.

Tag: <HEAD>

• Type: container• Function: contains tags comprising

the document head• Syntax: <HEAD>…</HEAD>• Attributes: none• Related Tags: <BASE>,

<ISINDEX>, <LINK>, <META>, <SCRIPT>, <STYLE>, <TITLE>

Page 10: Fundamentals of Web Programming

1020-753: Fundamentals of Web Programming

Lecture 4: HTML Basics I

Copyright © 1999, Carnegie Mellon. All Rights Reserved.

Tag: <BASE>

• Type: standalone• Function: set global HREF, TARGET

– HREF used when computing relative URL references

– TARGET used when computing frame references for linked documents

• Syntax: <BASE HREF=“base_URL”><BASE TARGET=“frame_name”>

Page 11: Fundamentals of Web Programming

1120-753: Fundamentals of Web Programming

Lecture 4: HTML Basics I

Copyright © 1999, Carnegie Mellon. All Rights Reserved.

Tag: <BASE>

• Attributes– only one attribute per tag instance– two tags to set defaults for both HREF

& TARGET

Page 12: Fundamentals of Web Programming

1220-753: Fundamentals of Web Programming

Lecture 4: HTML Basics I

Copyright © 1999, Carnegie Mellon. All Rights Reserved.

Tag: <BASE>

• Example<HEAD><BASE HREF=“http://mysite/”><BASE TARGET=“bigframe”></HEAD><BODY><A HREF=“mypage.html”></BODY>

Page 13: Fundamentals of Web Programming

1320-753: Fundamentals of Web Programming

Lecture 4: HTML Basics I

Copyright © 1999, Carnegie Mellon. All Rights Reserved.

Tag: <BASE>

• Equivalent to:<HEAD></HEAD><BODY><A TARGET=“bigframe” HREF=“http://mysite/mypage.html”></BODY>

Page 14: Fundamentals of Web Programming

1420-753: Fundamentals of Web Programming

Lecture 4: HTML Basics I

Copyright © 1999, Carnegie Mellon. All Rights Reserved.

Tag: <META>

• Type: standalone• Function:

– declares document meta-information: keywords, expiration date, author, page generator, etc.

– also used to implement client pull (dynamic update after a delay)

Page 15: Fundamentals of Web Programming

1520-753: Fundamentals of Web Programming

Lecture 4: HTML Basics I

Copyright © 1999, Carnegie Mellon. All Rights Reserved.

Tag: <META>

• Syntax:

<META HTTP-EQUIV=“header” CONTENT=“value”>

<META NAME=“name” CONTENT=“value”>

Page 16: Fundamentals of Web Programming

1620-753: Fundamentals of Web Programming

Lecture 4: HTML Basics I

Copyright © 1999, Carnegie Mellon. All Rights Reserved.

Tag: <META>

• Attributes:– HTTP-EQUIV - specify type of HTTP

header to send with the document; commonly REFRESH or EXPIRES

– NAME - specifies the document meta-variable you wish to specify: AUTHOR, KEYWORDS, GENERATOR, DESCRIPTION

Page 17: Fundamentals of Web Programming

1720-753: Fundamentals of Web Programming

Lecture 4: HTML Basics I

Copyright © 1999, Carnegie Mellon. All Rights Reserved.

Tag: <META>

• Attributes (cont.):– SCHEME - information on how to

interpret the meta-variable– CONTENT - specifies either the HTTP

header or the value of the meta-variable

Page 18: Fundamentals of Web Programming

1820-753: Fundamentals of Web Programming

Lecture 4: HTML Basics I

Copyright © 1999, Carnegie Mellon. All Rights Reserved.

Tag: <META>

• Example<HEAD><META HTTP-EQUIV=“Refresh” CONTENT=“10, URL=http://mysite/next.html”><META NAME=“KEYWORDS” CONTENT=“web programming, Java”></HEAD>

Page 19: Fundamentals of Web Programming

1920-753: Fundamentals of Web Programming

Lecture 4: HTML Basics I

Copyright © 1999, Carnegie Mellon. All Rights Reserved.

Tag: <LINK>

• Type: standalone• Function: denotes the linking

relationship between two files• Syntax:

<LINK HREF=“linked_file” TITLE=“title” REL=“forward_rel” REV=“reverse_rel”>

Page 20: Fundamentals of Web Programming

2020-753: Fundamentals of Web Programming

Lecture 4: HTML Basics I

Copyright © 1999, Carnegie Mellon. All Rights Reserved.

Tag: <LINK>

• Attributes:– HREF - URL of the file referred to– TITLE - give the link a description– REL - relation from this to that– REV - relation from that to this

Page 21: Fundamentals of Web Programming

2120-753: Fundamentals of Web Programming

Lecture 4: HTML Basics I

Copyright © 1999, Carnegie Mellon. All Rights Reserved.

Tag: <LINK>

• Example:<HEAD><LINK HREF=“style.css” REL=“Stylesheet”><LINK HREF=“/index.html” REL=“Home”></HEAD>

Page 22: Fundamentals of Web Programming

2220-753: Fundamentals of Web Programming

Lecture 4: HTML Basics I

Copyright © 1999, Carnegie Mellon. All Rights Reserved.

Tag: <SCRIPT>

• Type: container• Function: contains script code

referenced in the <BODY>• Syntax:

<SCRIPT LANGUAGE=“name”>… </SCRIPT>

Page 23: Fundamentals of Web Programming

2320-753: Fundamentals of Web Programming

Lecture 4: HTML Basics I

Copyright © 1999, Carnegie Mellon. All Rights Reserved.

Tag: <SCRIPT>

• Attributes:– DEFER - browser can render first– LANGUAGE - what scripting language

(deprecated)– SRC - URL of (remote) script code– TYPE - MIME type of script code

(required in HTML 4.0)text/javascripttext/vbscript

Page 24: Fundamentals of Web Programming

2420-753: Fundamentals of Web Programming

Lecture 4: HTML Basics I

Copyright © 1999, Carnegie Mellon. All Rights Reserved.

Tag: <STYLE>

• Type: container• Function: specifies style

information for the document• Syntax:

<STYLE TYPE=“mime_type” MEDIA=“media_type” TITLE=“title”>… </STYLE>

Page 25: Fundamentals of Web Programming

2520-753: Fundamentals of Web Programming

Lecture 4: HTML Basics I

Copyright © 1999, Carnegie Mellon. All Rights Reserved.

Tag: <STYLE>

• Attributes:– MEDIA - what media types the styles

are to be used for (visual browser, speech-based browser, Braille, etc.)

– TITLE - provide a descriptive label– TYPE - content type for the style

language

Page 26: Fundamentals of Web Programming

2620-753: Fundamentals of Web Programming

Lecture 4: HTML Basics I

Copyright © 1999, Carnegie Mellon. All Rights Reserved.

Tag: <STYLE>

• Example:<STYLE TYPE=“text/css1”>H1 {font: 16 pt Palatino; color: blue}H2 {font: 14 pt Palatino; color: AA4D60}H3 {font: 12 pt Palatino; color: black; font-weight: bold}</STYLE>

Page 27: Fundamentals of Web Programming

2720-753: Fundamentals of Web Programming

Lecture 4: HTML Basics I

Copyright © 1999, Carnegie Mellon. All Rights Reserved.

Tag: <TITLE>

• Type: container• Function: give the document a

descriptive title (used in history list, title bar, bookmarks, etc.

• Syntax: <TITLE>… </TITLE>• Attributes: none• Example:

<TITLE>Web Site Tips</TITLE>

Page 28: Fundamentals of Web Programming

2820-753: Fundamentals of Web Programming

Lecture 4: HTML Basics I

Copyright © 1999, Carnegie Mellon. All Rights Reserved.

Tag: <BODY>

• Type: container• Function: contains all text and tags

inside the document

Page 29: Fundamentals of Web Programming

2920-753: Fundamentals of Web Programming

Lecture 4: HTML Basics I

Copyright © 1999, Carnegie Mellon. All Rights Reserved.

Tag: <BODY>

• Syntax:<BODY BGCOLOR=“color” BACKGROUND=“image” LINK=“link_color” ALINK=“active_link_color” VLINK=“visited_link_color” TEXT=“text_color”> … </BODY>

Page 30: Fundamentals of Web Programming

3020-753: Fundamentals of Web Programming

Lecture 4: HTML Basics I

Copyright © 1999, Carnegie Mellon. All Rights Reserved.

Colors

• Color attributes can be:– one of the 16 reserved color names:

BLACK, WHITE, AQUA, SILVER, GRAY, MAROON, RED, PURPLE, FUSCHIA, GREEN, LIME, OLIVE, YELLOW, NAVY, BLUE, TEAL

– specified by an RBG hexadecimal triplet: e.g., #FFFFFF (white)

Page 31: Fundamentals of Web Programming

3120-753: Fundamentals of Web Programming

Lecture 4: HTML Basics I

Copyright © 1999, Carnegie Mellon. All Rights Reserved.

Tag: <BODY>

• Attributes:– ALINK - link color when clicked– BACKGROUND - URL of an image to

use (will be tiled to fit)– BGCOLOR - background color– LINK - link color (unvisited)– TEXT - default text color– VLINK - link color (visited)

Page 32: Fundamentals of Web Programming

3220-753: Fundamentals of Web Programming

Lecture 4: HTML Basics I

Copyright © 1999, Carnegie Mellon. All Rights Reserved.

Text-Level Format Tags

• <B>, <BASEFONT>, <BIG>, <FONT>, <I>, <S>, <SMALL>, <SUB>, <SUP>, <TT>, <U>, <ACRONYM>, <ADDRESS>, <CITE>, <CODE>, <DEL>, <DFN>, <EM>, <INS>, <KBD>, <Q>, <SAMP>, <STRONG>, <VAR>

Page 33: Fundamentals of Web Programming

3320-753: Fundamentals of Web Programming

Lecture 4: HTML Basics I

Copyright © 1999, Carnegie Mellon. All Rights Reserved.

Appearance Tags

• <B>Bold Text</B>• <BIG>Bigger Text</BIG>• <I>Italic Text</I>• <S>Stricken Text</S>• <SMALL>Smaller Text</SMALL>• <SUB>Subscript</SUB>• <SUP>Superscript</SUB>

Page 34: Fundamentals of Web Programming

3420-753: Fundamentals of Web Programming

Lecture 4: HTML Basics I

Copyright © 1999, Carnegie Mellon. All Rights Reserved.

Appearance Tags

• <TT>Fixed-width Chars</TT>• <U>Underlined Text</U>

Page 35: Fundamentals of Web Programming

3520-753: Fundamentals of Web Programming

Lecture 4: HTML Basics I

Copyright © 1999, Carnegie Mellon. All Rights Reserved.

Phrase Formatting

• <ACRONYM>HTML</ACRONYM>• <ADDRESS>email</ADDRESS>• <CITE>citation</CITE>• <CODE>Code Sample</CODE>• <DEL>deleted text</DEL>• <DFN>defining instance</DFN>• <EM>Emphasized Text</EM>

Page 36: Fundamentals of Web Programming

3620-753: Fundamentals of Web Programming

Lecture 4: HTML Basics I

Copyright © 1999, Carnegie Mellon. All Rights Reserved.

Phrase Formatting

• <INS>new text</INS>• <KBD>keyed input</KBD>• <Q CITE=“url”>quote</Q> • <SAMP>output</SAMP>• <STRONG>emphasis!</STRONG>• <VAR>variable</VAR>

Page 37: Fundamentals of Web Programming

3720-753: Fundamentals of Web Programming

Lecture 4: HTML Basics I

Copyright © 1999, Carnegie Mellon. All Rights Reserved.

Font Control

• <BASEFONT>, <FONT>

Page 38: Fundamentals of Web Programming

3820-753: Fundamentals of Web Programming

Lecture 4: HTML Basics I

Copyright © 1999, Carnegie Mellon. All Rights Reserved.

Tag: <BASEFONT>

• Type: standalone• Function: set default size, color,

typeface for <BODY>• Syntax:

<BASEFONT SIZE=“size” COLOR=“color” FACE=“list_typefaces”>

Page 39: Fundamentals of Web Programming

3920-753: Fundamentals of Web Programming

Lecture 4: HTML Basics I

Copyright © 1999, Carnegie Mellon. All Rights Reserved.

Tag: <BASEFONT>

• Attributes:– COLOR - one of 16 reserved names or

an RGB hexadecimal triplet– FACE - list of typefaces (uses first

available)– SIZE - integer value from 1 to 7

(default is 3); mapped to point size by browser according to user preferences

Page 40: Fundamentals of Web Programming

4020-753: Fundamentals of Web Programming

Lecture 4: HTML Basics I

Copyright © 1999, Carnegie Mellon. All Rights Reserved.

Tag: <BASEFONT>

• Example<BASEFONT SIZE=5 COLOR=“navy” FACE=“Arial,Helvetica”>

Page 41: Fundamentals of Web Programming

4120-753: Fundamentals of Web Programming

Lecture 4: HTML Basics I

Copyright © 1999, Carnegie Mellon. All Rights Reserved.

Tag: <FONT>

• Type: container• Function: modify font properties of

the contained text• Syntax:

<FONT SIZE=“size” COLOR=“color” FACE=“list_typefaces”>… </FONT>

Page 42: Fundamentals of Web Programming

4220-753: Fundamentals of Web Programming

Lecture 4: HTML Basics I

Copyright © 1999, Carnegie Mellon. All Rights Reserved.

Tag: <FONT>

• Attributes: – COLOR - one of 16 reserved names or

an RGB hexadecimal triplet– FACE - list of typefaces (uses first

available)– SIZE - integer value from 1 to 7; or

increment / decrement relative to base font

Page 43: Fundamentals of Web Programming

4320-753: Fundamentals of Web Programming

Lecture 4: HTML Basics I

Copyright © 1999, Carnegie Mellon. All Rights Reserved.

Tag: <FONT>

• Example<FONT SIZE=“+1” COLOR=“red”>Warning!</FONT>