CS HTML QB-1
CS HTML QB-1
HTML
Descriptive Questions
Q.1) What is HTML? Explain advantages and disadvantages of HTML.
Answer:
HTML is an evolving language, and stands for Hyper Text Markup Language
It is a text file containing small markup tags which are instructions given to
browser about how to display the page.
An HTML file must have an htm or html file extension.
An HTML file can be created using a simple text editor (like Notepad in
windows).
Advantages of HTML
1) HTML is an easy to use, learn, implement and flexible alternative to
traditional presentation and tedious software.
2) HTML documents are device and platform independent. (Since it can be
designed to work on not only home PCs but also on graphical workstations,
dumb terminals, network computers, hand-held devices etc.)
3) You can traverse to any HTML document required because of hyper linking
facility available, thus controlled navigation is possible.
4) Required HTML pages can be updated easily, without changing whole
document.
5) Independent work can be done and you need not rely on application or
program vendor.
6) No expensive license software or hardware required.
Disadvantages of HTML
1) HTML doesn’t offer programming languages features and capabilities.
2) It's easy to write "bad" HTML containing errors.
3) Complex HTML code is hard to read and understand and code complexity
increases to make interactive web page. So building complex pages is very time
consuming.
4) It's easy to make mistakes (e.g. leaving out a ">" or "/" character).
5) Special types of software like scripting languages (VB Script, Java Script) are
required for handling different events and validations.
6) Can’t detect errors easily since no special debugging tool is provided.
Q.2) What is element , tag and attribute with respect to HTML?
Answer:
Element:
An element is a fundamental component of the structure of a text document. Some
examples of elements are heads, tables, paragraphs, and lists. Elements can contain
plain text, other elements, or both.
Tags:
HTML elements are defined using HTML tags.
HTML tags are used to mark-up HTML elements.
HTML tags are surrounded by the two characters < and >
The surrounding characters are called angle brackets.
HTML tags normally come in pairs like <b> and </b>they are usually paired
to start and end the tag instruction.
The first tag in a pair is the start tag, the second tag is the end tag.
The text between the start and end tags is the element content.
HTML tags are not case sensitive; <b> means the same as <B>.
Syntax is:
<tag name> text (element content) </tag name>
<tag name attribute name=”argument/value”> text (element
content)
</tag name>
or just
<tag name>
For example:
1)<TITLE> WELCOME TO MY WEBSITE </TITLE>
Tag Attributes :
Tags can have attributes. Attributes can provide additional information about the
HTML elements on your page, included inside the start tag.
Attributes always come in name/value pairs like this: name="value"
Syntax is
<tag name attribute name=”value”>
e.g. <IMG SRC=”c:\a.jpg”>
so here src is an attribute for image tag. Normally its value is specified in quotes.
<HTML>
< HEAD >
<TITLE> HOME PAGE
</TITLE>
</HEAD>
<BODY> THIS IS MY FIRST WEB PAGE
</BODY>
</HTML>
Example Explained
The first tag in your HTML document is <HTML>. This tag tells your
browser that this is the start of an HTML document. The last tag in your document is
</HTML>. This tag tells your browser that this is the end of the HTML document.
The text between the <HEAD> tag and the </HEAD> tag is header information.
Header information is not displayed in the browser window. The title is displayed in
your browser's caption.
The text between the <BODY> tags is the text that will be displayed in your
browser.
The text between the <TITLE> tags is the title of your page
Syntax
<HEAD>...</HEAD>
e.g. <HTML>
<HEAD>
<TITLE>WELCOME TO FIRST WEBSITE</TITLE>
</HEAD>
</HTML>
SCOAS&C_CS_TG
TITLE
The title of a document is specified by the TITLE element, which should be
placed in the document HEAD. Each document can have only one title, which should
identify the document content in a general way.
The Title is not part of the document text and cannot contain hypertext links
or special markup commands -- it must be simple text. Often the title is used to label
the window displaying the text, or is used to label a place in a browser's history or
bookmark list. It therefore should be short -- less than 64 characters
e.g.<BODY>
<H1>This is my first web page</H1>
<HR SIZE=5 WIDTH=”20%”>
</BODY>
Headings
<H1>---<H6> Defines heading 1 to heading 6.
Headings are defined with the <H1> to <H6> tags. <H1> defines the largest
heading. <H6> defines the smallest heading (as shown).
SCOAS&C_CS_TG
Q.7) Explain following HTML tags:
1)<MARQUEE> 2)<SUB>3)<SUP>
Ans:
1)<MARQUEE> TAG
MARQUEE, supported only by the Microsoft Internet Explorer 2 (and later)
browser, is used to create a scrolling text marquee.
e.g. <MARQUEE ALIGN=”top”>Scrolling text </MARQUEE>
creates a text marquee with the enclosed text scrolling along the frame.
The another attribute is DIRECTION defining direction of the marquee text.
e.g.<MARQUEE DIRECTION=”RIGHT”>WELCOME</MARQUEE>
So here WELCOME scrolls from left towards right. The default direction is
right to left.
But other commercial browsers, including Netscape Navigator, do not support
this element.
Q.8) What is URL? Explain hyper linking facility provided by html in detail
with various examples.
Answer:
URL stands for Uniform Resource Locator, which may represent an address
of document on web or Internet or simply a path to a document in a specific directory.
The World Wide Web uses Uniform Resource Locators (URLs) to specify the
location of files on other servers. A URL includes the type of resource being accessed
(e.g., Web, gopher, FTP), the address of the server, and the location of the file.
HTML provides you to jump from a link to any document or image or any
local or WebPages by using special tag, called <a> i.e. Anchor tag.
Syntax is: <A HREF=”URL”>name or image which can be treated as link</A>
Thus anchor is a piece of text or some other object (e.g. image), which marks
the beginning and/or the end of a hypertext link. The <A> element is used to mark that
piece of text (or inline image), and to give its hyper textual relationship to other
documents. The text between the opening and closing tags, <A attributes> ...text... </A>
can act as start or destination (or both) of a link. The HREF attribute (which is
actually optional) marks the anchor as the start of a link to another document or
resource (it could point, for example, to an image file), or to a particular place in
another document.
Syntax is:
<A HREF="URL (absolute or relative path)">anchor name </A>
An absolute or partial URL can specify the address of the referenced document:
SCOAS&C_CS_TG
Q.10) Explain various list types in html.
Answer:
HTML supports ordered, unordered and definition lists.
The different types of list tags are as follows
<OL> Defines an ordered list
<UL> Defines an Unordered List
<LI> Defines a list item
<DL> Defines a definition list
<DT> Defines a definition term
<DD> Defines a definition description
1. Unordered Lists
An unordered list is a list of items. The list items are marked with bullets (typically
small black circles). To make an unnumbered, bulleted list,
1. Start with an opening list <UL> (for unnumbered list) tag Enter the <LI> (list item)
tag followed by the individual item; no closing </LI> tag is needed
2. End the entire list with a closing list </UL> tag
Inside a list item you can put paragraphs, line breaks, images, links, other lists, etc.
e.g. <HTML>
<BODY>
<H4>This is Unordered List</H4>
<UL type = "circle">
<LI>Sunday</LI>
<LI>Monday</LI>
<LI>Tuesday</LI>
</UL>
</BODY>
</HTML>
2. Ordered Lists
An ordered list is also a list of items. The list items are marked with
numbers. A ordered list also called as numbered .It is identical to an unnumbered
list, except it uses <OL> instead of <UL>. Inside a list item you can put paragraphs, line
breaks, images, links, other lists, etc. You can specify style of numbering for the list
items by giving type attribute in <OL> tag and it can take values "I" for uppercase
roman, "i" for lower case roman, "A" for uppercase letters, "a" for lower case alpha
numeric letter. The start attribute in <OL> tag is used to start the list from the
required number. e.g. <OL start = "6"> will start the list items from number 6.
e.g. <HTML>
<BODY>
<H4><B>This is an Ordered List</B></H4>
<OL type = "i">
<LI>Sunday</LI>
<LI>Monday</LI>
<LI>Tuesday</LI>
</OL>
</BODY>
</HTML>
so output given by browser is:
3. Definition Lists
A definition list is not a list of items. This is a list of terms and explanation of
the terms. A definition list starts with the <DL> tag. Thus a definition list (coded as
<DL>) usually consists of alternating a definition term (coded as <DT>) and a
definition description (coded as <DD>). Web browsers generally format the definition
on a new line and indent it.
e.g.
<HTML>
<BODY>
<H4>This is a Definition List</H4>
<DL>
<DT>VB</DT>
<DD>Programming Language</DD>
<DT>VB SCRIPT</DT>
<DD>Scripting Language </DD>
</DL>
</BODY>
</HTML>
so output given by browser is:
SCOAS&C_CS_TG
VB SCRIPT
Scripting Language
Inside a definition-list definition (the <DD> tag) you can put paragraphs, line breaks,
images, links, other lists, etc.
4.Nested lists
Lists can be nested. You can also have a number of paragraphs, each containing a
nested list, in a single list item.
e.g.
<HTML>
<BODY>
<H4>This is example of Nested List</H4>
<UL>
<LI>Scripted Programming</LI>
<LI>Structured Programming
<UL>
<LI>Basic</LI>
<LI>PASCAL</LI>
</UL>
</LI>
<LI>Object Oriented Languages</LI>
</UL>
</BODY>
</HTML>
Table Attributes
ALIGN
It specifies the horizontal placement of the table.
LEFT aligns the table on the left (the default).
RIGHT aligns the table on the right.
CENTER aligns the table in the center
BGCOLOR="color"
It sets the color of the background for the table. This color can be overridden by a
BGCOLOR tag in the TH, TR, or TD tags.
CELLPADDING="value"
It determines the amount of space, in pixels, between the border of a cell and the
contents of the cell. The default is 1.
CELLSPACING="value"
It determines the amount of space, in pixels, between individual cells in a table.
The default is 2.
HEIGHT="height"
It specifies the height of the table. The default is the optimal height determined by
the contents of each cell. It can be a number of pixels, or a percentage of the
height of the page or parent element.
SCOAS&C_CS_TG
WIDTH="width"
It defines the width of the table. The default is the optimal width determined by
the contents of each cell. It can be a number of pixels, or a percentage of the
height of the page or parent element.
COLS="numberOfColumns"
It indicates how many virtual columns of equal width fit in the width of the
window. If the WIDTH attribute is supplied, the COLS attribute indicates how
many virtual columns fit in the specified width. Suppose that the WIDTH
attribute is "80%" and the COLS attribute is 4. In this case, each column takes up
20% of the width of the window. Note, however, that if the minimum width
needed to display the contents of an actual column is greater than the width of a
virtual column, then the width of the column is expanded to fit its contents.
HSPACE="horizontalMargin"
It specifies the distance between the left and right edges of the table and any
surrounding content.
VSPACE="verticalMargin"
It specifies the distance between the top and bottom edges of the table and any
surrounding content.
Similarly you can define attributes within <TH> ... </TH> or <TD> ... </TD>
cells as---
ALIGN (LEFT, CENTER, RIGHT):- Horizontal alignment of a cell.
VALIGN (TOP, MIDDLE, BOTTOM):- Vertical alignment of a cell.
COLSPAN=n The number (n) of columns a cell spans.
ROWSPAN=n The number (n) of rows a cell spans.
PRGRAMMING LANGUAGE
JAVA
OBJECT ORIENTED LANGUAGE
C++
C
STRUCTURED LANGUAGE
BASIC
SCOAS&C_CS_TG
Syntax
<IMG
SRC="location"
ALT="alterntiveText"
ALIGN="alignment"
BORDER="borderWidth"
HEIGHT="height"
WIDTH="width"
HSPACE="horizMargin"
VSPACE="verticalMargin"
>
The SRC attribute is compulsory
SRC="location (URL)"
It specifies the URL of the image to be displayed in the document.
ALT="alternative Text"
It specifies text to be displayed if the browser does not support the IMG tag or if the
user has suspended image loading in the browser.
ALIGN
It specifies the alignment of the image in relation to the surrounding text. If you do
not specify a value for ALIGN, browser uses BOTTOM as the default LEFT aligns
an image with the left margin.
RIGHT aligns an image with the right margin.
TOP aligns the top of an image with the top of the tallest item in the current line.
TEXTTOP aligns the top of an image with the top of the tallest text in the current
line.
MIDDLE aligns the middle of the image with the baseline of the text in the
current line.
BASELINE aligns the bottom of an image with the baseline of the text in the
current line.
BOTTOM is the same as BASELINE.
BORDER="border Width"
It specifies the width, in pixels, of a border around the image. The value must be an
integer.
HEIGHT="height"
It specifies the height of the image, either in pixels or as a percentage of the height of
the window, frame, or positioned block of HTML that contains the image. To indicate
a number of pixels specify the value as an integer, for example, "100". To indicate a
percentage, specify the value as an integer followed by the percentage sign, for
example "20%”.
WIDTH="width"
It specifies the width of the image either in pixels or as a percentage of the window,
frame, or positioned block of HTML containing the image. To indicate a number of
pixels specify the value as an integer, for example, "100". To indicate a percentage,
specify the value as an integer followed by the percentage sign, for example, "20%".
HSPACE="horizMargin"
It specifies a margin in pixels between the left and right edges of the image and
surrounding text and images. Give the value as an integer
VSPACE="verticalMargin"
It specifies a margin in pixels between the top and bottom edges of the image and
surrounding text and images. Give the value as an integer.
SCOAS&C_CS_TG
Insert a Script into HTML Page
A script in HTML is defined with the <script> tag. Note that you will have to
use the type attribute to specify the scripting language
e.g.
<HTML>
<HEAD>
<TITLE>JAVA SCRIPT</TITLE>
</HEAD>
<BODY>
<SCRIPT TYPE="text/javascript">
document. write("Hello World!")
</SCRIPT>
</BODY>
</HTML>
Solved Examples
Q.1) Write HTML code to display a Message using different Font attributes.
Answer:
<HTML>
<HEAD>
<TITLE> HTML Document </TITLE>
</HEAD>
<BODY><FONT SIZE="7" face="Comic Sans MS">This is font size 7 with comic
sans ms font</FONT>
<p><FONT SIZE="5" COLOR="red">This is red colored text with font size
5</FONT></p>
</BODY>
</HTML>
Output is:
SCOAS&C_CS_TG
Q.2) Write HTML code to explain Different levels of headings with different
alignments.
Answer:
<HTML>
<HEAD>
<TITLE>Headings </TITLE>
</HEAD>
<BODY>
<H1 align="left">First level left aligned Heading</H1>
<H2 align="center">Second Level center aligned heading</H2>
<H3 align="center">Third level center aligned heading</H3>
<H4 align="right">Fourth level right aligned heading</H4>
<H5 align="right">Fifth level right aligned heading</H5>
<H6 align="left">Sixth level left aligned heading</H6>
</BODY>
</HTML>
Output is:
Q. 3) Write HTML code to explain different Lists in Html.
Answer:
<HTML>
<HEAD>
<TITLE> lists </TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<H3>Sample of Unordered lists</H3>
<UL type="disc">
<LI>HI
<LI>HELLO
</UL>
<H3>Sample of Ordered lists</H3>
<OL type="A" start=3>
<LI>WELCOME
<LI>NAMASKAR
</OL>
<H3>Sample of Definition lists</H3>
<DL>
<DT>HTML
<DD>HYPER TEXT MARKUP LANGUAGE
<DT>URL
<DD>UNIFORM RESOURCE LOCATOR
</DL></BODY>
</HTML>
Output is:
SCOAS&C_CS_TG
Q.4) Write HTML code for the following:
Answer:
YEAR
1998 1999 2000
UNITS 500 400 1000
SALES
INCOME 1000 800 2000
<HTML>
<BODY>
<TABLE BORDER>
<TR>
<TH ROWSPAN="2" COLSPAN="2">
<TH COLSPAN="3">YEAR
<TR>
<TH>1998
<TH>1999
<TH>2000
</TR>
<TR>
<TH ROWSPAN="2">SALES
<TH>UNITS
<TD>500
<TD>400
<TD>1000
</TR>
<TR>
<TH>INCOME
<TD>1000
<TD>800
<TD>2000
</TR>
</TABLE>
</BODY>
</HTML>
Q.5) Write the exact output of the following HTML code with font specifications
in brackets:
Answer:
<HTML>
<BODY>
<H1> LIST OF BOOKS </H1> <HR>
<UL TYPE = "CIRCLE">
<LI> How to solve it By computer
<LI> HTML in Easy Steps
<LI> C++ Programming
</UL>
<OL type = "A">
<LI> Microprocessor Programming
<LI> Networking Essentials
<LI> Microcontrollers
</OL>
</BODY>
</HTML>
6) Write a HTML code with VBscript for a web page which greets “Good Morning “
if time is 12.00A.M. to 12 P.M. else greets “Good Afternoon”.
<HTML>
<HEAD>
<TITLE>Greeting </TITLE>
</HEAD>
<BODY>
<SCRIPT LANGUAGE=”VBSCRIPT”
Function Greeting ()
If time()=#12:00:00 AM # and
time()<=12:00:00 PM # Then
greeting=”Good Morning”
else
greeting=”Good Morning”
End if
End function
Document .write Greeting ()
</SCRIPT>
<BR>
<H2> Welcome to world of HTML & WEB DESIGNING</H2>
SCOAS&C_CS_TG
</BODY>
<HTML>
Objective Questions
Select the correct alternative and rewrite the following. [1 Mark each]
i) The ------------- tag contains general information, or meta-information, about the
document.
a) <HEAD> b) <MARQUEE> c) <TITLE> d)<BODY>
ii) The block-level elements contain ------------- tag.
a) <PRE> b) <BODY> c) <MARQUEE> d) <HTML>
iii) ------------- Attribute is used for setting color for visited hyperlinks
a) VLINK b) LINK c)HLINK
iv) ------------- specifies the distance between the left and right edges of the table
and any surrounding content.
a) CELLSPACING b) CELLPADDING
c) HSPACE d)VSPACE
v) A ------------- tag, specifies the title for the table
a) CAPTION b)TITLE c)HEAD
vi) In ------------- type of list, list items are marked with bullets.
a) ORDERED b)DEFINITION c) NESTED d)UNORDERED
vii) ------------- attribute in the body tag specify an image file to use as a
background.
a) BGCOLOR b) BACKGROUND
c) BGIMAGAE d) BACKGROUNDIMG
viii) <a> tag has attribute ------------- which defines URL of the document to be
linked.
a) SRC b ) HREF c)VREF d)REF
ix) URL stands for -------------.
a) Uniform Resource Locator b) Unified Resource Location
c) Uniform Resource Link
x) HREF attribute in <A>tag stands for -------------.
a) Horizontal reference b)Hypertext reference
c) Hyperlink reference d)Hypermedia reference
xi) To place the image into an HTML file ------------- attribute is used in IMG
tag.
a) < URL > b) < ALT > c) < SRC > d) < HREF>
xii) ------------- tag is used to put a line break in HTML code.
a)<HR> b) <BR> c) <P> d)<TR>
Answers: i) <HEAD>, ii) <BODY>, iii) VLINK, iv) HSPACE, v) UNORDERED,
vi) BACKGROUND, vii) HREF, viii) Uniform Resource Locator, ix) Hypertext
Reference x) <BR>
Collge Name:S.P.College.
Admission data.
streams capacity
Commerce 150
Science 100
Arts 100
SCOAS&C_CS_TG
Q.4) Write HTML code for following.:---
Collge Name:Cummins College Of Engg.
CCOEW
Q.6) Write the HTML code for the following table: (Mar.2004)
Year
1999 2000 2001
Units 300 750 1,200
Sales
Income Rs. 3,000 Rs. 7,500 Rs. 12,000