Chapter 5 HTML Basics
Chapter 5 HTML Basics
October 2011
Introduction
Several applications:
E-mail www File transfer (FTP) Remote login E-commerce Instant messaging (chat) Mailing lists
Internet Programming
Introduction (contd)
A website
Web pages (static / dynamic) Media files (images, animations, sound, ) Style files (CSS) Documents (pdf, doc, txt, rtf, ) E.g. www.aau.edu.et
Introduction (contd)
A web page
A document with a mark-up language called HTML The basic unit of information storage on the www
Websites (with unique names) are stored on web servers Users access these websites via the Internet using software called a web browser. A user sends requests for resources from a server with the help of the a user agent (browser) The server sends the requested resource to the user agent The user agent renders the resource for the user to view.
Internet Programming
Introduction (contd)
Software involved:
At the server:
Web server software : listens for incoming requests for resources from clients and serves the requests
At the client:
Web browser : sends/receives requests/responses to/from web servers on behalf of the client and renders content as necessary
Internet Programming
Introduction (contd)
Communication protocol
Client (web browser) and Server (web server) communicate via the HTTP to exchange request/response messages
The web is governed by the w3c (world wide web consortium) (www.w3.org)
Internet Programming
Introduction (contd)
Resolves a human friendly name (eg www.google.com) to a machine friendly IP address (eg 64.233.187.99) Phone book of the Internet For this purpose, DNS servers store a table containing name-IP (among other things) pairs and do a look-up when requested A DNS server may communicate with other server to resolve a given name There are about 12 root DNS servers (http://www.rootservers.org/)
Internet Programming
Introduction (contd)
cs is under aau (a subdomain of aau), aau is under edu, edu is under et.
The highest level is the last component of the DNS address Labels separated by . (dot) Labels can be up to 63 characters long and are case insensitive A maximum of 255 characters is allowed in total
Three letter code top level domains (TLDs): indicating the type of organization
Internet Programming
Introduction (contd)
<protocol>://<host>[:<port>][<path>][?<query>]
E.g. http://www.somedomain.com/search.php?q=dns&lang=en Protocol identifies the type of protocol to be used for communication
Path identifies the name and path of the resource on the server Query specifies parameters, if any, that should be sent to the server along with the request
Internet Programming
A markup language, i.e. its used to markup content. Composed of several tags. HTML Document
A text document containing markup tags The tags tell the browser how to display the document Should have an .htm or .html file name extension Can be created using a simple text editor
10
Internet Programming
11
Internet Programming
HTML Elements
Names enclosed in < and > Commonly have a start tag and end tag
Start tag format: <tag_name> End tag format: </tag_name> [ note the / after < ] E.g. <strong>bold text</strong>
E.g. <br> <tag_name attr1=val1 attr2=val2 ></tag_name> E.g. <font face=arial size=9>Hello</font>
HTML Tags
html
everything in the document should be within <html> &</html> contains information which is not displayed in the browser display area may contain other tags in it format: <head></head>
head
title
13
sets the title of the web page to be displayed in the browsers title bar. found within the <head> tag. format: <title></title> Internet Programming
body
contains the visible part of the web page displayed in the display area of the browser contains several other tags and content in it format: <body></body> attributes:
bgcolor=color background=img url text=text color link=link color alink=active link color vlink=visited link color
Internet Programming
14
headings
predefined formats for text presentation six heading formats defined in HTML: <h1> up to <h6>
<h1> the largest font size <h6> the smallest font size <h1></h1>
Format:
bold
15
makes a text appear in bold Format: <b></b> or <strong></strong> E.g. <b>a text in bold</b>
Internet Programming
italics
makes a text appear in italics Format: <i></i> or <em></em> E.g. <i>a text in italics</i>
underline
paragraph
16
E.g. <p>this is a paragraph of text. it has a new line before and after it.</p> The browser inserts a new line before and after the text in the paragraph tag. attribute:
line break
inserts a new line Format: <br> E.g. line one <br> line two <br> line three <br> line four
17
Internet Programming
horizontal rule
sub/sup
18
define either a subscript or a superscript Format: <sub></sub> ; <sup></sup> E.g. X<sub>1</sub><sup>2</sup> + 2X<sub>3</sub>
Internet Programming
lists
define bulleted lists Format: <ul> <li></li> <li></li> </ul> Atribute: type=bullet type {disc, circle, square} E.g. <ul type=square> <li>book</li><li>marker</li><li>chalk</li></ul>
Internet Programming
19
define numbered lists Format: <ol> <li></li> <li></li> </ol> Atribute: type=number type {1, i, I, a, A} E.g. <ol type=i> <li>book</li><li>marker</li><li>chalk</li></ol>
20
Internet Programming
21
define a list of term-description pairs Format: <dl> <dt></dt> <dd></dd> <dt></dt> <dd></dd> </dl> E.g. <dl> <dt>book</dt><dd>something that we read </dd> <dt>marker</dt><dd>something we write with </dd> Internet Programming </dl>
images
insert images in an html document Format: <img> {no end tag} Attributes:
src=img url alt=alternate text border=border width width=image width height=image height gif, jpg/jpeg, png
22
anchor
defines a hyperlink or a named anchor used for navigation Format: <a></a> Attributes:
23 Internet Programming
named anchors
named places in an html document Format: <a name=anchor_name></a> E.g. <a name=top></a>
Format: <a href=#anchor_name>link text</a> {on the same page} <a href=url#anchor_namelink text</a> {on a different page} E.g. <a href=#top>Top of page</a> {assuming the example above} <a href=http://www.aau.edu.et/history.htm#establishment> Establishment of AAU</a>
Internet Programming
linking to anchors
24