Outline
– Introduction to HTML HyperText Markup Language – Designing Documents for the World Wide Web (HTML) § Creating and publishing a Web page § Validating a document § Main HMTL elements – Block-level HTML elements – Text-level HTML element – Creating hypertext links – Adding images to documents – Building tables
CS 4390 Web Programming Introduction to HTML 2
The World Wide Web The World Wide Web
• Definitions – HTTP § The HyperText Transfer Protocol – request/response model – The World Wide Web § The language used by a WWW client (e.g. Netscape, Internet § The Internet is networks of computers that are connected Explorer) to request documents from a WWW server (i.e. the § The Web is the set of computers on the Internet that support program running at Web sites like amazon.com or yahoo.com) HTTP § A stateless protocol – server does not keep any information § In 1989, Tim Berners-Lee and associates proposed the World about the client after it sends its response Wide Web at CERN, The European High-Energy Physics § Interaction between client and server equires a Center request/response exchange (not like stand alone GUI) § The Web has ability to combine text with graphics and other – HTML multimedia § The HyperText Markup Language § The language used to design web pages
CS 4390 Web Programming Introduction to HTML 3 CS 4390 Web Programming Introduction to HTML 4
HyperText Markup Language HTML Example
• Text Mixed with Markup Tags
Introduction
)Home Page for Lawrence M. Brown
• What Does Markup Describe? – Appearance Senior Network Engineer
– Layout Naval Surface Warfare Center
– Content (Can’t Enforce an Exact Look) 9500 MacArthur Boulevard
West Bethesda, Maryland, MD 20817-5700
email: • Changes in HTML 3.2 to HTML 4.0 [email protected]
Phone: (301) 277-4648
– Standardization of frames
This is my personal home page. For more specific – Deprecation of formatting elements (vs. style sheets) programming-related resources pages, please see: – Improved cell alignment and grouping in tables – Mouse and keyboard events for nearly all elements – Internationalization features CS 4390 Web Programming Introduction to HTML 5 CS 4390 Web Programming Introduction to HTML 6
1 Creating and Publishing a Web Page 1. Create an HTML document Designing Documents for the 2. Place the document in a world-accessible directory (often public_html or www) on a World Wide Web system running an HTTP server 3. Access the web page through http://hostname/~username/filename § E.g. http://www.apl.jhu.edu/~lmb/test.html – If the filename is omitted, a system default filename is assumed (often index.html) § E.g. http://www.apl.jhu.edu/~hall/ refers to the file index.html in hall’s public_html directory CS 4390 Web Programming Introduction to HTML 8
Creating and Publishing HTML Document Template a Web Page 4. Validate the Document – Check the syntax using a formal HTML validator § http://validator.w3.org/ § http://www.htmlhelp.com/tools/validator/ – The version of HTML against which the document is validated is based on the DOCTYPE The WWW Consortium recently added advice that Web pages include information on the character set, even though ASCII or Latin-1 is the default. The validator at http://validator.w3.org/ gives warnings if you omit this. You can ignore such warnings if you wish. CS 4390 Web Programming Introduction to HTML 9 CS 4390 Web Programming Introduction to HTML 10
Main HTML Elements Main HTML Elements
DOCTYPE Declarations HTML: … • Strict HTML 4.01 DOCTYPE Attributes: • Transitional HTML 4.01 DOCTYPE • LANG -- informational, do not change how the text is rendered, language code for search engine or spell • Frameset HTML 4.01 DOCTYPE checker • HTML elements • DIR -- LTR, RTL, Netscape does not support http://www.w3.org/TR/html4/index/elements.html • VERSION – HTML version, browser can determine • HTML attributes the HTML version http://www.w3.org/TR/html4/index/attributes.html
CS 4390 Web Programming Introduction to HTML 11 CS 4390 Web Programming Introduction to HTML 12
2 Main HTML Elements
HEAD:
… Attributes: Profile – TITLECS 4390 Web Programming Introduction to HTML 13 CS 4390 Web Programming Introduction to HTML 14
BASE Element BASE Element, Example
• Specifies the starting location for relative
URLsNews Headlines
– TARGET -- specify the default frame to displayNational News
Blah, blah, blah.International News
Yadda, yadda, yadda.CS 4390 Web Programming Introduction to HTML 15 CS 4390 Web Programming Introduction to HTML 16
META Element META Element, Example
• Records document information, forwards
and refreshes pagesNews Headlines
– HTTP-EQUIV="refresh" -- reload the page orNational News
Blah, blah, blah. load a new pageInternational News
Yadda, yadda, yadda. CS 4390 Web Programming Introduction to HTML 17 CS 4390 Web Programming Introduction to HTML 183 BGSOUND Element SCRIPT Element
• Playing sound files (wav, MIDI) • Embed scripting programs, usually • Nonstandard HTML elements JavaScript • Attributes: • Attributes: – SRC -- source file – LANGUAGE -- JavaScript – LOOP -- repeated 1 (default) or –1 or infinite – TYPE (required) – SRC
CS 4390 Web Programming Introduction to HTML 19 CS 4390 Web Programming Introduction to HTML 20
STYLE Element Main HTML Elements
• Specify cascading style sheets BODY Element –
• Attributes: – HTML Attributes and Attribute Values – TYPE (required) – text/css § BACKGROUND -- tile small picture § BGCOLOR -- background color – TITLE § TEXT -- foreground color – MEDIA § LINK, VLINK, ALINK – link, visited link, active link color § OnLoad, OnUnload, OnFocus, OnBlur Elements inside BODY element – Remaining HTML elementsCS 4390 Web Programming Introduction to HTML 21 CS 4390 Web Programming Introduction to HTML 22
Block-Level Elements
• Headings – H1 ... H6 Block-Level Elements – ALIGN • Basic Text Sections – P – ALIGN – PRE – WIDTH – ADDRESS – BLOCKQUOTE
CS 4390 Web Programming Introduction to HTML 24
4 Block-Level Elements Block-Level Elements
• Lists • Tables and Forms – OL • Misc. – LI – HR – UL – DIV – CENTER – LI – MULTICOL (Netscape only) – DL – DT – DD
CS 4390 Web Programming Introduction to HTML 25 CS 4390 Web Programming Introduction to HTML 26
Headings Headings
• Heading Types • Attributes: ALIGN –
...
– Values: LEFT (default), RIGHT, CENTER –...
• Nesting tags –...
– Headings and other block-level elements can –...
contain –...
text-level elements, but not vice versa –...
CS 4390 Web Programming Introduction to HTML 27 CS 4390 Web Programming Introduction to HTML 28
Headings, Example Headings, Result
Level-1 (H1)
Level-2 (H2)
Level-3 (H3)
Level-4 (H4)
Level-5 (H5)
Level-6 (H6)
CS 4390 Web Programming Introduction to HTML 29 CS 4390 Web Programming Introduction to HTML 305 P – The Basic Paragraph
• Attributes: ALIGN – LEFT (default), RIGHT, CENTER. Same as headings. – Whitespace ignored (use
for line break) § Consecutive
’s do not yield multiple blank lines – End Tag is Optional:
Paragraph 1 Paragraph 1
Paragraph 2
Paragraph 2 Paragraph 3
Equivalent with Implied Tags Paragraph 3
Fully-Specified CS 4390 Web Programming Introduction to HTML 31 CS 4390 Web Programming Introduction to HTML 32Preformatted Paragraphs
• The PRE Element –
...• Attributes: WIDTH – Expected width in characters. Not widely supported. • Problem: Special Characters
if (a > & & doThat(); " " } Non-breaking space
CS 4390 Web Programming Introduction to HTML 33 CS 4390 Web Programming Introduction to HTML 34
OL: Ordered (Numbered) Lists OL: Ordered (Numbered) Lists
• OL Element • List entries: LI –
- –
- ... (End Tag Optional)
- … – Attributes: (When inside OL) VALUE, TYPE
- … ... A sample list:
- List Item One – Attributes: TYPE, START, COMPACT
- List Item Two
- List Item Three
CS 4390 Web Programming Introduction to HTML 35 CS 4390 Web Programming Introduction to HTML 36
6 Nested Ordered Lists UL: Unordered (Bulleted) Lists
- Headings
- Basic Text Sections
- Lists
- Ordered • UL Element
- The OL tag
- –
- TYPE
- START
- COMPACT
- …
- The LI tag
- …
- The OL tag
- Unordered
- ...
- The UL tag
- The LI tag
- Definition
- The DL tag
- The DT tag
- The DD tag
- Ordered • UL Element
- Miscellaneous
UL: Unordered (Bulleted) Lists UL: Custom Bullets
- The UL tag • Attributes: TYPE, COMPACT
- TYPE
- – TYPE is DISC, CIRCLE, or SQUARE
- DISC
- CIRCLE
- SQUARE • List entries: LI (TYPE)
- COMPACT – TYPE is DISC, CIRCLE, or SQUARE
- TYPE
- The LI tag A sample list:
- TYPE
- List Item One
- DISC
- List Item Two
- CIRCLE
- SQUARE
- List Item Three
- VALUE
- TYPE
Definition Lists Definition List -- Example
A sample list: • Definition list:
- …
- HTML – Attributes: COMPACT
- HyperText Markup Language
- WWW • Definition term:
- …
(optional) - World Wide Web – Attributes: None
CS 4390 Web Programming Introduction to HTML 41 CS 4390 Web Programming Introduction to HTML 42
7 Text-Level Elements
• Physical Character Styles – B, I, TT, U, SUB, SUP, SMALL, BIG, STRIKE, S, Text-Level Elements BLINK – FONT § SIZE § COLOR § FACE – BASEFONT -- set the default font size for nonheading text for the remainder of document § SIZE
CS 4390 Web Programming Introduction to HTML 44
Physical Character Styles, Physical Character Styles, Result Example
...
Physical Character Styles
BoldItalic
Teletype (Monospaced)
Underlined
Subscripts: f0 + f1
Superscripts: x2 + y2
Smaller
Bigger
Bold Italic
Big Monospaced
Small Italic
Gray
Insert
... CS 4390 Web Programming Introduction to HTML 45 CS 4390 Web Programming Introduction to HTML 46
Logical Character Styles, Text-Level Elements Example • Logical Character Styles ...
Logical Character Styles
– EM -- emphasis Emphasized– STRONG -- strong emphasis Strongly Emphasized
Code
– CODE -- computer code with fixed width Sample Output
– SAMP -- sample program output Keyboard Text
– KBD – keyboard input Definition
Variable
– DFN -- definition Citation
– VAR -- variable
Emphasized Code
Gray Citation
– CITE -- citation JDK – ACRONYM Acronym ... § Attribute: TITLE CS 4390 Web Programming Introduction to HTML 47 CS 4390 Web Programming Introduction to HTML 48
8 Logical Character Styles, Result Text-Level Elements
• Hypertext Links – A § HREF, NAME, TARGET, ... • Images – IMG § SRC (required), ALT, ALIGN, WIDTH, HEIGHT, HSPACE, VSPACE, BORDER, USEMAP, ISMAP • Misc. Text-Level Elements – BR (Explicit line break) – AREA (Client-side image maps) – APPLET (Java) – ... CS 4390 Web Programming Introduction to HTML 49 CS 4390 Web Programming Introduction to HTML 50
Hypertext Links Hypertext Links
• Links can contain images and other text-level • Link to Relative URL elements (i.e., ... ) – Use a filename or relative path to filename • Link to Absolute URL § Interpreted wrt location of current file Java is discussed in – Use a complete URL beginning with http:// Chapter 2. Java is discussed in • Link to Section Chapter 2. – Use a section name (see below) preceded by # Images are discussed in Section 2.
CS 4390 Web Programming Introduction to HTML 51 CS 4390 Web Programming Introduction to HTML 52
Hypertext Links IMG: Embedding Images
• Link to Section in URL • Example – Use absolute or relative URL, then #, then section name • Attributes: Sec. 2 of Chap. 1. – SRC (required) • Naming a Section – ALT (technically required) – Use and do not include the pound – ALIGN sign – WIDTH, HEIGHT Images
– HSPACE, VSPACE – BORDER
CS 4390 Web Programming Introduction to HTML 53 CS 4390– WebUSEMAP, Programming ISMAP Introduction to HTML 54
9 Image Alignment, Example Image Alignment, Result
Image Alignment
Alignment | Result |
---|---|
LEFT | This positions the image at the left side, with text flowing around it on the right. |
RIGHT | This positions the image at the right side, with text flowing around it on the left. ... |
Tables
• Template
Heading1 | Heading2 |
---|---|
Row1 Col1 Data | Row1 Col2 Data |
Row2 Col1 Data | Row2 Col2 Data |
Row3 Col1 Data | Row3 Col2 Data |
CS 4390 Web Programming Introduction to HTML 58
TABLE Element Attributes TABLE Element Attributes
• ALIGN • CELLSPACING – The ALIGN attribute gives the horizontal alignment of – This gives the space in pixels between adjacent cells. the table as a whole Drawn as a 3D line if BORDER is nonzero, otherwise – Legal values are LEFT, RIGHT, and CENTER, with LEFT being the default empty space in the background color is used • BORDER – The default is usually about 3 – This specifies the width in pixels of the border around • CELLPADDING the table – This is in addition to the border around each cell (the – CELLPADDING determines the empty space, in CELLSPACING). pixels, between the cell’s border and the table element – The default is zero, which also results in the visible 3D – The default is usually about 1 divider between cells being turned off
CS 4390 Web Programming Introduction to HTML 59 CS 4390 Web Programming Introduction to HTML 60
10 TABLE Element Attributes TABLE Element Attributes
• WIDTH • BACKGROUND – This specifies the width of the table, either in pixels – This nonstandard attribute supported by IE gives an (
Col 1&2 Heading – E.g., the following aligns entries on a decimal point | Col3 Heading | ||
---|---|---|---|
Col1 Data | Col2 Data • VALIGN | Col3 Data – TOP, BOTTOM, MIDDLE |
CS 4390 Web Programming Introduction to HTML 67 CS 4390 Web Programming Introduction to HTML 68
Table Cells: TH and TD Summary
• WIDTH, HEIGHT • A DOCTYPE is required to validate the document – Values in pixels only (no percentages officially • HTML document should have an enclosing allowed) HTML element, a HEAD (TITLE is required) and • NOWRAP a BODY • Documents are composed of block-level and – Use with caution text-level elements • BGCOLOR, BACKGROUND – Text-level elements must be inside block-level – Same as for TABLE and TR elements, not vice versa
CS 4390 Web Programming Introduction to HTML 69 CS 4390 Web Programming Introduction to HTML 70
Summary
• Hypertext links, , can be absolute or relative – A link to a named section is denoted by #section • Tables are composed of main table element,
; and table data, | – Use BGCOLOR to give background colors to tables, rows, or cells – Use ROWSPAN or COLSPAN to join cells CS 4390 Web Programming Introduction to HTML 71 12 |
---|