Presentation is loading. Please wait.

Presentation is loading. Please wait.

The world wide web Chapter 4. Learning outcomes Explain in general terms how web documents are transferred across the Internet and What processes are.

Similar presentations

Presentation on theme: "The world wide web Chapter 4. Learning outcomes Explain in general terms how web documents are transferred across the Internet and What processes are."— Presentation transcript:

1 The world wide web Chapter 4

2 Learning outcomes Explain in general terms how web documents are transferred across the Internet and What processes are triggered when you click on hyperlink Code web pages using HTML and XHTML using style sheets. Explain why it is advisable to use XHTML rather than HTML Describe some technologies available for dynamic web pages

3 Essential Reading Joe Casad, Teach yourself TCP/IP, Ch. 17 William Buchanan, Mastering The Internet, Ch. 6-8 Introductory materials on HTML & XHTML either a text book such as John Shelly, HTML AND CSS explained, or

4 Additional reading William Buchanan, Mastering The Internet, Ch Andrew Tanenbaum, Computer Networks, Ch. 7.3 Douglas Comer, Computer Netwoks and Networking, ch Chuck Masciano and Bill Kennedy, HTML and XHTML the definitive guide, for reference Mike Lewis, Understanding Javascript, June- Jully 2000

5 How the web works The client-server model Client and server operate on machines which are able to communicate through a network The server waits for requests from a clients Server receives a requests from a client Performs a the requested work Or lookup the requested data And send a response to the client Servers: file servers, web servers, name servers Clients: browsers, clients

6 url format :// / which protocol to use http: in general file: which tells the client document is in a local machine ftp: file transfer protocol identifies the server system i.e. tells the server where to find the file

7 Web browsers and servers A browser: is a program that can retrieve files from the world wide web and render text, images, or sounds encoded in the files. i.e. IE, Nescape, Mozilla A web server: is an application which waits for client requests, fetches requested documents from disk and transmits them the client. i.e Apache

8 What happened when you click on hyperlink? Determine URL and extract domaine name. Use the name server to get IP address (DNS) Make a TCP connect to port 80 And send a request for a web page once the server has accepted to connection. The server send the file and releases the TCP connection The client displays the document.

9 Other possibilities The steps in the previous slide are for displaying a static web page from a remote machine. Other possibilities are: Page is loaded from a local system no tcp connection url begin with file://... The page is dynamically generated by a client-side script No tcp connection The page is dynamically generated by a server-side script: The server may carry out other functions Secure server Check users identity if they are authorised to access a particular resources

10 Stateless connection Both client and server release TCP connection after a page has been transferred. HTTP1.0 is stateless Connections are not persistent There is no indication to the server whether new transactions involve the same client HTTP 1.1 is persistent By keeping track of the client IP addresses However, there is no way of identifying a repeated visits to the site by the same user. Futhermore, ISPs reallocate IP addresses to dial-up customers as new user dial in.

11 Cookies Request the browser to store a small data file (cookie) on the users hard disk. Which can serve to identify users only. For instance it could contain a key into a database on the server machine. Most browsers nowadays allow you to decide whether or not you want cookies on your machine.

12 Introduction to HTML

13 What is an HTML File? HTML stands for HyperText Markup Language An HTML file is a text file containing small markup tags The markup tags tell the Web browser how to display the page An HTML file must have an htm or html file extension An HTML file can be created using a simple text editor

14 Internet - Services & MIME (Multipurpose Internet Mail Extensions) text (text/html), image, video, etc. Telnet & ssh FTP – File Transfer Protocol Gopher IRC – Internet Relay Chat Newsgroups WWW – World Wide Web HTTP (Hypertext transfer protocol) uses a Question- Answer-Scheme, i.e. a browser sends a request und gets a response from a server. Note the server does not send out anything without a request.

15 Markup languages Suppose we have a document containing only plain text We tag certain parts of the document to indicate what they are and how they should be formatted This procedure is called marking-up the document Tags are usually paired: e.g. My Memoirs A pair of tags plus their content constitute an element Un-paired tags are called empty tags

16 Markup languages Physical vs Semantic markup physical refers to appearance (style) on the page semantic refers to structure and meaning HTML is the HyperText Markup Language HTML is based on SGML (Standard Generalised Markup Language) which is more complex HTML has a fixed set of tags but is constantly evolving, but newer versions are downward compatible

17 Markup languages HTML places primary emphasis on structure paragraphs, headings, lists, images, links, …. HTML places secondary emphasis on style (CSS) fonts, colours, …. HTML does not label the meaning of the text (XML)

18 A basic document Every document should start with the following line There are three required elements, defined by the tags, and My Home Page Welcome

19 Basic structure elements first and last tags The HEAD section must come before the BODY section contains generic information about the document Elements specified in the HEAD section can include – title, link, script, style The BODY section contains the content of the document (text, images etc) this content is structured by other tags

20 Block elements Block elements define sections of text, usually preceded by a blank line - paragraph... - headings - preserve (original format) - indented text - division used to identify a section of the document that may be subject to special formatting (for example, using stylesheets).

21 Paragraphs Paragraphs:... force a break between the enclosed text and the text surrounding it the tagged region of text may be subject to special formatting Here is another paragraph – align is an attribute of the paragraph tag – center is the value of the align attribute here is a piece of text that has been placed inside a paragraph Here is another paragraph

22 Headings Chapter 1 1. Introduction This is the introduction 2. Next section This is the next section 2.1 A subsection This is a subsection Headings Six levels of importance... Use headings to divide document into sections

23 Element relationships The elements marked by tags form a hierarchy The root element is html (marked by... ) It usually has two children: head and body each of these are further subdivided There are rules for which elements can contain other elements e.g. headers cannot contain headers see for a full list of rules Elements must not overlap each other we cannot have: we can have:

24 Inline descriptive elements Descriptive elements affect the appearance of text depending on how the text is described emphasis, usually with italics strong, usually with bold citation, usually in italics usually results in monotype spacing A fascinating subject that I must understand

25 Inline explicit style elements bigger font than surrounding text smaller font than surrounding text italics strikethrough subscripts superscripts delimits text for stylesheet control delimits blocks of text for stylesheet control

26 Inline explicit style elements attributes face - name of font (must be installed) – "arial", "times", "verdana", "helvetica" size - absolute size (1-7), or relative to previous text – "2", "5", "7", "+1", "-2"... color - hexadecimal RGB, or a named color – "3399dd", "blue", "red" weight - boldness from 100, 200,..., 900 – "100", "300", "900" e.g.

27 Unordered lists Unordered lists for the list elements each item has a bullet some normal text apples oranges pears bananas

28 Ordered lists Ordered lists for the list elements each item has a number some normal text apples oranges pears bananas

29 Definition lists The enclosing tags The definition term The definition MIME Multipurpose... FTP File transfer... TCP Transmission...

30 Nested lists A list may contain another list The inner list is nested inside the outer list apples red green oranges pears bananas

31 Comments Comments are delimited by Comments may span multiple lines

32 Horizontal lines To insert a horizontal line to divide up parts of a document we use the empty tag Attributes: align, size (in pixels), width (in pixels or percentage), noshade Chapter 1 Introduction

33 Special characters Some characters such as, " and & have special meanings. To prevent them being interpreted as HTML code, they must be written as follows: < > " & Blank space is normally ignored in HTML. To include a space in your document use: A < fascinating > subject that I m u s t understand

34 Links The link (anchor) element... provides hypertext links between 1. different documents (using a URL) 2. different parts of an individual document User selection of the link (hot spot) results in 1. retrieval and display of the designated document 2. movement to relevant part of same document The Department of Computer Science is a very....

35 Link with URL The href attribute gives the URL of the target page The text between the tags is highlighted – selecting it activates the link The Department of Computer Science is a very.... Example:

36 Relative addressing The root directory for the link is assumed to be the directory containing the parent page of the link Research Publications Computer Science home The previous example gave the full path name, known as the absolute address

37 Images Images are included using the empty tag Example: The src attribute specifies the file containing the image absolute or relative path names can be used (see notes for links) The alt attribute specifies the text to be displayed if the image is not viewed some users choose not to display images (for faster download) also used for compatibility with older browsers

38 Image attributes The size attributes control the size of the image The align attribute controls the vertical location of the image, relative to the line of text – align="top" top of image aligned with top of text – align="middle" centre of image aligned with centre of text – align="bottom" bottom of image aligned with baseline of text The align attribute also controls the horizontal location of the image, relative to the line of text – align="left" image aligned with left margin – align="right" image aligned with right margin

39 Links with images A link element can include an image instead of text both images and text can be included if required Enter my world of cats

40 Colour Colours are specified with hexadecimal numbers for the red, green and blue primary colours, preceded by a #. To set the background colour of a web page

41 Colour – RGB Model – #ff0000 (red), – #00ff00 (green) – #0000ff (blue) – #ffff00 (yellow) –... – #3395ab (a pastel blue)

42 Colour To set the colour of all text on a page In the body element, the colour of link text can be controlled with the following attributes: –link for an un-visited link –vlink for a visited link –alink for a link that is currently selected by the mouse Example

43 Colour To set the colour of an individual piece of text use the font element (or preferably stylesheets – see later) Text in quotes "such as this" has a different colour

44 Colour names Netscape and Internet Explorer allow textual names for colours instead of hexadecimal This is OK provided the page is not looked at by a browser that does not support colour names For example

45 Background patterns Rather than a uniform color You can give the background of web page a pattern as follow:

46 Forms Server-based programs may return data to the client as a web page Client-side scripts can read input data To validate the data, prior to sending to server To use in local processing which may output web page content that is displayed on the client

47 Example applications Questionnaires to provide feedback on a web site e-commerce, to enter name, address, details of purchase and credit-card number request brochures from a company make a booking for holiday, cinema etc. buy a book, cd, etc obtain a map giving directions to a shop Run a database query and receive results (an important part of e-commerce)

48 Input types text checkbox radio (buttons) select (options) textarea password button submit reset hidden file image

49 The method and action attributes Tell us what you think The method attribute specifies the way that form data is sent to the server program –GET appends the data to the URL –POST sends the data separately The action attribute specifies a server program that processes the form data (often as a URL)

50 The input element: type="text " Tell us what you think Name Address The type attribute specifies the type of user input The name attribute gives an identifier to the input data

51 The input element: type="checkbox " How did you hear about this web site? A friend Search engine The name attribute is used to define a set of checkboxes The value attribute identifies the individual checkbox If the checked attribute is set the box is initially checked

52 The input element: type="radio " Radio buttons are similar to checkboxes, but only one can be selected To select a button by default, use the checked attribute (for one button only) How did you hear about this web site? A friend Search engine

53 The input element: type="button " Do you want to receive any further information: The name attribute uniquely identifies a button The value attribute gives a label to the button Actions can be associated with buttons using JavaScript –see later

54 The input element: type="submit/reset" Thank you type="submit" –clicking this button sends the form data to the program (URL) specified in the action attribute of the form type="reset" –clicking this button clears all data entered so far

55 The input element: type="password/file/hidden" type="password" –similar to type="text" except that the input is echoed with asterisks (so not visible) type="file" –provides a file dialogue box to specify a file that is sent to the server type="hidden" –similar to text input, but the value attribute is used to specify data that is to be sent to the server. Nothing appears on the screen. –The data might be set by a server program to keep track of the details of a particular transaction.

56 The textarea element Used for multi-line text input The size of the input area is specified with the cols and rows attributes Any text placed inside the element appears in the input area (this can be deleted). Please write your comments: put text here

57 The select element How do you rate this site? Good Bad Ugly The select element provides a menu of options An option can be selected by default using the selected attribute (otherwise the first in the list is initially selected)

58 Tables Tables provide a means of organising the layout of data A table is divided into rows and columns: these specify the cells of the table

59 Tables main element table row table header table data Name A B Morgan D P Jones Course Fishing Sailing Year 8 5

60 Rows and Columns Cells can span multiple columns and multiple rows with the colspan and rowspan attributes Name Course Year A B Morgan Fishing 5 D J Jones 8

61 The align and width attributes The align attribute determines the position of the text within a cell The width attribute determines the width of the row relative to the table Name Course Year Last Init. Morgan AB Fishing 5

62 Table attributes align alignment relative to the page width in pixels or percentage of page width border - width of border (pixels) cellspacing separation between cells (pixels) cellpadding - space around data inside cell (pixels) bgcolor - background colour (inside cells) Furthermore The element puts a title above the table

63 Table attributes Course Data Name Course Year A B Morgan Fishing 5

64 Frames and Framesets A frameset partitions a web browser window so that multiple web documents can be displayed simultaneously. Example application: To maintain a permanently visible directory of links within your site, while also displaying one or more selected documents from the site.

65 Framesets The frameset element replaces the body element frameset has attributes cols or rows, defined in terms of pixels, percentage(%) or unspecified (*) this splits the window into two or more columns or rows Frames 1

66 Frame attributes The name attribute uniquely identifies the frame. It may be used as the target in an anchor ( ) element The src attribute specifies the web page to be placed in the frame initially (it may subsequently be overwritten)

67 Frame attributes The scrolling attribute ( "auto", "yes", "no" ) specifies whether the frame is to have scroll bars The frameborder attribute ( "0", "1" ) specifies whether the frame is to have a border

68 navigation.html The anchor tag has a target attribute takes the name of the frame used to display the information All anchors below are targeted to the " mainF " frame Navigation Bar HTML Course Paragraphs Headings Unordered lists Ordered lists Nested lists Home

69 intro.html A simple document which is initially placed in the " mainF " frame This is replaced when a user clicks on a link in the " navF " frame Internet Computing Welcome to the HTML Course Please select the subject of...

70 Nested framesets Frames 2

71 Noframes Frames 1 Something here for browsers not supporting frames Some browsers cannot process frames. Alternative content should be provided using the noframes element

72 Stylesheets One of the most important functions of HTML is its ability to separate the content and presentation of a web document Aspects of the document presentation include positioning on the page choice of fonts colours and backgrounds borders

73 Styles A style is a set of formatting instructions that can be applied to a piece of text. Styles can be defined Within a single HTML tag – Inline styles In the section, and applied to the whole document – Global styles In external files, and can be applied to any document by including the URI of the file – Stylesheets

74 Inline styles Every tag has a style attribute This can be assigned a style definition A style definition is a list of property-value pairs a property is separated from its value by a colon property-value pairs are separated by semi-colons the list is delimited by quotation marks A property-value pair is also called a declaration Inline styles only affect the text contained in the tag Inline styles

75 Inline styles some text... some text The heading is boxed with the text displayed in blue The paragraph is indented by 10% (from the left) and has a cream background

76 Global styles A style can be defined in the head of the document using the tag The style declaration is placed inside a comment so that it can be ignored by older browsers Each style rule consists of the name of an element (selector) followed by a list of property-value pairs enclosed in curly brackets Styles Simple styles

77 Example Simple styles some text... A global style applies to every instance of the corresponding element in the document

78 Stylesheets Styles can be declared in separate files called stylesheets. A stylesheet is linked to a web document by including the following line in the head section rel specifies the type of link being used href specifies a hyperlink to the stylesheet file type specifies the MIME type of the data text/css describes the cascading style sheets type

79 Multiple stylesheets The first stylesheet is included using the tag Any further stylesheets have to be imported command is placed inside a comment Stylesheets url( url(mystyles.css) -->

80 Cascading stylesheets Multiple stylesheets can be included in a document Styles defined in the first stylesheet are overridden by corresponding styles defined in the second stylesheet the stylesheets are said to cascade Example – mainstyles.css – the company's stylesheet – deptstyles.css – the department's stylesheet – mystyles.css – the user's stylesheet If the stylesheets are included in this order, the user's style definitions will override the department styles, which in turn will override the company styles

81 Cascading stylesheets Different stylesheets for different media, platforms and systems – Font size in CSS does not yield sam results on different screens. On Print Media 10pt size fonts are always the same size because the size of a pt is well defined. The conversion of pt to px (pixel) is different on Windows, Linux or Mac OS X platforms. – Browser allow to customize layout and fonts

82 Style rules A style rule has two parts a selector (element name) and a set of declarations The selector associates the style rule with a HTML tag of the same name selector { property: value; } Each declaration has two parts: –a property and a value For readability, each declaration should be placed on a separate line

83 Style rules body { background-color: lightgreen; } h1 { color: lightgreen; background-color: blue; font-family: "Book Antiqua", Times, serif; border: thick groove #9baab2; } Some properties can be given multiple values –The browser first looks for the "Book Antiqua" font –If this is not on the system, it looks for the Times font –Last resort: the browser uses the generic serif font

84 Properties and values Fonts font-family: [ ] font-style: normal|italic|oblique font-weight: normal|bold|bolder|lighter font-size: small|medium|large|smaller|larger Backgrounds and colours color: background-color: |transparent background-image: URL|none

85 Properties and values Text text-decoration: none|underline|overline|line-through text-transformation: none|capitalize|uppercase|lowercase text-align: left|right|center|justify text-indentation: length|percentage Example: To remove underlining on links: a:link, a:visited, a:active{text-decoration: none}

86 Properties and values Boxes margin: length|percentage|auto {1,4} border-width: thin|thick|medium|length {1,4} padding: length|percentage {1,4} border-color: value {1,4} border-style: none|dotted|dashed|solid|double|groove {1,4} ridge: value {1,4} width: length|percentage|auto height: length|auto

87 Properties and values Position location: absolute|relative|fixed – absolute : relative to upper left corner of window – relative : relative to the last item – fixed : does not move when the page is scrolled left: distance from left border of window (pixels, %) top: distance from top border of window (pixels, %)

88 Classes Simple style rules change the appearance of all instances of the associated element A class is a style definition that may be applied as and when we choose if we don't want the styles, we don't have to use them Simple classes are applied to a single type of element Anonymous classes can be applied to any type of element

89 Simple classes A Simple Heading some text... some text

90 Anonymous classes A Simple Heading some text... some text

91 CSS Classes…cont. In your HTML code for the table: you simply reference the class to invoke the style: display this text with a white background and this text with a grey background TD {font-face : sans-serif; font-size : 12pt}.even {background-color : #FFFFFF}.odd {background-color : #CCCCCC} white grey

92 IDs First Second Third Classes specify styles for particular instances of an element IDs specify the style of a single element IDs allow the element to be identified by other elements on the page

93 & are your friends & are your friends and tags allow you define exceptions to the general rules of your body text…and they are helpful tools for document designers and web developers is usually used to designate styles for block elements that should stand apart from the body text…like callout quotes. Everything inside a tag takes on the attributes…and you can specify classes and ids for too!

94 Divisions and spans Rather than applying styles to an element itself, we wrap the element in a div element (usually for block elements), or a span element (usually for inline elements) Any required formatting can then be applied to the or element. Div and span elements become part of the document In particular, each can have class and id attributes

95 Divisions Styles can be applied to blocks of HTML code using div A Simple Heading some text...

96 Spans spans are similar to divisions A Simple Heading some text...

97 Layers The browser maintains a stack of layers, each containing text, images etc. The browser displays layers on top of each other (in order). The tag has the following attributes – z-index: the number of the layer containing the division – left and top : the location (top-left corner) of the division in pixels – width and height: the size of the division in pixels – position: absolute or relative

98 Layers Layers can be manipulated using JavaScript to create Dynamic HTML pages Layers can also be used to organise page content THIS STUFF IS ON TOP BACKGROUND STUFF

99 Summary By now you should be able to use: Tables Frames Stylesheet – CSS Inline style Embedded style External style

100 Typical exam question explain why is it important to separate the content from the style. what is CSS? State three ways in which styles can be used. And explain the advantages and disadvantages of each one.

101 Next Look at the disadvantages of html XML Well formed vs valid xml document XHTML vs HTML DHTML

102 Useful sites

Download ppt "The world wide web Chapter 4. Learning outcomes Explain in general terms how web documents are transferred across the Internet and What processes are."

Similar presentations

Ads by Google