Information Technology
Information Technology
HTML stands for Hyper Text Markup Language. It is a universal language which allows an
individual using special code to create web pages to be viewed on internet.
<HTML>
<HEAD>
<TITLE> This is the Title </TITLE>
</HEAD>
<BODY>
…. Type the body of the program
</BODY>
</HTML>
<form action="/action_page.php">
<label for="fname">First name:</label><br>
<input type="text" id="fname" name="fname" value="John"><br>
<label for="lname">Last name:</label><br>
<input type="text" id="lname" name="lname" value="Doe"><br><br>
<input type="submit" value="Submit">
</form>
<TABLE>
<TH> Heading </TH>
<TR> Row elements </TR>
<TD> Table data values </TD>
</TABLE>
Question 9. How do you change the color of background or text in
HTML?
Include the element \"bgcolor\" with a color code in your body tag:
<BODY BGCOLOR=\"#ffffff\" TEXT=\"#000000\"
LINK=\"#cc0000\"VLINK=\"#000066\" ALINK=\"#ffff00\">
<html>
<head>
<title> Horizontal Rule </title>
</head>
<body>
<p>
Hello world <hr/>
123 <hr/>
ABC <hr/>
</p>
</body>
</html>
Question 16. What are the style precedence rules when using multiple
approaches?
Inline styles override both linked style sheets and style information stored in the document
head with <STYLE> tag. Styles defined in the document head override linked style sheets.
Linked style sheets override browser defaults
<HTML>
<HEAD>
<STYLE Type = “text/css”>
predefined tag name {attribute name1:attribute value1; attribute name2:attribute
value2; ……attribute name-n:attribute value-n}
<STYLE>
</HEAD>
<BODY>
write the body of program
</BODY> </HTML>
<html>
<head>
<title>display image</title>
Module 1 : Introduction to HTML
</head>
<body>
<img src="abc.png" alt="cannot display"/>
</body>
</html>
<html>
<head>
<title> Blockquotes </title>
</head>
<body>
<p> HELLO THERE </p>
<blockquote>
<p> ROOTWORKZ </p>
</blockquote>
</body>
</html>
<html>
<head>
<title> ordered List </title>
</head>
<body>
<h3> Cessna 210 Engine Starting Instructions </h3>
<ol>
<li> Set mixture to rich </li>
<li> Set propeller to high RPM </li>
<li> Set ignition switch to "BOTH" </li>
<li> Set auxiliary fuel pump switch to "LOW PRIME" </li>
<li> When fuel pressure reaches 2 to 2.5 PSI, push starter button </li>
</ol>
</body>
</html>
Script:
<html>
<head>
<title> cell spacing and cell padding </title>
</head>
<body>
<h3>Table with space = 10, pad = 50</h3>
<table border = "7" cellspacing = "10" cellpadding = "50">
<tr>
<td> Kswamy</td>
<td>Chethan </td>
</tr>
</table>
<h3>Table with space = 50, pad = 10</h3>
<table border = "7" cellspacing = "50" cellpadding = "10">
<tr>
<td> Divya </td>
<td>Chethan </td>
</tr>
</table>
</body>
</html>
Question 26. Write a complete HTML form script using checkbox, actions
buttons(SUBMIT, RESET), <textarea> tag and radio button.
<html>
<head>
<title> CompleteForm</title>
</head> <body>
<h1>Registration Form</h1>
<form action=" ">
<p> <label>Enter your email id:
<input type = "text" name = "myname" size = "24" maxlength = "25" />
</label> </p>
<p> <label>Enter the password:
<input type = "password" name = "mypass" size = "20" maxlength = "20" />
</label> </p>
<p>
<label><input type="radio" name="act" value="one"/>Male</label>
<label><input type="radio" name="act" value="two"/>Female</label>
</p>
<p>Which of the following Accounts do you have?</p>
<p>
<label><input type="checkbox" name="act" value="one"/>Gmail</label>
<label><input type="checkbox" name="act" value="two"/>Facebook</label>
<label><input type="checkbox" name="act" value="three"/>Twitter</label>
<label><input type="checkbox" name="act" value="four"/>Google+</label>
</p>
<p> Any Suggestions?</p>
<p> <textarea name="feedback" rows="5" cols="100"> </textarea> </p>
<p>Click on Submit if you want to register</p>
<p> <input type="SUBMIT" value="SUBMIT"/>
<input type="RESET" value="RESET"/>
</p>
</form>
</body>
<html>
Question 27. Explain frames and <frame> tag.
FRAMES
The browser window can be used to display more than one document at a time. The window
can be divided into rectangular areas, each of which is a frame. Each frame is capable of
displaying its own document.
<frameset> tag:
>The number of frames and their layout in the browser window are specified with the
<frameset> tag.
>A frameset element takes the place of the body element in a document. A document has
either a body or a frameset but cannot have both.
>The <frameset> tag must have either a rows or a cols attribute. (or both)
> To create horizontal frames, rows attribute is used.
>To create vertical frames, cols attribute is used.
Question 28. How will you put background image using CSS? write script.
The background-image property is used to place an image in the background of an element.
<html>
<head>
<title>Background Image</title>
<style type = "text/css">
body {background-image:url(bk.jpg);}
p {text-align: justify; color:white;font-size:25pt;}
</style>
</head>
<body>
<p class = "two">HEllO WORLD</p>
</body>
</html>
Question 32. Write a JavaScript function that prompts the user to input a
number, and then gives them 5 chances to guess the square of the number.
<script language="JavaScript">
var theNumber = prompt("pick a number","");
var num = parseInt(theNumber);
var theSquare;
var theirNumber;
var guess;
theSquare= num * num;
for (var i=1; i <= 5; i++)
{
theirNumber= prompt("what is " + num + " squared","0");
guess= parseInt(theirNumber);
if (guess == theSquare)
{
alert("Correct");
break;
} else
{
alert("Attempt " + i + " is wrong");
}
}
</script>
Question 33. Write a JavaScript function that takes 3 parameters, price, tax
rate, balance, and prints yes in an alert box if someone has adequate balance
to purchase an item at the specified price with the given tax rate. Otherwise,
print out no in an alert box.
<script language="JavaScript">
function affortIt(price, taxrate, balance)
{
var total = price + price *taxrate;
if (total <= balance)
{
alert("yes");
} else
{
alert("no");
}
}
</script>
Strict equality === checks that two values are the same or not.
Value are not implicitly converted to some other value before comparison.
If the variable values are of different types, then the values are considered as unequal.
If the variable are of the same type, are not numeric, and have the same value, they are
considered as equal.
Question 35. Write a function that generates a complete web page containing
a list with 50 items.The items should be item1 through item50
<script>
function genList()
{
document.open();
document.write("<html><head></head><body>");
document.write("<ul>");
for (var i=1; i <= 50; i++)
{
document.write("<li> item" + i + "</li>");
}
document.write("</ul></body></html>");
document.close();
}
</script>
Question 38. Write a function that keeps prompting the user for input until
the letter "p" is typed by the user.
function Test()
{
var letterP = prompt("Please enter the letter p"," ");
while (letterP!=="p")
{
letterP = prompt("No dummy! Enter the letter p","");
}
alert("Thank you!")
}
Question 39. Write a JavaScript function that takes 4 variables, a, b, c, d,
and prints true in an alert box if input a > input b and input c > input d. Else,
print false in an alert box.
<script language="JavaScript">
function question9(a,b,c,d)
{
if (a>b&&c>d) {
alert("true")
}
else {
alert("false")
}
}
</script>
Question 40. Write a HTML script that contains JavaScript function that
prompts the user for a color and uses what they typed to set the background
color of the web page.
<html>
<head><title>Changing Background Color</title>
<script language="JavaScript">
function changeBgColor(){
var bodycolor = document.form1.body.value;
document.getElementById("bdy").style.backgroundColor = bodycolor;
}
</script>
</head>
<body ID="bdy">
<p>
Pick a background color for this page.
</p>
<form name="form1">
<b> Color </b>
<input type="text" name="body"><br>
<input type="button" value="Change color" onclick="changeBgColor()">
<br>
</form>
</body>
</html>