Module 1
Module 1
MODULE – 1
Fundamentals of Web, XHTML, CSS
A Brief Introduction to the Internet
Internet History
• BITnet, CSnet - late 1970s & early 1980s for email and file transfer for other institutions
• NSFnet - 1986
❑Originally for non-Department of Defense funded places
❑Initially connected five supercomputer centers
❑By 1990, it had replaced ARPAnet for non-military uses
❑Soon became the network for all (by the early 1990s)
NSFnet eventually became known as the Internet
Internet History
What the Internet is:
“Collection of computers connected in communication network”
Or
“Its a global computer network that provides variety of information and communication facilities, consisting
of interconnected networks using standardized communication protocols.”
• Problem: By the mid-1980s, several different protocols had been invented and were
being used on the Internet, all with different user interfaces (Telnet, FTP, Usenet, mailto)
Domain names
“A domain name is your website name. A domain name is the address where Internet users can
access your website. A domain name is used for finding and identifying computers on the
Internet. computers use IP addresses, which are a series of number.”
• Form: host-name.domain-names
• DNS servers - convert fully qualified domain names to Ips
• All the requests from the browsers are routed to name server, name server
plays vital role in handling queries regarding the location of a domain name's
various services.
Client and Server
• Clients and Servers are programs that communicate with each other
over the Internet
• A Server runs continuously, waiting to be contacted by a Client
• Each Server provides certain services
• Services include providing web pages
• A Client will send a message to a Server requesting the service
provided by that server
• The client will usually provide some information, parameters, with the
request
The World-Wide Web
• General form:
scheme:object-address
• The scheme is often a communications protocol, such as telnet or ftp
• For the http protocol, the object-address is: fully qualified domain name/doc path
• For the file protocol, only the doc path is needed
• Host name may include a port number, as in zeppo:80 (80 is the default, so this is silly)
• URLs cannot include spaces or any of a collection of other special characters (semicolons, colons,
...)
• The doc path may be abbreviated as a partial path
• The rest is furnished by the server configuration
• If the doc path ends with a slash, it means it is a directory
Multipurpose Internet Mail Extensions (MIME)
• Form:
Status line
Response header fields
blank line
Response body
• Status line format:
HTTP version status code explanation
• Example: HTTP/1.1 200 OK
(Current version is 1.1)
• Status code is a three-digit number; first digit specifies the general status
1 => Informational
2 => Success
3 => Redirection
4 => Client error
5 => Server error
• The header field, Content-type, is required
HTTP Response Example
HTTP/1.1 200 OK
Date: Tues, 18 May 2004 16:45:13 GMT
Server: Apache (Red-Hat/Linux)
Last-modified: Tues, 18 May 2004 16:38:38 GMT
Etag: "841fb-4b-3d1a0179"
Accept-ranges: bytes
Content-length: 364
Connection: close
Content-type: text/html, charset=ISO-8859-1
• Both request headers and response headers must be followed by a blank line
Origins and Evolution of HTML
HTML has lax syntax rules, leading to sloppy and sometime ambiguous documents
– XHTML syntax is much more strict, leading to clean and clear documents in a standard form
HTML processors do not even enforce the few syntax rule that do exist in HTML
The opening tag and its closing tag together specify a container for the content they enclose
➢ If a tag has attributes, they appear between its name and the right bracket of the opening tag
➢ Browsers ignore comments, unrecognizable tags, line breaks, multiple spaces, and tabs
➢ Tags are suggestions to the browser, even if they are recognized by the browser
HTML Document Structure
➢ The <title> tag is used to give the document a title, which is normally displayed in the browser’s window title bar (at the top of the display)
➢ The browser puts as many words of the paragraph’s content as will fit in each
line
<!-- Greet.hmtl A trivial document -->
<html xmlns = ″http://www.w3.org/1999/xhtml″>
<head> <title> Our first document </title>
</head>
<body>
<p>
Greetings from your Webmaster!
</p>
</body>
</html>
➢ Line breaks: The effect of the <br /> tag is the same as that of <p>, except for the blank line
• No closing tag!
• “/” indicates both opening and closing
➢ Example of paragraphs and line breaks:
<!-- headings.html
An example to illustrate headings
-->
<html xmlns = ″http://www.w3.org/1999/xhtml″>
<head> <title> Headings </title>
</head>
<body>
<h1> Aidan’s Airplanes (h1) </h1>
<h2> The best in used airplanes (h2) </h2>
<h3> "We’ve got them by the hangarful" (h3)
</h3>
<h4> We’re the guys to see for a good used
airplane (h4) </h4>
<h5> We offer great prices on great planes
(h5) </h5>
<h6> No returns, no guarantees, no refunds,
all sales are final (h6) </h6>
</body>
</html>
➢ Blockquotes
• Content of <blockquote>
• To set a block of text off from the normal flow and appearance of text Browsers often indent, and sometimes italicize
➢ Font Styles and Sizes (can be nested)
• Boldface - <b>
• Italics - <i>
• Larger - <big>
• Smaller - <small>
• Monospace - <tt>
The <big> sleet <big> in <big> <i> Crete The sleet in Crete
</i><br /> lies </big> completely </big>
in </big> the street lies completely in the street
➢ These tags are not affected if they appear in the content of a <blockquote>, unless there is a conflict (e.g., italics)
➢ Superscripts and subscripts
• Subscripts with <sub>
• Superscripts with <sup>
Example: x<sub>2</sub><sup>3</sup> Display: x23
➢ Inline versus block elements
Block elements CANNOT be nested in inline elements
➢ All of this font size and font style stuff can be done with style sheets, but these tags are not yet deprecated
➢ Character Entities
➢ Horizontal rules
<hr /> draws a line across the display, after a line break
➢ The meta element (for search engines) Used to provide additional information about a document, with attributes, not content
Images
➢ GIF (Graphic Interchange Format)
8-bit color (256 different colors)
➢ JPEG (Joint Photographic Experts Group)
24-bit color (16 million different colors)
➢ Both use compression, but JPEG compression is better
➢ Images are inserted into a document with the <img /> tag with the src attribute
➢ The alt attribute is required by XHTML
Purposes:
1.Non-graphical browsers
2.Browsers with images turned off
<img src = "comets.jpg"
alt = "Picture of comets" />
The <img> tag has 30 different attributes, including width and height (in pixels)
➢ If the rows have labels and there is a spanning column label, the upper left corner must be made larger, using rowspan
➢ Table Sections
• Header, body, and footer, which are the elements: thead, tbody, and tfoot
• If a document has multiple tbody elements, they are separated by thicker horizontal lines
Forms
➢ A form is the usual way information is gotten from a browser to a server
➢ HTML has tags to create a collection of objects that implement this information gathering
➢ The objects are called widgets (e.g., radio buttons and checkboxes)
➢ When the Submit button of a form is clicked, the form’s values are sent to the server
➢ All of the widgets, or components of a form are defined in the content of a <form> tag
➢ The only required attribute of <form> is action, which specifies the URL of the application that is to be called when the Submit button is clicked
➢ The method attribute of <form> specifies one of the two possible techniques of transferring the form data to the server, get and post
➢ Widgets
Many are created with the <input> tag
The type attribute of <input> specifies the kind of widget being created
1. Text
• Creates a horizontal box for text input
• Default size is 20; it can be changed with the size attribute
• If more characters are entered than will fit, the box is scrolled (shifted) left
➢ If you don’t want to allow the user to type more characters than will fit, set maxlength, which causes excess input to be ignored
<input type = "text" name = "Phone"
size = "12" >
2. Checkboxes - to collect multiple choice input
• Every checkbox requires a value attribute, which is the widget’s value in the form data when the checkbox is ‘checked’
• A checkbox that is not ‘checked’ contributes no value to the form data
• By default, no checkbox is initially ‘checked’
• To initialize a checkbox to ‘checked’, the checked attribute must be set to "checked“
Grocery Checklist
<form action = "">
<p>
<input type = "checkbox" name ="groceries"
value = "milk" checked = "checked">
Milk
<input type = "checkbox" name ="groceries"
value = "bread">
Bread
<input type = "checkbox" name = "groceries"
value= "eggs">
Eggs
</p>
</form>
➢ Radio Buttons –
• collections of checkboxes in which only one button can be ‘checked’ at a time
• Every button in a radio button group MUST have the same name
➢ If no button in a radio button group is ‘pressed’, the browser often ‘presses’ the first one
Age Category
<form action = "">
<p>
<input type = "radio" name = "age"
value = "under20" checked = "checked"> 0-19
<input type = "radio" name = "age"
value = "20-35"> 20-35
<input type = "radio" name = "age"
value = "36-50"> 36-50
<input type = "radio" name = "age"
value = "over50"> Over 50
</p>
</form>
➢ Menus - created with <select> tags
➢ There are two kinds of menus, those that behave like checkboxes and those that behave like radio buttons (the default)
➢ Menus that behave like checkboxes are specified by including the multiple attribute, which must be set to "multiple"
➢ The name attribute of <select> is required
➢ The size attribute of <select> can be included to specify the number of menu items to be displayed (the default is 1)
If size is set to > 1 or if multiple is specified, the menu is displayed as a pop-up menu
➢ Text areas - created with <textarea>
• Usually include the rows and cols attributes to specify the size of the text area
• Default text can be included as the content of <textarea>
• Scrolling is implicit if the area is overfilled
Please provide your employment aspirations
<form action = "">
<p>
<textarea name = "aspirations" rows = "3”
cols = "40">
(Be brief and concise)
</textarea>
</p>
</form>
➢ Reset and Submit buttons
Both are created with <input>
<input type = "reset" value = "Reset Form">
<input type = "submit” value = "Submit Form">
Submit has two actions:
1. Encode the data of the form
2. Request that the server execute the server-resident program specified as the value of the action
attribute of <form>
A Submit button is required in every form
Frames
➢ Frames are rectangular sections of the display window, each of which can display a different document
➢ Because frames are no longer part of XHTML, you cannot validate a document that includes frames
➢ The <frameset> tag specifies the number of frames and their layout in the window
<frameset> takes the place of <body>
Cannot have both!
<frameset> must have either a rows attribute or a cols attribute, or both (usually the case)
Default is 1
➢ The possible values for rows and cols are numbers, percentages, and asterisks
A number value specifies the row height in pixels - Not terribly useful!
A percentage specifies the percentage of total window height for the row - Very useful
➢ An asterisk after some other specification gives the remainder of the height of the window
Examples:
<frameset rows = "150, 200, 300">
HTML or HyperText Markup Language is the main XHTML (Extensible HyperText Markup Language) is a
markup language for creating web pages and other family of XML markup languages that mirror or
information that can be displayed in a web browser. extend versions of the widely used Hypertext Markup
Language (HTML), the language in which web pages
are written
Internet media type: text/html application/xhtml+xml
Can have empty/open tags e.g. <br>, <p>. All the unclosed tags must be closed e.g. <br/>,
<p></p>.
Attributes have quotes as optional e.g. <font Attributes have quotes mandatory e.g. <font
color=#ff0000>. color=”#ff0000?>.
Case insensitive:The tags and attributes can be of Case sensitive:The tags and attributes must be of
uppercase or lowercase as per the preference. lowercase.
HTML is not mandatory for one root element. XHTML documents must have one root element.
Explore more on:
A <link> tag is used to specify that the browser is to fetch and use an external style sheet file
Style Specification Formats
➢ Format depends on the level of the style sheet
Inline:
➢ Style sheet appears as the value of the style attribute General form:
➢ Pseudo Classes
• Pseudo classes are styles that apply when something happens, rather than because the target element simply exists
• Names begin with colons
• hover classes apply when the mouse cursor is over the element
• focus classes apply when an element has focus
EXECUTE -3
border-top-style: dotted;
border-right-style: solid;
border-bottom-style: dotted;
border-left-style: solid;
EXECUTE -4
p { EXECUTE -5
margin-top: 100px; p {
margin-bottom: 100px; margin: 25px 50px 75px 100px;
margin-right: 150px; }
margin-left: 80px;
}
EXECUTE -6
h1 {
text-align: center;
}
EXECUTE -7 EXECUTE -8
p { h1 {
font-family: "Times New Roman", Times, serif; font-size: 40px;
} }
EXECUTE -9
p.normal {
font-style: normal;
}
p.italic {
font-style: italic;
}
p.oblique {
font-style: oblique;
}
EXECUTE -10 EXECUTE -11
p.normal { p.normal {
font-weight: normal; font-variant: normal;
} }
p.thick { p.small {
font-weight: bold; font-variant: small-caps;
} }
EXECUTE -12
a:link {
color: red;
}
/* visited link */
a:visited {
color: green;
}
/* mouse over link */
a:hover {
color: hotpink;
}
/* selected link */
a:active {
color: blue;
}
ul.a { ul.a {
list-style-type: circle; list-style-position: outside;
} }
ul.b { ul.b {
list-style-type: square; list-style-position: inside;
} }
ol.c {
list-style-type: upper-roman;
}
ol.d {
list-style-type: lower-alpha;
} table, th, td {
border: 1px solid black;
}
Font Properties
➢ font-family Value: is a list of font names - browser uses the first in the list it has
font-family: Arial, Helvetica, Courier
Generic fonts: serif, sans-serif, cursive, fantasy, and monospace (defined in CSS)
➢ Browser has a specific font for each
If a font name has more than one word, it should be single-quoted
➢ font-size: Possible values: a length number or a name, such as smaller, xx-large, etc.
➢ font-style: italic, oblique (useless), normal
➢ font-weight - degrees of boldness bolder, lighter, bold, normal
Could specify as a multiple of 100 (100 – 900)
font: bolder 14pt Arial Helvetica
Order must be: style, weight, size, name(s)
List properties
➢ The <span> tag is similar to other HTML tags, they can be nested and they have id and class attributes
➢ Another tag that is useful for style specifications: <div>
➢ Used to create document sections (or divisions) for which style can be specified
e.g., A section of five paragraphs for which you want some particular style