Wa0012
Wa0012
The internet is a collection of connected computers that communicate with each other. The Web is a
collection of protocols (rules) and software’s that support such communication.
In most situations when two computers communicate, one acts as a server and the other as a client,
known as client-server configuration.
Browsers running on client machines request documents provided by servers. Browsers are so
called because they allow the user to browse through the documents available on the webservers. A
browser initiates the communication with a server, requesting for a document. The server that is
continuously waiting for a request, locates the requested document and sends it to the browser,
which displays it to the user.
The most common protocol on the web is Hyper Text Transfer protocol (HTTP)
The most commonly used browsers are Microsoft Internet Explorer (IE).Netscape browser and
Mozilla. The most commonly used web servers are Apache and Microsoft Internet Information
server (IIS).
HTML Basics
Hyper Text Markup Language is a simple markup language used to create platform- independent
hypertext documents on the World Wide Web. Most hypertext documents on theweb are written in
HTML.
You will need a simple text editor to write html codes. For example you can use notepad in
windows and Vi editor in Linux operating system. You will need a browser to view thehtml code,
you can use IE on windows and Mozilla on Linux operating system.
HTML tags are somewhat like commands in programming languages. Tags are not
themselvesdisplayed, but tell the browser how to display the document’s contents.
Every HTML tag is made up of a tag name, sometimes followed by an optional list of attributes, all
of which appears between angle brackets < >. Nothing within the brackets will bedisplayed in the
browser. The tag name is generally an abbreviation of the tag’s function.
1
Attributes are properties that extend or refine the tag’s function. The name and attributes within
a tag are not case sensitive. Tag attributes, if any, belong after the tag name, each separated by
one or more spaces. Their order of appearance is not important. Most attributestake values,
which follow an equal sign (=) after the attribute’s name. Values are limited to 1024 characters
in length and may be case sensitive. Sometimesthe value needs to appear in quotation marks
(double or single).
Most HTML tags are containers, meaning they have a beginning start tag and an end tag. Anend
tag contains the same name as the start tag, but it is preceded by a slash (/). Few tags do not
have end tags.
HTML5
HTML5 is still a work in progress. However, the major browsers support many of the new HTML5
elements and APIs.
New features of HTML5 are based on HTML, CSS, DOM, and JavaScript. To better handle today's
internet use, HTML5 also includes new elements for drawing graphics, adding media content,
better page structure, better form handling, and several APIs to drag/drop elements, find
Geolocation, include web storage, application cache, web workers, etc. Some of the most
interesting new features in HTML5 are:
The latest versions of Apple Safari, Google Chrome, Mozilla Firefox, and Opera all support many HTML5
features and Internet Explorer 9.0 will also have support for some HTML5 functionality.
The mobile web browsers that come pre-installed on iPhones, iPads, and Android phones all have excellent
support for HTML5.
<!DOCTYPE html>
2
The <!DOCTYPE> declaration helps the browser to display a web page correctly. There are many
different documents on the web, and a browser can only display an HTML page 100%correctly if it
knows the HTML type and version used.
The <header> tag specifies a header for a document or section. The <header> element shouldbe
used as a container for introductory content or set of navigational links.You can have several
<header> elements in one document.
The <footer> tag defines a footer for a document or section. A <footer> element should contain
information about its containing element. A footer typically contains the author of thedocument,
copyright information, links to terms of use, contact information, etc.
Some HTML tags required to design simple web pages are given below
Tag Description
<!DOCTYPE> Defines the document type
<TITLE> One of the most important parts of a header is title. Title is the small text that
</TITLE> appears in title bar of viewer's browser.
<BODY> Every web page needs a body in which one can enter web page content
</BODY>
<BR> A single tag used to break lines
<p> A single tag used to break text. Breaking text with the<p>tag adds vertical spacing
3
<CENTER> Centers enclosed text
</CENTER>
<BIG></BIG> Sets the type one font size larger than the surrounding text
<SMALL> Sets the type one font size smaller than the surrounding text
</SMALL>
<SUB></SUB> Formats enclosed text as subscript.
<Header> The <header> tag specifies a header for a document or section. The
<header> element should be used as a container for introductory content or set of
navigational links.
You can have several <header>elements in one document. Note:A<header>
tag cannot be placed within a <footer>, <address>or another
<header>element
<footer> The<footer>tag defines footer for a document or section.
A<footer>element should contain information about its containing
element.
An HTML document is divided into two major portions: the head and the body. The head contains
information about the document, such as its title and “meta” information describingthe contents.
The body contains the actual contents of the document (the part that is displayed in the browser
window).
<!---MyfirstProgramme--!>
<!DOCTYPE html>
<html>
<body>
66
4
A sample HTML5 document is given below
<HTML>
<HEAD>
<TITLE>MyWebpage</TITLE>
</HEAD>
<BODY BACKGROUND=”myimage.jpg”text=”#FF0000”>
The<FONTsize=6>Fontsize</FONT>canbechanged<Br>aswellas<FONTcolor=”#00
<!DOCTYPE html>
<html>
<body>
<b>Bold Text</b><br>
<i>Italic Text</i><br>
<sup>superscripted Text</sup><br>
<sub>subscripted Text</sub><br>
<big> Big Text><br>
<strong> String Text</strong><br>
<u>Underlined Text</u>
<font face="Arial" size="10" color="blue">Formatted Text</font>
</body></html>
Lists: Lists are a great way to provide information in a structured and easy to read format.
5
Tags used to create lists are given in the following table.
face="Arial” size="6"
color="orange">
<i><u><b>
List of
Fruits
</i></u></b>
<ul type="square">
<li>Apple
<li>Pinapple
<li>Mango
<li>Guava
</ul>
6
</body>
</html>
7
Tables: A table is a two dimensional matrix, consisting of rows and columns. HTML tables are
intended for displaying data in columns on a web page. Tables contains information such as text,
images, forms, hyperlinks etc.
Tags used to create table are given in the following table.
8
A sample HTML document for creating table is given below
<!DOCTYPEhtml>
<html>
<head>
</head>
<body>
<caption>List of Books</caption>
<tr>
<th align="center"colspan=2>Price</th>
</tr>
<tr>
<th align="center">Rs.</th>
<th align="center">Paise</th>
Frames : Using frames, one can divide the screen into multiple scrolling sections, each of which
can display a different web page in to it. It allows multiple HTML documents to be seen
concurrently
Inline frames: It is a new frame tag introduced in HTML5. It is having same properties and attribute
options as in<FRAME>tag. An<iframe>tag is used to display a web page within a web page. Inline
frames can be included within the text block in HTML5 document.
<iframesrc="URL"></iframe>
9
Tags used to add frames are given in the following table
10
<IFRAME> <iframe> Iframe Attribute 1. <iframesrc="C:\
</IFRAME> Docum
Tag is used Attribute Specifications to entsandSettings\
to specify an Adjust Appearance and Desktop\
inline frame. Behavior a7.html"width="150"h
eig
An inline o src="(URL ht="150"></iframe>
frame of initial
Allows iframe
you to content)" 2. <iframename="inli
embed o name="(name of neframe"src="float
another frame ,required .h
document for targeting)" tml"frameborder="
within the o long desc="(link 0"
current to long scrolling="auto"wi
HTML description)" dt
document. o width=(frame h="500"height="1
The width,% or 80
HTML5 pixels) "marginwidth="5"
Specificatio o height=(frame ma rginheight="5"
n refers to height,%or ></iframe>
this as pixels)
a"nested o align=[top|middle|
browsing bott om|left| right|
context". center
](frame alignment, pick two,
use comma)
o frame border=[1|
0](frame border,
default is1)
o margin
width=(margi
n width, in
pixels)
o margin
height=(margi
n height, in
pixels)
o scrolling=[yes|no|auto
](ability to scroll)
11
What is CSS?
CSS is an acronym for Cascading Style Sheets.CSS is a style language that defines layout
ofHTML documents. For example, CSS covers fonts, colours, margins, lines, height, width,
background images, advanced positions and many other things. Just wait and see!
HTML can be (mis-)used to add layout to websites. But CSS offers more options and is
moreaccurate and sophisticated. CSS is supported by all browsers today.
HTML is used to structure content. CSS is used for formatting structured content. The language
HTML was only used to add structure to text. An author could mark his text by stating "this is a
headline" or "this is a paragraph" using HTML tags such as <h1> and <p>.
As the Web gained popularity, designers started looking for possibilities to add layout to
onlinedocuments. To meet this demand, the browser producers (at that time Netscape and
Microsoft) invented new HTML tags such as for example <font> which differed from the original
HTML tags by defining layout - and not structure.
This also led to a situation where original structure tags such as <table> were increasingly being
misused to layout pages instead of adding structure to text. Many new layout tags such as
<blink> were only supported by one type of browser. "You need browser X to view this page"
became a common disclaimer on web sites. CSS was invented to remedy this situation by
providing web designers with sophisticated layout opportunities supported by all browsers.At
the same time, separation of the presentation style of documents from the content of documents,
makes site maintenance a lot easier.
Advantages of CSS: CSS was a revolution in the world of web design. The concrete benefitsof
CSS include:
12
How does CSS work?
In this assignment you will learn how to make your first style sheet. You will get to know about
the basic CSS model and which codes are necessary to use CSS in an HTML document.
Many of the properties used in Cascading Style Sheets (CSS) are similar to those of HTML.Thus, if
you are used to use HTML for layout, you will most likely recognize many of the codes. Let us
look at a concrete example.
<body bgcolor="#FF0000">
With CSS the same result can be achieved like this: body
{background-color: #FF0000;}
body{background-color:#FF0000;}
As you will note, the codes are more or less identical for HTML and CSS. The above examplealso
shows you the fundamental CSS model:
rule=selector + declaration
13
But where do you put the CSS code? This is exactly what we will go over now.
One way to apply CSS to HTML is by using the HTML attribute style. Building on the
aboveexample with the red background color, it can be applied like this:
:
<html>
<head>
<title>Example</title>
</head>
<body style="background-color:#FF0000;">
Another way is to include the CSS codes using the HTML tag <style>. For example like this:
<html>
<head>
<title>Example</title>
<style type="text/css">
{background-color:#FF0000;}
14
</style>
15
</head>
<body>
<p>This is a red page</p>
</body>
</html>
Samplecode1:
<!DOCTYPEhtml>
<html>
<head>
<style>bod y
{
background-color:#d0e4fe;
h1
color:orange; text
align:center;
}
p
font- family:"TimesNewRoman";font
-size:20px;
</style>
</head>
<body>
<h1>CSSexample!</h1>
16
<p>This is a paragraph.</p>
</body>
</html>
Method 3
External style sheets are separate files full of CSS instructions (with the file extension .css). When any web
page includes an external style sheet, its look and feel will be controlled by this CSS file (unless you decide
to override a style using one of these next two types). This is how you change a whole website at once. And
that's perfect if you want to keep up with the latest fashion in web pages without rewriting every page!
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="mystyle.css">
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body></html>
Creation of forms
Forms: HTML5 provides better & more extensive support for collecting user inputs throughforms.
A form can be placed anywhere inside the body of an HTML document.
17
You can have more than one form in the document.
Tags used to add input forms are given in the following table.
18
</SELECT> and Age Between:
displays name="(name to be passed <select
to the script as part of name=”age”
a name/value pair)" size=1>
set rows="no. of </select>
rows"
of cols="(no. of
cols.)"
optional
list items
fro
m
which
the user
can select
one or
more items.
<TEXTAREA> Multi name=name of data <textarea
</ field rows=10columns=40>
line
TEXTAREA> size=#of item s to display </textarea>
text
multiple allows multiple
entry selections
widget
<OPTION> indicates <select
a possible selected=default selection name=”age”
item value="data submitted if this size=1>
within option is selected" <option selected>21-30
a <option>31-40
select </select>
widge
t
HTML5 introduces 13 new input types. When viewed in a browser that doesn't support them, these
input types fall back to text input.
19
type=”text”></form>
Legend Define <form>
∙ <legend>create
a new
Caption for acount</legend>
field </form>
set
eleme
nt
20
is 0, and the the
default for max
is100
Date For ● value: The initial
entering a value. The format <input type="date"
date with is "yyyy-mm-dd". name="some-
no time ● step: The step size name"/>
zone. in days. The
default is1.
● min,max: The
smallest and largest
dates that can be
selected, formatted
as date strings of
the
form "yyyy-mm-dd".
Time For
entering a <input type="time"/>
time value
with hour,
minute,
seconds,
and
fractional
seconds,
but no time
zone.
Datetime-local For
entering <input type="datetime-
a date local"/>
and
Time
with no
time
zone.
Color For ● value: The initial <input type="datetime-
choosing value. The intention local"/>
color is that if a browser
through pops up a color chooser,
the initial
a
21
Color Selection will match the
well current value.
control
Email For
entering a ● value: The initial <input type="email"
value(a legal name="some-
single mail email address). name"/>
address or ● list: The id of a <input
a list of separate" data list" type="email"
email element that defines list="email-
addresses. a list of email choices"
addresses for the name="some
user to choose - name"/>
among <datalist
id="email
-
choices">
<option
label="Marty Hall"
value="hall@coreservlet
s
.com">
<option
label="Somebody Else"
value=
"someone@example
.com">
<option
label="ThirdPerson"
value="other@example.c
om">
...
</data list>
URL For ● value: The initial <input type="url"
entering a value, as an name="some-name"/>
single absolute URL. <input type="url"
URL. ● list: The id of a list="url-choices
separate "data list" "name="some-
element that defines name"/>
a list of URLs for <data list
the user to choose id="url-
among. choices"
>
</datalist>
22
Tel For ● value: The initial <input type="tel"
entering value as a phone number name="some-name"/>
A
telephone
number.
23
The value wins, and place
holder is ignored.
24
the text field when
the entry is
selected.
● value: The value
that should be
inserted into the
text field when the
entry
is selected.
25
Try this Code
<!DOCTYPE html>
<html>
<body>
<form>
<h3>Registration Form</h3>
Enter your Name <input type="text" name="t1"> Your
Email Address<input type="email" name="t2"> Your
Phone Number<input type="text" name="t3"> Your City
<select name=t4>
<option>Nashik</option>
<option>Pune</option>
<option> Mumbai</option>
</select>
Gender
Male <input type=radio name=r1>
Female<input type=radio name=r1>
<input type=submit value="display">
</form>
</body>
</html>
Every element that can be displayed on a web page is comprised of one or more rectangular boxes. CSS
box model typically describes how these rectangular boxes are laid out on a web page. These boxes can
have different properties and can interact with each other in different ways, but every box has a content
area and optional surrounding padding, border, and margin areas.
The following diagram demonstrates how the width, height, padding, border, and margin CSS
properties determines how much space an element can take on a web page.
26
The specific area that an element box may occupy on a web page is measured as follows-
div {
width: 300px;
border: 15px solid green;
padding: 50px;
margin: 20px;
}
A navigation bar is mostly displayed on the top of the page in the form of a horizontal list of links.
<html>
<head>
<style> #ul-
nb {
list-style: none;
margin:2px;
padding:3px;
}
#ul-nb li { float:left;
padding:10px;
background:orange; text-
align: center; margin-
left:5px;
}
#ul-nbli:hover
{ background:red;
opacity:0.8; color:white;
}
</style> 29
</head>
<body>
<ul id="ul-nb">
<li><a href="#">Home</a></li>
<li><a href="#">About Us</a></li>
<li><a href="#">Community</a></li>
<li><a href="#">Careers</a></li>
</ul>
</body>
</html>
Set-A
Q1) Create a HTML document to display the following screen.
List of Books
Price
Item No Item Name
Rs. Paise
SET B
Q 1. Write the HTML code for generating the form as shown below.
Apply the internal CSS to following form change the font size of the heading to 6pt and change the color to
red and also change the background color yellow
Q 2. Write HTML 5 code which generates the following output and display each element of list in
different size, color & font. Use external CSS to format the list
31
Q 3. Create HTML5 page with following specifications
i) Title should be about your City.
ii) Color the background by Pink color.
iii) Place your city name at the top of page in large text and in blue color. iv) Add names
of the landmarks in your city, each in different color, style and font
v) Add scrolling text about your City.
vi) Add any image at the bottom. (Use inline CSS to format the web page)
Set C.
Q 1. Design HTML 5 Page Using CSS which display the following Box ( use
Box Model Property in CSS)
32
Q 2Design HTML 5 Page Using CSS Which Display the following Navigation Bar
33