Unit - I Web Technologies Notes
Unit - I Web Technologies Notes
in
Web Technologies
(Paper – VI)
Name : ________________________________
Roll No :_______________________________
Unit – I
Introduction To XHTML– Introduction, first HTML, Headings, Linking, Images, special
characters and horizontal rules, Lists, Tables, Frames, Forms, internal linking, meta
Elements.
CASCADING STYLE SHEETS – Introduction, Inline Styles, Embedded Style Sheets, Conflicting
Styles, Linking external sheets, position Elements, box model and text flow, media types,
building a CSS drop-down menu, user style sheets, CSS3..
Unit – II
Introduction To Java Scripting- Introduction, simple program, prompt dialog and alert
boxes, memory concepts, operators, decision making, control structures, if… else
statement, while, counter-controlled repetitions, switch statement, do… while statement,
break and continue statements.
Functions – Program modules in JavaScript, programmer–defined functions, functions
definition, scope rules, global functions, Recursion.
Unit – III
Arrays- Introduction, declaring and allocating arrays, references and reference parameters,
passing arrays to functions. Multidimensional arrays.
EVENTS – registering event handling, event onload, onmouseover, onmouseout, onfocus,
onblur, onsubmit, onreset, event bubbling, more events.
JAVA SCRIPT OBJECTS – introduction to object technology, Math Object, String Object, Date
Object, Boolean and Number Object, document and window Objects, using cookies.
Unit – IV
XML - Introduction, XML Basics, Structuring Data, XML Namespaces, Document Type
Definitions (DTDs), W3C XML Schema Documents, XML Vocabularies, Extensible Style sheet
Language and XSL Transformations, Document Object Model (DOM).
Ajax-Enabled Rich Internet Applications: introduction, history of Ajax, traditional web
applications Vs Ajax Applications, RIAs with Ajax, Ajax example using XMLHttpRequest
object, XML and DOM, creating full scale Ajax-enabled application, Dojo Toolkit.
Text Book:
Internet & World Wide Web: HOW TO PROGRAM- H. M. Deitel, P.J. Deitel, -
Fourth Edition- Pearson edition
Chapter 1
1.1 Introducing HTML:
• HTML stands for Hyper Text Markup Language
• HTML is the predominant mark-up language for web pages. HTML elements are the
basic building-blocks of Webpages.
• HTML is not programming language, it is a markup language
• HTML describes the structure of a Web page
• HTML consists of a series of elements
• HTML elements tell the browser how to display the content
• HTML elements are represented by tags
• Browsers do not display the HTML tags, but use them to render the content of
the page
• Tim Berners-Lee is known as father of Html.
• Hypertext: is text which contains links to other texts. The hypertext pages are
interconnected by hyperlinks, when mouse click on these link which brings you to a new
webpage
• Markup language: Any tag based language known as markup language, for example gml,
Introducing XHTML:
XHTML stands for Extensible HyperText Markup Language. It is a cross between HTML and XML
language. XHTML is designed to replace HTML.
XHTML is almost identical to HTML but it is stricter than HTML. XHTML is HTML defined as an XML
application. It is supported by all major browsers.
Although XHTML is almost the same as HTML but It is more important to create your code
correctly, because XHTML is stricter than HTML in syntax and case sensitivity. XHTML documents
are well-formed and parsed using standard XML parsers, unlike HTML, which requires a lenient
HTML-specific parser.
The opening tag says “ This is the beginning of a heading ” and the closing tag says “ This is the
end of a heading. ”.
1.3 Structure of an HTML Document
<html>
<head>
<title> Document Title Goes Here </title>
...Head information describing the document ....
</head>
<body>
...Document content and markup go here....
</body>
</html>
5
The entire web page is surrounded by <html>…</html> which tell the software that it is now
processing HTML. Within these tags two distinct sections ae created using the <head> …</head>
(i.e. Document Head) tags and the <body>…</body> (i.e. Document body) tags.
1.3.1 Document Head
The < head > element: Often referred to as the head of the page, this contains information about
the page (this is not the main content of the page).
The only tag that most authors insert in their head sections is the title.
<title>. . . </title>
All HTML documents have just one title which is displayed at the top of the browser window.
<head>
<title> Popular Websites: Google </title>
</head>
Between the opening < title > tag and the closing < /title > tag are the words Popular Websites:
Google , which is the title of this web page.
The < body > element: Often referred to as the body of the page, this contains the
information you actually see in the main browser window. It consists of the opening <body> tag,
closing </body> tag, and everything in between.
Together, the < html > , < head > , and < body > elements make up the skeleton of an HTML
document — they are the foundation upon which every web page is built.
The align attribute indicates whether the heading appears to the left, center, or right of the page
(the default is the left). the word “ deprecated ” appears in parentheses in the heading of this
section.
Value Meaning
left The heading is displayed to the left of the browser window (or other
containing element if it is nested within another element). This is the
default value if the align attribute is not used.
center The heading is displayed in the center of the browser window (or other
containing element if it is nested within another element).
right The heading is displayed to the right of the browser window (or other
containing element if it is nested within another element).
<html>
<head>
<title> The effect of the align attribute </title>
</head>
<body>
<h1 align="left"> Welcome </h1>
<h1 align="center"> To </h1>
<h1 align= "right"> Align Program </h1>
</body>
</html>
The < p > element offers another way to structure your text. Each paragraph of text should go in
between an opening < p > and closing < /p > tag .
Syntax :
<p>………</p>
Whenever you use the < br > element, anything following it starts on the next line.
You could use multiple < br > elements to push text down several lines, and many designers use
two line breaks between paragraphs of text rather than using the < p > element to structure text,
as follows:
Syntax :
<br>
1.4.4 Creating Preformatted Text Using the < pre > Element
The <pre> tag in HTML is used to define the block of preformatted text which preserves the text
spaces, line breaks, tabs, and other formatting characters which are ignored by web browsers. Text
in the <pre> element is displayed in a fixed-width font. The <pre> tag requires a starting and end
tag.
Example program on <pre> tag
<html>
<head>
<title>pre tag</title>
</head>
<body>
<pre>
Avanthi Computer Science
</pre>
</body>
</html>
9
If you use a word processor, you will be familiar with the ability to make text bold, italic, or
underlined; these are just three of the ten options available to indicate how text can appear in
XHTML.
The full list is bold, italic, monospaced, underlined, strikethrough, teletype, larger, smaller,
superscripted, and subscripted text.
1.5.4 The < s > and < strike > Elements / Strike Text
The content of an < s > or < strike > element is displayed with a strikethrough, which is a thin line
through the text ( < s > is just the abbreviated form of < strike > ).
Syntax :
<s>………</s>
1.5.5 The < tt > Element
The content of a < tt > element is written in monospaced font (like that of a teletype machine).
Syntax :
<tt>………</tt>
The content of a <sup> element is written in superscript; it is displayed half a character ’ s height
above the other characters and is also often slightly smaller than the text surrounding it.
Syntax :
<sup>………</sup>
10
The < small > element is the opposite of the < big > element, and its contents are displayed one
font size smaller than the rest of the text surrounding it. If the font is already the smallest,
Syntax :
<small>………</small>
The <hr> element creates a horizontal rule across the page. It is an empty element, rather like
the <br> element. This is frequently used to separate distinct sections of a page where a new
heading is not appropriate.
Syntax :
<hr>
11
<html>
<head>
<title>Presentational Elements</title>
</head>
<body>
<b>This will be in bold</b><br>
<i>This will be in italic</i><br>
<u>This will be underlined</u><br>
The scientific notation of Water is H<sub>2</sub>O <br>
(a+b)<sup>2</sup> = a<sup>2</sup> + 2ab + b<sup>2</sup><br>
<s>To show wrong text</s><br>
<tt>TT for Teletype</tt><br>
The following word should be <big> bigger </big> than those
around it. <hr>
The following word should be <small> smaller </small> than
Those around it
</body>
</html>
12
Phrase elements displayed in a manner similar to the Presentational Elements <b> , <i> , <pre> ,
and <tt> , but phrase elements are not just for presentational purposes; they also describe
something about their content.
1.6.1 The <em> Element / Emphasized Text
HTML <em> tag is used to stress emphasis the particular text within a sentence or phrase. It gives
semantic meaning to the text contained within it and renders in the italic form on the browser.
Syntax :
<em>………</em>
Syntax :
<address>………</address>
1.6.4 The < abbr > Element / Text Abbreviation
You can abbreviate a text by placing it between opening < abbr > and closing < /abbr > tags.
using a title attribute whose value is the full version of the abbreviations
Syntax :
<abbr title=” value”>………</abbr>
1.6.5 The < acronym > Element / Acronym Element
It allows you to indicate that the text between opening < acronym > and closing
< /acronym > tags is an acronym.
Syntax :
<acronym title=” value”>………</abbr>
The HTML <blockquote> tag defines a long block quotation in the HTML document from another
source. Browsers traditionally render the text found within the <blockquote> tag as indented text.
This tag is also commonly referred to as the <blockquote> element.
Syntax :
<blockquote>………</ blockquote >
HTML <cite> tag specifies a citation, it provides reference or title to a creative work, quoted
content, books, websites, a research paper, a blog-spot, painting, etc.
The main purpose of adding <cite> element is to provide or identify the source of the quote or any
content.
Syntax :
<cite>Cited Content.......</cite>
The < samp > element indicates sample output from a program, script, or the like. Again, it is mainly
used when documenting programming concepts.
Syntax :
<samp>………</samp>
14
When you are talking about computers, you want to tell a reader to enter some text, you can
use the <kbd> element to indicate what should be typed in.
The content of a <kbd> element is usually represented in a monospaced font, rather like the
content of the <code> element.
Syntax :
<kbd>………</kbd>
HTML <var> tag is a phrase tag which is used to define the variable for a mathematical equation,
or in the programming context.
The content within <var> tag renders in italic font in most of the browsers,
Syntax :
<var>………</var>
<html>
<head>
<title>Phrase Elements</title>
</head>
<body>
It will emphasis the <em>important text</em> of the sentence <br>
<strong>It may heavy rain today, so it will better to be in your
home</strong> <br>
<address>This Notes prepared by Santhosh <br>
Avanthi Degree & PG College </address> <br>
Mouse over the content and see the abbreviation <br> <abbr
title="HyperText Markup language">HTML</abbr> <br>
<acronym title="Osmania University">OU</acronym> <br>
<dfn>HTML</dfn> A markup language for Web designing <br>
<blockquote>
The only way to learn a new programming language is by writing programs
in it
</blockquote>
<cite>-Dennis Ritchie</cite><br>
15
1.7 Lists
HTML Lists are used to specify lists of information. All lists may contain one or more list elements.
There are three different types of HTML lists:
Each bullet point or line you want to write should then be contained between opening
< li > tags and closing < /li > tags (the li stands for list item ).
<html>
<head>
<title>Unordered List </title>
</head>
<body>
<ul>
<li>oranges</li>
<li>apples</li>
<li>pears</li>
</ul>
</body>
</html>
To represent different unordered lists, there are 4 types of attributes in <ul> tag.
Type Description
type "disc" This is the default style. In this style, the list items are marked with bullets.
Ex: <ul> or
<ul type=”disc”>
Type "circle" In this style, the list items are marked with circles.
Ex:
<ul type=”circle”>
Type "square" In this style, the list items are marked with squares.
Ex:
<ul type=”square”>
Type "none" In this style, the list items are not marked.
Ex:
<ul type=”none”>
<html>
<head>
<title>Unordered List </title>
</head>
17
<body>
<ul type="square">
<li>oranges</li>
<li>apples</li>
<li>pears</li>
</ul>
</body>
</html>
In an ordered list, rather than prefixing each point with a bullet point, you can use either numbers
(1, 2, 3), letters (A, B, C), or Roman numerals (i, ii, iii) to prefix the list item.
An ordered list is contained inside the <ol> element. Each item in the list should then be nested
inside the <ol> element and contained between opening <li> and closing </li> tags.
<html>
<head>
<title>Ordered List </title>
</head>
<body>
<ol>
<li>oranges</li>
<li>apples</li>
<li>pears</li>
</ol>
</body>
</html>
18
Using the type Attribute to Select Numbers, Letters, or Roman Numerals in Ordered Lists
By default, the list is ordered by numbers; however, you can change this by using the type attribute.
To represent different ordered lists, there are 5 types of attributes in <ol> tag.
Type "I" In this type, the list items are I, II, III, IV, V (Large Roman
Ex: numbered with upper case roman numerals)
<ol type=”I”> numbers.
Type "i" In this type, the list items are i, ii, iii, iv, v (Small Roman
Ex: numbered with lower case roman numerals)
<ol type=”i”> numbers.
Type "A" In this type, the list items are A, B, C, D, E (Capital letters)
Ex: numbered with upper case letters.
<ol type=”A”>
Type "a" In this type, the list items are a, b, c, d, e (Small letters)
Ex: numbered with lower case letters.
<ol type=”a”>
<html>
<head>
<title>Ordered List1 </title>
</head>
<body>
<ol type="A">
<li>oranges</li>
<li>apples</li>
<li>pears</li>
</ol>
</body>
</html>
19
Using the start Attribute to Change the Starting Number in Ordered Lists
If you want to specify the number that a numbered list should start at, you can use the start
attribute on the < ol > element. The value of this attribute should be the numeric representation
of that point in the list, so a D in a list that is ordered with capital letters would be represented by
the value 4.
<html>
<head>
<title>Ordered List2 </title>
</head>
<body>
<ol type="A" start="4">
<li>oranges</li>
<li>apples</li>
<li>pears</li>
</ol>
</body>
</html>
HTML Description List or Definition List displays elements in definition form like in dictionary. The
<dl>, <dt> and <dd> tags are used to define description list.
<html>
<head>
<title>Definition List </title>
</head>
<body>
<dl>
<dt> Unordered List </dt>
<dd> A list of bullet points. </dd>
<dt> Ordered List </dt>
<dd> An ordered list of points, such as a numbered set of steps. </dd>
20
Anything after <! - - until the closing - - > will not be displayed. It can still be seen in the source
code for the document, but it is not shown onscreen.
21
22
Example :-
<html>
<head>
<title>Link example</title>
</head>
<body>
<a href="http://www.avanthicollege.ac.in/"> Avanthi College </a>
</body>
</html>
Click on “Avanthi College” and it will redirect you to the homepage of our(www.avanthicollege.ac.in)
website.
HTML <a> tag provides you option to specify an email address to send an email. While using <a>
tag as an email tag, you will use mailto: email address along with href attribute.
To create a link to an e - mail address, you need to use the following syntax with the <a>
element:
< a href=”mailto:[email protected]” > [email protected] </a>
Here, the value of the href attribute starts with the keyword mailto , followed by a colon, and then
the e - mail address you want the mail sent to.
<html>
23
<head>
<title>Link example</title>
</head>
<body>
<a href="mailto:[email protected]">E-mail us</a>
</body>
</html>
24
<html>
<head>
<title>Image Tag</title>
</head>
<body>
<img src="C:\Users\Santhu-PC\Downloads\LOGO red 2.jpg" alt="Avanthi Logo">
</body>
</html>
Output:
The height and width attributes specify the height and width of the image, and the values for these
attributes are almost always shown in pixels
Example Program:
<html>
<head>
25
<title>Image Tag</title>
</head>
<body>
<img src="C:\Users\Santhu-PC\Downloads\LOGO red 2.jpg" alt="Avanthi Logo"
height="100" width="100">
</body>
</html>
The align attribute was created to align an image within the page
<html>
<head>
<title>Image Tag</title>
</head>
<body>
<img src="C:\Users\Santhu-PC\Downloads\LOGO red 2.jpg" alt="Avanthi Logo"
height="200" width="200" align="right">
</body>
</html>
26
The align attribute was particularly used by authors who wanted text to flow around an image. The
align attribute can take one of the values in the table that follows
Value Purpose
Top The top of the image is aligned with top of the current line of text.
middle The middle of the image is aligned with the current text baseline.
bottom The bottom of the image is aligned with the baseline of the current line of
text (the default), which usually results in images rising above the text.
left The image is aligned to the left side of the containing window or element
and any text flows around it.
right The image is aligned to the right side of the containing window or element
and any text flows around it.
<html>
<head>
<title>Image Tag</title>
</head>
<body>
Hello <img src="C:\Users\ Santhu-PC\Downloads\LOGO red 2.jpg" alt="Avanthi Logo"
height="100" align="left"> Avanthi <br><br><hr>
</body>
</html>
27
The hspace and vspace attributes can be used to control the amount of white space around an
image.
<html>
<head>
<title>Image Tag</title>
</head>
<body>
<img src="C:\Users\Santhu-PC\Downloads\LOGO red 2.jpg" alt="Avanthi Logo" height="100"
border="2" hspace="50" vspace="50">
</body>
</html>
28
It ’s easy to turn an image into a link; rather than putting text between the opening <a> tag and
the closing </a> tag, you simply place an image inside these tags. Images are
often used to create graphical buttons or links to other pages.
(or)
To use an image as a link, put the <img> tag inside the <a> tag:
Syntax :
<html>
<head>
<title>Image Hyperlink Example</title>
</head>
<body>
<p>click on following image</p>
<a href = "http://www.avanthicollege.ac.in/">
<img src = "C:\Users\Santhu-PC\Downloads\LOGO red 2.jpg" height="100"
width="100">
</a>
</body>
</html>
Output :
You can click on the image (Avanthi Logo) to reach to the home page of Avanthi college.
Browsers tend to support three common bitmap graphics formats, and most graphics programs
will save images in these formats:
GIF: Graphics Interchange Format (pronounced either “ gif ” or “ jif ” )
JPEG: Joint Photographic Experts Group Format (pronounced “ jay peg ” )
PNG: Portable Network Graphics (pronounced “ pee en gee ” or “ ping ” )
29
Adding Flash animations, video, and audio to your pages. Collectively, these are often referred to
as rich media .
In order to show rich media on your pages, you will need to learn a new element, the <object>
element.
<object> element can tell the browser several things, including:
• The name of the file and where to find it
• The format of the file
• The type of plug - in used to play the file
Inside the <object> element, you can use the <param> element to pass extra information to the
player
<html>
<body>
<object width="600" height="400" data=="F:\Motivational.mp4">
</object>
</body>
</html>
30
<html>
<head>
<title>embed tag</title>
</head>
<body>
<embed src="F:\Motivational.mp4" height=600 width=800>
</body>
</html>
<html>
<head>
<title>audio tag</title>
<body>
<embed src="G:\01 - Baitikochi Chuste [NaaSong.in].mp3"> </embed>
</body>
</html>
31
4. Table
HTML table tag is used to display data in tabular form (row * column). There can be many
columns in a row.
We can create a table to display data in tabular form, using <table> element, with the help of
<tr> , <td>, and <th> elements.
In Each table, table row is defined by <tr> tag, table header is defined by <th>, and table data is
defined by <td> tags.
In order to create a table in a Web page, firstly the structure of the table is to be defined using
TABLE tag in HTML. The Beginning and end of a table are marked using <TABLE>and </TABLE>
tags.
Syntax: <table>…............ </table>
When the structure of a table is created <TR> tag is used to add a row in the table. It marks the
beginning of a row.
Synatx:
<table>
<tr>
…
…
</tr>
</table>
There are two types of cell tags used in a table.
1. <th>: Marks a heading cell within a row. It is similar to the heading tag <HI. ... H6> on a web
page and is used to give a proper heading to the columns of the table. This tag is optional and
you can create tables without using <TH>tag.
2. <td>: It is a data cell tag and used for the body of the table.
Synatx:
<table>
<tr>
<th>…</th>
<td>….</td>
…
</tr>
</table>
32
Value Purpose
none No inner borders (b default)
rows Displays horizontal borders between each row
cols Displays vertical borders between each column
all Displays horizontal and vertical borders between each row and column
33
<html>
<head>
<title>Table Tag</title>
</head>
<body>
<table align="center" border="2" rules="all" height="200">
<caption> Student Table</caption>
<tr align="center" width="100">
<th>S.No</th>
<th>Name</th>
<th>Subject</th>
<th>Marks</th>
</tr>
34
<tr align="center">
<th >Group</th>
<th>9:00 to 9:45</th>
<th>9:45 to 10:30</th>
<th>10:30 to 11:15</th>
<th rowspan="4" style="writing-mode:vertical-rl">Break</th>
<th>11:25 to 12:10</th>
<th>12:10 to 01:00</th>
</tr>
36
5. Forms
HTML Forms are required, when you want to collect some data from the site visitor. For example,
during user registration you would like to collect information such as name, email address,
creditcard, etc.
An HTML form is a section of a document which contains controls such as text fields, password
fields, checkboxes, radio buttons, submit button, menus etc.
An HTML form facilitates the user to enter data that is to be sent to the server for processing
such as name, email address, password, phone number, etc.
Creating a Form with the <form> Element
The HTML <form> element provide a document section to take input from user. It provides
various interactive controls for submitting information to web server such as text field, text
area,password field, etc.
Syntax:
<form>
//Form elements
</form>
The different types of form controls that live inside the < form > element to collect data from a
visitor to your site.
▪ Text input controls
▪ Buttons
▪ Checkboxes and radio buttons
▪ Select boxes (sometimes referred to as drop - down menus and list boxes)
▪ File select boxes
5.1.1 Text Inputs
Text input boxes are used on many web pages. Possibly the most famous text input box is
the one right in the middle of the Google homepage that allows you to enter what you are
searching for.
There are actually three types of text input used on forms:
5.1.1.1 Single - line text input controls: Used for items that require only one line of user input,
such as search boxes or e - mail addresses. They are created using the < input > element and
sometimesreferred to simply as “ textboxes. ”
37
Syntax : <form>
<input type=”text” >
</form>
Attributes
Following is the list of attributes for <input> tag for creating text field.
1 type
Indicates the type of input control and for text input control it will be set to text.
2 name
Used to give a name to the control which is sent to the server to be recognized and
get the value.
3 value
This can be used to provide an initial value inside the control.
4 size
Allows to specify the width of the text-input control in terms of characters.
5 maxlength
Allows to specify the maximum number of characters a user can enter into the text
box.
</form>
38
</form>
Attributes
1 name
Used to give a name to the control which is sent to the server to be recognized and
get the value.
2 rows
Indicates the number of rows of text area box.
3 cols
Indicates the number of columns of text area box
1 type
Indicates the type of input control and for checkbox/Radio input control it will be
set to radio.
39
2 name
Used to give a name to the control which is sent to the server to be recognized and
get the value.
3 value
The value that will be used if the Checkbox / radio box is selected.
Syntax : <form>
<input type=”checkbox”>
<input type=”radio”>
</form>
5.1.4 Select Box Control
A select box, also called drop down box which providesoption to list down various options
in the form of drop down list, from where a user can select one or more options.
Syntax : <form>
<select>
<option> Option1
<option> Option2
</select>
</form>
Attributes
1 name
Used to give a name to the control which is sent to the server to be recognized and
get the value.
2 size
This can be used to present a scrolling list box.
3 multiple
If set to "multiple" then allows a user to select multiple items from the menu.
40
1 name
Used to give a name to the control which is sent to the server to be recognized and
get the value.
2 accept
Specifies the types of files that the server accepts.
Syntax : <form>
<input type=”file”>
</form>
1 submit
This creates a button that automatically submits a form.
2 reset
This creates a button that automatically resets form controls to their initial values.
3 image
This creates a clickable button but we can use an image as background of the
button.
41
Syntax : <form>
<input type=”submit”>
<input type=”reset”>
<input type=”image” src=”image path”>
</form>
Usually, the value of the action attribute is a page or program on a web server that will receive
the information.
42
43
6. Frames
Frames divide a browser window into two or more separate pieces or panes, with each pane
containing a separate web page. A collection of frames in the browser window is known
as aframeset.
A frameset divides the window into rows and columns (rather like a table). The simplest of
framesets might just divide the screen into two rows, whereas a complex frameset could use
several rows and columns.
6.1 The <frameset> Element
The <frameset> element replaces the <body> element in frameset documents. It is the attributes
of the <frameset> element that specify how the browser window will be divided up into rows
and columns.
These attributes are as follows:
cols specifies how many columns are in the frameset.
rows specifies how many rows are in the frameset.
The <frameset> element contains a <frame> element for each frame of the document (each cell
of the grid constructed by the <frameset> element) and a <noframes> element to indicate
whatshould be displayed if the user ’ s browser does not load frames.
44
<frameset cols="50%,50%">
45
This takes values either "yes", "no" or "auto". For example scrolling = "no" means it should not
have scroll bars.
46
Auto means Indicates that the browser should include scrollbars when the content does not
fit in the frame, but otherwise should not show them.
47
<html>
<head>
<title>Frames</title>
</head>
<frameset cols="50%,50%" rows="50%,50%" frameborder="2" bordercolor="Red">
<frame src="Headings.html">
<frame src="Presentational.html">
<frame src="Phrasetags.html">
<frame src="Image.html">
<noframes>
<body>Your browser does not support frames.</body>
</noframes>
</frameset>
</html>
48
<html>
<head>
<title>Frames</title>
</head>
<frameset cols="50%,50%" border="2" bordercolor="red">
<frame src="anchor.html" name="Frame1">
<frame src=" " name="Frame2">
<noframes>
<body>Your browser does not support frames.</body>
</noframes>
</frameset>
</html>
49
Meta elements :
The <meta> tag defines metadata about an HTML document. Metadata is data (information)
about data.
<meta> tags always go inside the <head> element, and are typically used to specify character
set, page description, keywords, author of the document, and viewport settings.
Metadata is used by browsers (how to display content or reload page), search engines
(keywords), and other web services.
There is a method to let web designers take control over the viewport (the user's visible area
of a web page), through the <meta> tag (See "Setting The Viewport" example below).
<html>
<head>
<meta charset="UTF-8">
<meta name="description" content="HTML Notes">
<meta name="keywords" content="HTML,CSS,XML,JavaScript">
<meta name="author" content="Santhosh">
<meta name="viewport" content="width=device-width">
</head>
<body>
<p>All meta information goes in the head section...</p>
</body>
</html>
50
Chapter-2
Cascading Style Sheets
Cascading Style Sheets (CSS) provide easy and effective alternatives to specify various
attributes for the HTML tags. Using CSS, you can specify a number of style properties for a given
HTML element.
Each property has a name and a value, separated by a colon (:). Each property declaration is
separated by a semi-colon (;).
Syntax CSS Properties:
Selector Selector : It means any valid tag name
{ Propertyname: which property you want
Propertyname : value; apply on selector
Propertyname : value; Value: Which value is to be set to the
property.
Propertyname : value;
…….
}
1.1 Types of CSS (Cascading Style Sheet) / Where you can Add CSS Rules
Cascading Style Sheet(CSS) is used to set the style in web pages which contain HTML elements.
It sets the background color, font-size, font-family, color, … etc property of elements in a web
pages.
There are three types of CSS which are given below:
• Inline Style Sheet
• Internal or Embedded Style Sheet
• External Style Sheet
1.1.1 Inline CSS: If style attribute is used within the HTML tag then it is known as Inline Style
Sheet.
Syntax: <tagname style=”propertyname : value ; ..”> ….</tagname>
Example: <p style="color: red"> Inline Style Sheets </p>
In the above example “p” is a paragraph tag , “style” is attribute , “color” is property name
and
“red” is value.
Example Program:
<html>
<head>
<title>Inline Style Sheets</title>
</head>
<body>
<p style="color:red; background-color:cyan">
Welcome to Inline Style Sheets</p> </body></html>
51
Example Program:
<html>
<head>
<title>Internal Style Sheets</title>
<style type="text/css">
p
{
color:red;
background-color:cyan;
}
</style>
</head>
<body>
<p> Welcome to Internal Style Sheets</p>
<b> Bold tag</b>
</body>
</html>
52
Syntax:
<head>
...
<link rel="stylesheet" href="filename.css">
...
</head>
• The rel attribute specifies the relationship between the document and the file referred.
• note that the external style sheet can be located anywhere on the web
• the syntax used in external style sheets is the same as for embedded style sheets
(without the style tags).
Styles.css
p
{
color:red;
background-color:cyan;
}
Externalstylesheet.html
<html>
<head>
<title>External Style Sheets</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<p>Welcome to External Style Sheet </p>
<b>Bold
tag</b>
</body>
</html>
53
Selectors have different values of importance (or specificity). Here is the short list (listed in
order of importance):
Example Program :
<html>
<head>
<title>Conflictng Styles</title>
<style>
#abc
{
color: blue;
}
.xyz
{
color: green;
}
p
{
color: pink;
}
</style>
</head>
<body>
<p id="abc" class="xyz"
style="color: red;font- size:25pt">Conflciting Styles</p>
</body>
</html>
54
The CSS position property is used to set position for an element. it is also used to place an
element behind another and also useful for scripted animation effect.
You can position an element using the top, bottom, left and right properties. These properties
can be used only after position property is set first.
There are four types of positioning that can be used to place elements required positions. They
are as follows.
55
<html>
<head>
<title>Position Property</title>
</head>
<body>
<p style="position:static ; left:50px ;
background-color:red" > Static Position </p>
<p style="position:relative ;left:50px;
background-color:green"> Relative Position </p>
<p style="position:absoulute; left:50px;
background-color:purple"> Absolute Position </p>
<p style="position:fixed ; left:50px;
background-color:cyan"> Fixed Position </p>
</body>
</html>
56
i) <div> tag:
The div tag is known as Division tag. The div tag is used in HTML to make divisions of content
in the web page like (text, images, header, footer, navigation bar, etc).
This is very important block level tag which plays a big role in grouping various other
HTML tags and applying CSS on group of elements.
The <div> tag can be used to create webpage layout where we define different parts (Left,
Right, Top etc.) of the page using <div> tag.
This tag does not provide any visual change on the block but this has more meaning when it is
used with CSS.
Syntax :
<div> ……</div>
Example Program:
<html>
<head>
<title>Division Tag</title>
</head>
<body>
<div align="left">
<b> It is Bold Format </b> <br>
<i>It is Italic Formt</i>
</div>
<div align="center">
<b> It is Bold Format </b><br>
<i>It is Italic Formt</i>
</div>
<div align="right">
<b> It is Bold Format </b><br>
<i>It is Italic Formt</i>
</div>
</body>
</html>
57
<divalign="center" style="background-color:#ffff00;
width:200px;line-height:400px;text-align:center ;
float:left;" >
Left
</div>
<div align="center" style="background-color:#ffff00;
width:200px;line-height:400px; float:right" >
Right
</div>
<div style="width:100%;line-height:400px;
text-align:center;" >
Center
</div>
<div style="background-color:#009900; width:100%;
line-height:120px;float:left;text-align:center;">
bottom
</div>
</body>
</html>
58
<html>
<head>
<title>Span tag</title>
</head>
<body>
<p>
Welcome to <span style="color:red">Avanthi</span>
Degree <span style="color:blue">College</span>
</p>
</body>
</html>
59
60
we can individually change the color of the bottom, left, top, and right sides of a
box ’ s border using the following properties:
border-bottom-color
border-right-color
border-top-color
border-left-color
The border - style Property
The border - style property allows you to specify the line style of the border:
p
{
border-style:solid;
}
The default value for this property is none , so no border would be shown automatically.
The table that follows shows the possible values.
We can individually change the style of the bottom, left, top, and right borders of a box using
the following properties:
border-bottom-style
border-right-style
border-top-style
border-left-style
61
The border - width property allows you to set the width of your borders; usually the width is
specified in pixels.
p
{
border-style:solid;
border-width:4px;
}
The value of the border - width property cannot be given as a percentage, although you could
use any absolute unit or relative unit, or one of the following values:
thin
medium
thick
We can individually change the width of the bottom, top, left, and right borders of a box using
the following properties:
border-bottom-width
border-right-width
border-top-width
border-left-width
Expressing Border Properties Using Shorthand
The border property allows you to specify color, style, and width of lines in one property:
P
{
border: 4px solid red;
}
Example Program on border properties :
<html>
<head>
<title>Border Properties</title>
<style>
p
{
border-color:#ff0000;
border-style:solid;
border-width:4px;
}
</style>
</head>
<body>
<p> This is Paragraph tag with Border properties </p>
</body>
</html>
62
<html>
<head>
<title>Border and Padding Properties</title>
<style>
p
{
border: dotted 4px red;
padding : 5px;
}
</style>
</head>
<body>
<p> This is Paragraph shorthand Border and Padding
Properties </p>
</body>
</html>
63
<html>
<head>
<title>Border and Padding Properties</title>
<style>
p,h1
{
border: dotted 4px red;
margin: 50px;
}
</style>
</head>
<body>
<h1> Heading 1</h1>
<p> This is Paragraph shorthand Border and Margin
Properties
</p>
</body>
</html>
64
Example Program using Border, Padding Margin and Text flow property
<html>
<head>
<title>Border Margin & Padding Properties</title>
<style>
p,h1
{
border: dotted 4px red;
margin: 50px;
padding : 5px;
text-align:center;
float:right;
}
</style>
</head>
<body>
<h1> Heading 1</h1>
<p> This is Paragraph shorthand Border and Margin
Properties
</p>
</body>
</html>
65
Dimensions of a Box
The following properties are allowing you to control the dimensions
of boxes.
66
3. Select Internet options from the drop down menu, you can then access
Internet Options immediately and Select the ' Accessibility ' button. The
Accessibility dialog box will appear.
.html file
<html>
<head>
<title>User Style Sheets</title>
</head>
<body>
<p> Applying user styles </p>
<p> In Internet Explorer </p>
</body>
</html>
Mystyle.css
*
{
background-color:cyan;
color:red;
font-size:20pt;
}
68
<html>
<head>
<title>Css Drop-down Menu</title>
<style>
.abc
{
font-weight:bold;
text-align:center;
color:white;
width:10em;
background-color:blue
}
div.abc:hover a
{
color:black;
display:block;
background-color:white;
}
a
{
color:orange;
}
</style>
</head>
<body>
<div class="abc"> UG Course<br>
<a href="#">BSc</a>
<a href="#">BCom</a>
<a href="#">BBA</a>
<a href="#">BA</a>
</div>
</body>
</html>
69
1.7 CSS3
CSS3 is the latest version of the CSS specification. CSS3 adds several new styling features and
improvements to enhance the web presentation capabilities.
70
<html>
<head>
<title>Mediatypes </title>
<style>
@media all
{
body { background-color:cyan }
p
{
font-size: 12pt; color: black;
}
h1
{
color:red;
}
} /* end @media all declaration. */
@media print
{
p
{
font-size: 14pt; color: lime;
}
h1
{
color:cyan;
}
} /* end @media all declaration. */
</style>
</head>
<body>
<h1> CSS Media Type Example </h1>
<p> This text will appear one font on the screen and a
different font on paper or in a print preview. To see
the difference in Internet Explorer, go to the Print menu
and select Print Preview. In Firefox, select Print
Preview from the File menu.</p>
</body>
</html>
71
Unit-I Questions
1. Write about HTML & XHTML
2. Explain about presentational and Phrase elements
3. Write about headings and Images
4. Define list. What are the different types of lists in html? Explain how these lists are
created in HTML with suitable examples.
5. Explain in detail about Table with an example
6. What is Frame ? Explain working of the frames with examples.
7. Write about forms and explain about different types of form controls.
8. What is Cascading Style Sheets (CSS) ? Explain different types of Style sheets (Types
of CSS)
9. Explain about meta elements with an example
10. Write about Conflict Style sheets
11. Position elements
12. Explain about Box model and Text flow
13. Explain in detail about media types.
14. Discuss about building / Creating a CSS drop-down menu
15. Write about user style sheets and CSS3
72