Chapter 16 The World Wide Web
2 The World Wide Web (Web) is an infrastructure of distributed information combined with software that uses networks as a vehicle to exchange that information. A Web page is a document that contains or references various kinds of data, such as text, images, graphics, and programs. Web pages also contain links to other Web pages so that the user can “move around.” It’s these links that turn text documents into hypertext.
3 The World Wide Web A Web site is a collection of related Web pages connected by links. The Internet makes the communication possible, but the Web makes that communication easier, more productive, and more enjoyable.
4 Web Browser A browser is a software tool that issues the request for the Web page we want and displays it when it arrives. We often talk about “visiting” a Web site, as if we were going there. In truth, we specify the information we want, and it is brought to us.
5 Web Browser Figure 16.2 A browser retrieving a Web page
6 URLs A hostname is the core part of a Uniform Resource Locator, or URL, which uniquely identifies the page you want out of all of the pages stored anywhere in the world.
7 URLs The four parts of a URL are: protocol hostname path filename E.g. http is the protocol used to transfer all Web pages.
8 Search Engines Search Engine: A website that helps you find other websites. For example, Yahoo and Google are search engines. You enter keywords and the search engine produces a list if links to potentially useful sites. There are two types of searches: Keyword searches Concept-based searches
9 Instant Messaging Instant messaging (IM): An application that allows people to send and receive messages in real time. Both sender and receiver must have an IM app running. Most IM applications use a proprietary protocol that dictates the precise format and structure of the messages that are sent across the network to the receiver. Instant messages are not secure!
10 Cookies Cookie: A small text file that a web server stores on your local computer’s hard disk. A cookie contains information about your visit to the site. Cookies can be used to determine number of unique visitors to the site, to customize the site for your future visits, to implement shopping carts that can be maintained from visit to visit. Cookies are not dangerous!
11 HTML Web pages are created (or built) using a language called the Hypertext Markup Language, or HTML. The term markup language comes from the fact that the primary elements of the language take the form of tags that we insert into a standard text file to annotate the information stored there.
HTML Since web pages are standard text files they can be created with any text editor. The files are saved with the file extension.html (or.htm) so browsers will apply the rules to the text.
HTML – a brief history Tim Berners-Lee began development of HTML at CERN.CERN First specification for HTML published Request for Comments 1866 specifies HTML 2.0.Request for Comments World Wide Web Consortium (W3C) maintains specifications for HTML.World Wide Web Consortium HTML 4.01 published development began on HTML5.
XHTML – the present HTML5 is not yet widely supported, but more importantly, many web designers have regretted the conflation of Structure and Presentation in HTML. The separation of these has been achieved by using XHTML to specify Structure, and Cascading Style Sheets (CSS) to specify Presentation.
What Is XHTML? XHTML stands for EXtensible HyperText Markup Language. XHTML is almost identical to HTML XHTML is a stricter and cleaner version of HTML. XHTML is HTML defined as an XML application. XHTML is a W3C Recommendation of January 2000.January 2000 XHTML is supported by all major browsers.
Structure of an XHTML document An XHTML document consists of 3 main parts: the DOCTYPE declaration the section
17 Structure of an XHTML document appears in the Title Bar …
XHTML The declaration is mandatory in XHTML. This declaration refers to a Document Type Definition (DTD) which specifies the rules for the markup language, so that the browsers render the content correctly. For example: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
XHTML Different Doctypes XHTML 1.0 Strict This DTD contains all HTML elements and attributes, but does NOT INCLUDE presentational or deprecated elements (like font). Framesets are not allowed. The markup must also be written as well-formed XML. XHTML 1.0 Transitional This DTD contains all HTML elements and attributes, INCLUDING presentational and deprecated elements (like font). Framesets are not allowed. The markup must also be written as well-formed XML. XHTML 1.0 Frameset This DTD is equal to XHTML 1.0 Transitional, but allows the use of frameset content. XHTML 1.1 This DTD is equal to XHTML 1.0 Strict, but allows you to add modules (for example to provide ruby support for East-Asian languages).
XHTML Some important differences between HTML and XHTML: XHTML elements must be properly nested. XHTML elements must always be closed. XHTML elements must be in lowercase. XHTML documents must have one root element.
21 XHTML Tags A tag consists of a keyword enclosed in angle brackets. ( ) Tags are most often used in pairs, with a start tag such as and an end tag such as surrounding the text to which they apply. A tag pair, along with its enclosed text, is called an element.
22 A sample document “Raw” XHTML. Tags are blue. CSE 1520 Welcome to the Website for CSE 1520 This is our first foray onto the World Wide Web. We are trying to learn how to create pages that can become part of the WWW. We hope to learn about elements of Structure, including: - headings - paragraphs - tables
23 HTML The same file displayed in a browser.
24 XHTML Note that the browser determines how the page should be displayed based on the tags. It ignores the way we format the XHTML source document. Tabs, carriage returns, extra spaces, and blank lines are called “whitespace” and are ignored by the browser. The browser takes into account the width and height of its window. When you resize the browser window, the contents of the Web page are reformatted to fit the new size.
25 Basic Markup in XHTML The body element in the sample page contains 2 other elements: … is a heading element. … is a paragraph element. Welcome to the Website for CSE 1520 This is our first foray onto the World Wide Web. We are trying to learn how to create pages that can become part of the WWW. We hope to learn about elements of Structure, including: - headings - paragraphs - tables
26 Basic Markup in XHTML Headings in a document. There are six predefined heading levels in XHTML: h1, h2, h3, h4, h5, and h6. The heading level determines the size of text, and the vertical spacing below the text. Paragraphs (... ) specify text that should be treated as a single paragraph. A paragraph always starts on a new line. Paragraphs are followed by vertical spacing.
27 Basic Markup in XHTML To cause text to start on a new line without vertical spacing, use the line break element: This empty element uses a single tag instead of a pair. To conform to the rule that all tags must be closed, the “ /” (space slash) are added to empty tags.
28 Lists in XHTML We often want to display a list of items. The … pair creates an unordered list, the … pair creates an ordered list, and the … pair distinguishes each list item.
29 A sample list a list item another list item and another list item This XHTML code will produce…
30 A sample list …this list in the browser.
31 Tables In XHTML, tabular data can be displayed by using a table comprised of rows of details. … tags surround the table … tags surround a row … tags define each detail (data)
32 Tables col1 row1 col2 row1 col1 row2 col2 row2
33 Tables XHTML requires that web pages be compatible with non-visual browsers. In the case of tables this means that a tag must include a summary attribute. The text in the summary provides a description of the table to users of non-visual browsers.
34 Tables The sample table as displayed in a browser.
35 Images An image can be incorporated into a Web page using the tag. This is another example of an empty element since it does not surround text, but instead indicates a point at which to insert the picture.
36 Images To specify where to find the picture to be inserted, the tag uses the mandatory src attribute. Note the other mandatory attribute - alt, which provides text to be displayed whenever the image cannot be.
37 Tag Attributes Note the syntax of tag attributes. The attribute name is followed by the equals sign (=), and then the attribute value, which is enclosed in quotes. – Either double or single quotes may be used.
38 Links A link is specified using the element a, which stands for anchor. The tag includes an attribute called href that specifies the URL of the destination document. For example: CSE1520 Alternate Web Site
39 Links Our example: CSE1520 Alternate Web Site Notes: The URL is enclosed in quotes. The link text between the tags is displayed in the browser, usually in underlined blue. However, this can be changed.
Cascading Style Sheets CSS
CSS Style Rules Style Rules tell the browser how a particular part of a web page is to be presented. Presentation refers to aspects of the display related to the text, like font, colour, size, etc. For example: body {background-color: yellow;} h1 {color: blue;} p {font-family: verdana; font-size: smaller;}
Applying Style Sheets There are 3 levels at which style rules can be set : External level Styles are saved in a separate file (.css) The XHTML document links to the style sheet. Document level Styles are grouped within a … element, which is placed in the element. Inline level Style rules are set as the value of the style attribute of a specific element.
External level If our example styles are saved in YandB.css, then we can link it to an XHTML document this way: The document will now have a yellow background, level 1 headings will have blue text, and paragraphs will use a Verdana font, one decrement smaller than normal.
Document level Another way to apply styles to a document is to include them in the head. CSE 1520 body {background-color: yellow;} h1 {color: blue;} p {font-family: verdana; font-size: smaller;}
Inline level Welcome to the Website for CSE 1520 This is our first foray onto the World Wide Web. We are trying to learn how to create pages that can become part of the WWW. We hope to learn about elements of Structure, including: headings paragraphs tables
Applying Style Sheets The advantages of applying style sheets at the External level, make it the current favourite. – Styles can be applied to the whole, or part(s) of a website without having to copy/paste them to multiple documents. – Modifying the presentation of the whole site, or any part of it, requires changes to only 1 file.
Interactive Web Pages
48 Interactive Web Pages When HTML was first developed, there was no way to interact with the text and graphics presented in a Web page. As users clamored for a more dynamic web, new technologies were developed to accommodate these requests. Many of the new ideas were offshoots of the newly developed Java programming language.
49 Java Applets A Java applet is a program that is designed to be embedded into an HTML document using the applet tag. The program is transferred over the Web, along with the text and graphics.
50 Java Applets The browser has a built-in interpreter that executes the applet, allowing the user to interact with it. Consider the difficulties inherent in this situation. How can we expect a program that was written on one type of computer to run on possibly many other types of computers?
51 Java Applets Java programs are compiled into Bytecode, a low-level representation of a program that is not quite machine code because it’s not specific to any CPU. A Java interpreter is installed on each user’s machine to translate Bytecode into the machine code for that particular CPU. This interpreter executes the Bytecode.
52 Java Applets Java applets are restricted as to what they can do. The Java language has a carefully constructed security model. An applet, for instance, cannot access any local files or change any system settings.
53 Java Server Pages A Java Server Page, or JSP, is a Web page that has JSP scriptlets embedded in it. A scriptlet is a small piece of executable code intertwined among regular HTML content. A JSP scriptlet is encased in special tags beginning with. Imagine JSP scriptlets as having the expressive power of a full programming language.
54 Java Server Pages JSPs are executed on the server - where the Web pages are stored. This execution creates (X)HTML code that is sent to the browser. By the time it arrives at your computer, all active processing has taken place, producing a static (though dynamically created) Web page. JSPs are particularly good for coordinating the interaction between a Web page and an underlying database.
55 XML HTML has a predefined set of tags and each tag has its own meaning. There is nothing about HTML tags that describes the content of a document. The Extensible Markup Language, or XML, allows the creator of a document to describe its contents by defining their own set of tags.
56 XML XML is a metalanguage, which is a language for talking about, or defining, other languages. The Standard Generalized Markup Language (SGML) was used to define HTML. XML is a simplified version SGML used to enhance HTML.
57 XML Like HTML, an XML document is made up of tagged data. Figure 16.5 An XML document containing data about books
58 XML Note line 2 of the example: This indicates the file that contains the definition (organisation) for documents of that type.
59 XML Document Type Definition (DTD) is a specification of the organization of the document. The structure of a particular XML document is described by its corresponding DTD document. Figure 16.6 The DTD document corresponding to the XML books document
XML XML represents a standard format for organizing data without tying it to any particular type of output. Extensible Stylesheet Language (or XSL) is a language for defining transformations from XML documents to other output formats. Figure 16.7 An XML document can be transformed into many output formats