The Web Document HTML. B ACKGROUND HTTP is the protocol used by most web applications Two phases ...

57
The Web Document HTML

Transcript of The Web Document HTML. B ACKGROUND HTTP is the protocol used by most web applications Two phases ...

Page 1: The Web Document HTML. B ACKGROUND  HTTP is the protocol used by most web applications  Two phases  REQUEST: a client asks a server for information.

The Web Document

HTML

Page 2: The Web Document HTML. B ACKGROUND  HTTP is the protocol used by most web applications  Two phases  REQUEST: a client asks a server for information.

2 BACKGROUND

HTTP is the protocol used by most web applications Two phases

REQUEST: a client asks a server for information RESPONSE: the server responds to the clients request

Communication is primarily textual. The response is usually an HTML document.

Page 3: The Web Document HTML. B ACKGROUND  HTTP is the protocol used by most web applications  Two phases  REQUEST: a client asks a server for information.

3 INTRODUCTION

Browsers request data from servers. The requested data is usually delivered as an HTML document.

An HTML document is composed of content : the data of the document. structure : the way in which the content is organized

within the document style : how the content is displayed / rendered

Page 4: The Web Document HTML. B ACKGROUND  HTTP is the protocol used by most web applications  Two phases  REQUEST: a client asks a server for information.

4 DOCUMENT CONTENT

Title

Attribution

Chapter

Paragraph

Quotation

Essays in the art of writing.

By Robert Louis Stevenson

On Some Technical Elements of Style in Literature

There is nothing more disenchanting to man than to be shown the springs and mechanism of any art. All our arts and occupations lie wholly on the surface; it is on the surface that we perceive their beauty, fitness, and significance; and to pry below is to be appalled by their emptiness and shocked by the coarseness of the strings and pulleys. In a similar way, psychology itself, when pushed to any nicety, discovers an abhorrent baldness, but rather from the fault of our analysis than from any poverty native to the mind. And perhaps in aesthetics the reason is the same: those disclosures which seem fatal to the dignity of art seem so perhaps only in the proportion of our ignorance; and those conscious and unconscious artifices which it seems unworthy of the serious artist to employ were yet, if we had the power to trace them to their springs, indications of a delicacy of the sense finer than we conceive, and hints of ancient harmonies in nature. This ignorance at least is largely irremediable. We shall never learn the affinities of beauty, for they lie too deep in nature and too far back in the mysterious history of man. The amateur, in consequence, will always grudgingly receive details of method, which can be stated but never can wholly be explained; nay, on the principle laid down in Hudibras, that

‘Still the less they understand, The more they admire the sleight-of-hand,’

Page 5: The Web Document HTML. B ACKGROUND  HTTP is the protocol used by most web applications  Two phases  REQUEST: a client asks a server for information.

5DOCUMENT STRUCTURE

Essays in the art of writing.

By Robert Louis Stevenson

On Some Technical Elements of Style in Literature

There is nothing more disenchanting to man than to be shown the springs and mechanism of any art. All our arts and occupations lie wholly on the surface; it is on the surface that we perceive their beauty, fitness, and significance; and to pry below is to be appalled by their emptiness and shocked by the coarseness of the strings and pulleys. In a similar way, psychology itself, when pushed to any nicety, discovers an abhorrent baldness, but rather from the fault of our analysis than from any poverty native to the mind. And perhaps in aesthetics the reason is the same: those disclosures which seem fatal to the dignity of art seem so perhaps only in the proportion of our ignorance; and those conscious and unconscious artifices which it seems unworthy of the serious artist to employ were yet, if we had the power to trace them to their springs, indications of a delicacy of the sense finer than we conceive, and hints of ancient harmonies in nature. This ignorance at least is largely irremediable. We shall never learn the affinities of beauty, for they lie too deep in nature and too far back in the mysterious history of man. The amateur, in consequence, will always grudgingly receive details of method, which can be stated but never can wholly be explained; nay, on the principle laid down in Hudibras, that

‘Still the less they understand, The more they admire the sleight-of-hand,’

The document contains a title and a chapter. The chapter contains a paragraph and a quotation.

There are likely many more details that are not shown.

Page 6: The Web Document HTML. B ACKGROUND  HTTP is the protocol used by most web applications  Two phases  REQUEST: a client asks a server for information.

6 DOCUMENT STYLE

Essays in the art of writing.

By Robert Louis Stevenson

On Some Technical Elements of Style in Literature

There is nothing more disenchanting to man than to be shown the springs and mechanism of any art. All our arts and occupations lie wholly on the surface; it is on the surface that we perceive their beauty, fitness, and significance; and to pry below is to be appalled by their emptiness and shocked by the coarseness of the strings and pulleys. In a similar way, psychology itself, when pushed to any nicety, discovers an abhorrent baldness, but rather from the fault of our analysis than from any poverty native to the mind. And perhaps in aesthetics the reason is the same: those disclosures which seem fatal to the dignity of art seem so perhaps only in the proportion of our ignorance; and those conscious and unconscious artifices which it seems unworthy of the serious artist to employ were yet, if we had the power to trace them to their springs, indications of a delicacy of the sense finer than we conceive, and hints of ancient harmonies in nature. This ignorance at least is largely irremediable. We shall never learn the affinities of beauty, for they lie too deep in nature and too far back in the mysterious history of man. The amateur, in consequence, will always grudgingly receive details of method, which can be stated but never can wholly be explained; nay, on the principle laid down in Hudibras, that

‘Still the less they understand, The more they admire the sleight-of-hand,’

Large bold underlined

Small all-caps gray

Medium bold blue

Small black

Small italic indented

Page 7: The Web Document HTML. B ACKGROUND  HTTP is the protocol used by most web applications  Two phases  REQUEST: a client asks a server for information.

7 RENDERED DOCUMENT

The browser takes the content, structure, and style information and 'renders' the document. This is the result.

Page 8: The Web Document HTML. B ACKGROUND  HTTP is the protocol used by most web applications  Two phases  REQUEST: a client asks a server for information.

8 HTML DOCUMENTS

HTML documents: Hypertext markup language hypertext : links markup language : tags are used to describe structure

HTML documents are plain text documents content is just typed in tags are used to provide structure to the content CSS is used to provide style to the document

Page 9: The Web Document HTML. B ACKGROUND  HTTP is the protocol used by most web applications  Two phases  REQUEST: a client asks a server for information.

9 HTML SYNTAX

HTML documents are composed of elements (also known as tags) A tag is written like:

<section> …. </section> <div> … </div> <table> … </table>

Notes on tags the ‘<‘ indicates that what follows is a command to the browser The ‘</’ indicates the end of a command The name of the tag is what occurs first in the angled brackets.

There are a fixed number of tags in HTML. You can’t just type whatever you want: <china> … </china> <scun> … </scun>

Page 10: The Web Document HTML. B ACKGROUND  HTTP is the protocol used by most web applications  Two phases  REQUEST: a client asks a server for information.

10 HTML SYNTAX

Tags define the structure of the content What kind of thing the content represents

section quotation title …

How the content is related to other content Tags are not case sensitive

<BODY> <Body> <body> <bODY>

Page 11: The Web Document HTML. B ACKGROUND  HTTP is the protocol used by most web applications  Two phases  REQUEST: a client asks a server for information.

11DOCUMENT STRUCTURE

<div>Essays in the art of writing.

</div>

<h6>By Robert Louis Stevenson</h6>

<div class="chapter">On Some Technical Elements of Style in Literature

</div>

<p>There is nothing more disenchanting to man than to be shown the springs and mechanism of any art. All our arts and occupations lie wholly on the surface; it is on the surface that we perceive their beauty, fitness, and significance; and to pry below is to be appalled by their emptiness and shocked by the coarseness of the strings and pulleys. In a similar way, psychology itself, when pushed to any nicety, discovers an abhorrent baldness, but rather from the fault of our analysis than from any poverty native to the mind. And perhaps in aesthetics the reason is the same: those disclosures which seem fatal to the dignity of art seem so perhaps only in the proportion of our ignorance; and those conscious and unconscious artifices which it seems unworthy of the serious artist to employ were yet, if we had the power to trace them to their springs, indications of a delicacy of the sense finer than we conceive, and hints of ancient harmonies in nature. This ignorance at least is largely irremediable. We shall never learn the affinities of beauty, for they lie too deep in nature and too far back in the mysterious history of man. The amateur, in consequence, will always grudgingly receive details of method, which can be stated but never can wholly be explained; nay, on the principle laid down in Hudibras, that</p>

<q>‘Still the less they understand, The more they admire the sleight-of-hand,’</q>

Document structure is defined by the tags.

Page 12: The Web Document HTML. B ACKGROUND  HTTP is the protocol used by most web applications  Two phases  REQUEST: a client asks a server for information.

12DOCUMENT STRUCTURE

Tags define the structure of a document. Tags must be properly nested. Each tag must be fully contained

within a ‘parent’ tag. Good:

<div>This is some text <span>with nesting</span></div> Bad:

<div>This is some text<span>with</div> nesting</span>

Tags are related to each other as parent : If tag A contains tag B without another tag between them,

tag A is the parent of tag B. child : If tag B is contained by tag A without another tag between

them, tag B is the child of tag A. sibling : If tag A and tag B have the same parent, A and B are siblings.

Page 13: The Web Document HTML. B ACKGROUND  HTTP is the protocol used by most web applications  Two phases  REQUEST: a client asks a server for information.

13EXAMPLE OF DOCUMENT

STRUCTURE

Page 14: The Web Document HTML. B ACKGROUND  HTTP is the protocol used by most web applications  Two phases  REQUEST: a client asks a server for information.

14HTML SYNTAX :

ATTRIBUTES

Tags may also have attributes <tagname att1="val1" att2="val2" …>

Examples: <div class=“highlight”> … </div> <td border=“0”/> … </td>

An attribute is always name=“value” A tag may have many attributes

Attribute names are fixed. You can’t just type whatever you want. <div school="scun"> … </div> <td singer="Huo Zun"> … </td>

Page 15: The Web Document HTML. B ACKGROUND  HTTP is the protocol used by most web applications  Two phases  REQUEST: a client asks a server for information.

15 HTML TAGS

There are over 100 tags in HTML5. They can be grouped as follows Structure: html, head, body, div, span Text: p, h1-h6, strong, em, abbr, acronym, address, bdi, bdo,

blockquote, cite, q, code, ins, del, dfn, kbd, pre, samp, var, br, sub, sup, b, i, big, small, hr, pre

Links: a, base Images and Objects: img, area, map, object, param Lists: uo, ol, li, dl, dt, dd Tables: table, tr, td, th, tbody, thead, tfoot, col, colgroup,

caption Forms: form, input, textarea, select, option, optgroup,

button, label, fieldset, legend

Page 16: The Web Document HTML. B ACKGROUND  HTTP is the protocol used by most web applications  Two phases  REQUEST: a client asks a server for information.

16HTML DOC

STRUCTURE Every document must have the following skeleton

DOCTYPE tag says that this is an "HTML 5" document <html> tag as the root element with exactly two children.

<head> tag as the first element of the root <title> within the head

<body> follows the title.

<!DOCTYPE HTML><html> <head> <title>Title</title> </head> <body> </body></html>

Page 17: The Web Document HTML. B ACKGROUND  HTTP is the protocol used by most web applications  Two phases  REQUEST: a client asks a server for information.

17 ENTITIES

Some characters have a special meaning "<" indicates the start of an element (or tag)

How to put a ‘<‘ in a paragraph of text? Create a page that contains the text "x < y".

Result Description Entity Name Entity Number  non-breaking space &nbsp; &#160;< less than &lt; &#60;> greater than &gt; &#62;& ampersand &amp; &#38;¢ cent &cent; &#162;£ pound &pound; &#163;¥ yen &yen; &#165;€ euro &euro; &#8364;§ section &sect; &#167;© copyright &copy; &#169;® registered trademark &reg; &#174;

Page 18: The Web Document HTML. B ACKGROUND  HTTP is the protocol used by most web applications  Two phases  REQUEST: a client asks a server for information.

18 ELEMENT LAYOUT

Tags are either block or inline BLOCK: appear as a 'block' which means that the

elements are separated from surrounding elements as if a line-feed had been entered and an empty-line inserted.

INLINE: are not separated from other elements and may not have any visible indicator at all.

Page 19: The Web Document HTML. B ACKGROUND  HTTP is the protocol used by most web applications  Two phases  REQUEST: a client asks a server for information.

19GENERIC STRUCTURAL

ELEMENTS

Page 20: The Web Document HTML. B ACKGROUND  HTTP is the protocol used by most web applications  Two phases  REQUEST: a client asks a server for information.

20 PREFORMATTED

Page 21: The Web Document HTML. B ACKGROUND  HTTP is the protocol used by most web applications  Two phases  REQUEST: a client asks a server for information.

21 HEADINGS

Page 22: The Web Document HTML. B ACKGROUND  HTTP is the protocol used by most web applications  Two phases  REQUEST: a client asks a server for information.

22 SECTION

Page 23: The Web Document HTML. B ACKGROUND  HTTP is the protocol used by most web applications  Two phases  REQUEST: a client asks a server for information.

23 ARTICLE

Page 24: The Web Document HTML. B ACKGROUND  HTTP is the protocol used by most web applications  Two phases  REQUEST: a client asks a server for information.

24 PARAGRAPH

Page 25: The Web Document HTML. B ACKGROUND  HTTP is the protocol used by most web applications  Two phases  REQUEST: a client asks a server for information.

25 QUOTATION

Page 26: The Web Document HTML. B ACKGROUND  HTTP is the protocol used by most web applications  Two phases  REQUEST: a client asks a server for information.

26 BLOCKQUOTE

Page 27: The Web Document HTML. B ACKGROUND  HTTP is the protocol used by most web applications  Two phases  REQUEST: a client asks a server for information.

27 BLOCKQUOTE

Page 28: The Web Document HTML. B ACKGROUND  HTTP is the protocol used by most web applications  Two phases  REQUEST: a client asks a server for information.

28 ANCHORS

Page 29: The Web Document HTML. B ACKGROUND  HTTP is the protocol used by most web applications  Two phases  REQUEST: a client asks a server for information.

29 IMAGES

Web browsers have support for images in many formats. The most common are: GIF

8 bit color (usually lossy) Small file size Use for logos/icons

JPEG 24 bit color (usually lossy) Good compression Use for photos

PNG 24 bit color with better transparency support than JPEG Good compression Use for photos

Page 30: The Web Document HTML. B ACKGROUND  HTTP is the protocol used by most web applications  Two phases  REQUEST: a client asks a server for information.

30 IMAGES

Page 31: The Web Document HTML. B ACKGROUND  HTTP is the protocol used by most web applications  Two phases  REQUEST: a client asks a server for information.

31 IMAGES

Page 32: The Web Document HTML. B ACKGROUND  HTTP is the protocol used by most web applications  Two phases  REQUEST: a client asks a server for information.

32 LISTS

There are three kinds of HTML lists UL : an unordered list of items

order of the items is not meaningful rendered with bullets items are tagged with <LI>

OL : an ordered list of items order of the items is meaningful rendered with numbers items are tagged with <LI>

DL : a definition list a list of terms and their definitions Contains only dt and dd elements

Page 33: The Web Document HTML. B ACKGROUND  HTTP is the protocol used by most web applications  Two phases  REQUEST: a client asks a server for information.

33 LISTS

Page 34: The Web Document HTML. B ACKGROUND  HTTP is the protocol used by most web applications  Two phases  REQUEST: a client asks a server for information.

34 LISTS

Page 35: The Web Document HTML. B ACKGROUND  HTTP is the protocol used by most web applications  Two phases  REQUEST: a client asks a server for information.

35 LISTS

Page 36: The Web Document HTML. B ACKGROUND  HTTP is the protocol used by most web applications  Two phases  REQUEST: a client asks a server for information.

36 LISTS

Page 37: The Web Document HTML. B ACKGROUND  HTTP is the protocol used by most web applications  Two phases  REQUEST: a client asks a server for information.

37 LISTS

Page 38: The Web Document HTML. B ACKGROUND  HTTP is the protocol used by most web applications  Two phases  REQUEST: a client asks a server for information.

38 FORMS

An HTML form defines a set of interactive controls that collect data from a user and submit the data to a web site. Different types of input : text, numbers, dates, others Need to know where to submit the data Need to know when to submit the data Need to know how to submit the data

A form defines the specific inputs where to submit the data when to submit the data how to submit the data

Page 39: The Web Document HTML. B ACKGROUND  HTTP is the protocol used by most web applications  Two phases  REQUEST: a client asks a server for information.

39 FORMS

Page 40: The Web Document HTML. B ACKGROUND  HTTP is the protocol used by most web applications  Two phases  REQUEST: a client asks a server for information.

40 INPUT

Page 41: The Web Document HTML. B ACKGROUND  HTTP is the protocol used by most web applications  Two phases  REQUEST: a client asks a server for information.

41 FORMS

Form data is sent to the server as name-value pairs. When the above form is submitted, the web server

would receive the following information first_name="Jackie" last_name="Chan" email="[email protected]"

Page 42: The Web Document HTML. B ACKGROUND  HTTP is the protocol used by most web applications  Two phases  REQUEST: a client asks a server for information.

42 FORMS

Form data is sent to the server as name-value pairs. When the above form is submitted, the web server

would receive the following information first_name="Jackie" last_name="Chan" email="[email protected]"

Page 43: The Web Document HTML. B ACKGROUND  HTTP is the protocol used by most web applications  Two phases  REQUEST: a client asks a server for information.

43 SELECT

Page 44: The Web Document HTML. B ACKGROUND  HTTP is the protocol used by most web applications  Two phases  REQUEST: a client asks a server for information.

44 TABLE OVERVIEW

A table is a grid of data. A table contains A <caption> (optional) A head <thead> (optional) A foot <tfoot> (optional) A body <tbody> (mandatory but supplied if not provided)

Contains rows <tr> Contains column headers <th> Contains data <td>

Page 45: The Web Document HTML. B ACKGROUND  HTTP is the protocol used by most web applications  Two phases  REQUEST: a client asks a server for information.

45 TABLE

Page 46: The Web Document HTML. B ACKGROUND  HTTP is the protocol used by most web applications  Two phases  REQUEST: a client asks a server for information.

46 TABLE

Page 47: The Web Document HTML. B ACKGROUND  HTTP is the protocol used by most web applications  Two phases  REQUEST: a client asks a server for information.

47 TABLE

A table is a matrix of cells: <table> A <caption> is the table title.

First child of <table> Each row is contained in a <tr> element A cell <td> can have HTML elements within A header cell <th> contains column headers Border attribute is used to specify the border!

border=“border” means browser default border=“3” means 3 pixel-width border

Page 48: The Web Document HTML. B ACKGROUND  HTTP is the protocol used by most web applications  Two phases  REQUEST: a client asks a server for information.

48 TABLE EXAMPLE

<table border = "border"> <caption> Fruit Juice Drinks </caption> <tr> <th> </th> <th> Apple </th> <th> Orange </th> <th> Screwdriver </th> </tr> <tr> <th> Breakfast </th> <td> 0 </td> <td> 1 </td> <td> 0 </td> </tr> <tr> <th> Lunch </th> <td> 1 </td> <td> 0 </td> <td> 0 </td> </tr> </table>

Page 49: The Web Document HTML. B ACKGROUND  HTTP is the protocol used by most web applications  Two phases  REQUEST: a client asks a server for information.

49 TABLE EXAMPLE

<table border = "border"> <tr>

<th></th><th colspan=“3”>Fruit Juice Drinks</th>

</tr> <tr> <th> </th> <th> Apple </th> <th> Orange </th> <th> Screwdriver </th> </tr> <tr> <th> Breakfast </th> <td> 0 </td> <td> 1 </td> <td> 0 </td> </tr> <tr> <th> Lunch </th> <td> 1 </td> <td> 0 </td> <td> 0 </td> </tr> </table>

Page 50: The Web Document HTML. B ACKGROUND  HTTP is the protocol used by most web applications  Two phases  REQUEST: a client asks a server for information.

50 FORMS

A form is used to gather information from the browser and send it to a server.

Data is entered into HTML controls (or widgets) radio buttons textareas checkboxes…

When a form is submitted, the values of the controls in the form are gathered and transmitted to the server

All controls must be located in a <FORM> element. ACTION is a required attribute and denotes what URL

receives the submitted data action=“http://www.company.com/login.jsp”

Page 51: The Web Document HTML. B ACKGROUND  HTTP is the protocol used by most web applications  Two phases  REQUEST: a client asks a server for information.

51CONTROLS (WIDGETS)

<INPUT> tag is used to create various kinds of controls Usually best to enclose the inputs in <label> tags TYPE attribute denotes the kind of input created

TYPE=“TEXT”: a horizontal box for text input size: default size is 20 characters maxlength: if set, causes extra characters to be ignored

TYPE=“PASSWORD”: identical to text except that the typed characters are displayed as asterisks

TYPE=“CHECKBOX”: used to collect zero-or-more values value: the value if checked checked: whether or not the control is initially checked

Page 52: The Web Document HTML. B ACKGROUND  HTTP is the protocol used by most web applications  Two phases  REQUEST: a client asks a server for information.

52 CHECKBOXES

My favorite football teams<p><form action=""><label><input type="checkbox" name="favorite" value="Rams" checked="checked"/>Rams</label><label><input type="checkbox" name="favorite" value="Packers" />Packers</label><label><input type="checkbox" name="favorite" value="Bears" />Bears</label><label> <input type="checkbox" name="favorite" value="Vikings" />Vikings</label></form>

Page 53: The Web Document HTML. B ACKGROUND  HTTP is the protocol used by most web applications  Two phases  REQUEST: a client asks a server for information.

53 RADIO BUTTONS

TYPE=“RADIO”: selects exactly one of many choices Every button in the group must have the same name Only one ‘checked’ attribute must be set and if none are

set the browser will usually check the first choice

Select your favorite football team<p><form action=""><label><input type=“radio" name="favorite" value="Rams" checked="checked"/>Rams</label><label><input type=“radio" name="favorite" value="Packers" />Packers</label><label><input type=“radio" name="favorite" value="Bears" />Bears</label><label> <input type=“radio" name="favorite" value="Vikings" />Vikings</label></form>

Page 54: The Web Document HTML. B ACKGROUND  HTTP is the protocol used by most web applications  Two phases  REQUEST: a client asks a server for information.

54 SUBMIT AND RESET

Enter SSN:<p><form action=""><input type="TEXT" size="11"></text><input type="SUBMIT" value="Submit"><input type="RESET"></form>

Page 55: The Web Document HTML. B ACKGROUND  HTTP is the protocol used by most web applications  Two phases  REQUEST: a client asks a server for information.

55 SELECT

Select: <SELECT> element behaves like either the checkbox or radio button but uses a different interface Radio button is the default behavior multiple=“multiple” denotes checkbox behavior name attribute is required each option is denoted by an <OPTION> element

SELECTED attribute is used to denote which option is selected

Page 56: The Web Document HTML. B ACKGROUND  HTTP is the protocol used by most web applications  Two phases  REQUEST: a client asks a server for information.

56 SELECT

Select your favorite football team:<p><form action="">

<select name="favorite"><option>Rams</option><option>Packers</option><option>Bears</option><option>Vikings</option>

</select></form>

Page 57: The Web Document HTML. B ACKGROUND  HTTP is the protocol used by most web applications  Two phases  REQUEST: a client asks a server for information.

57 TEXTAREA

Text area: <textarea> A multi-row control for entering text rows=“n” denotes the number of rows cols=“n” denotes the number of columns Textarea scrolls if the entered text overflows the

displayed size

Enter comments:<p><form action="“><textarea name="comment" rows="3" cols="40">The Rams rule and the Vikings drool.</textarea></form>