Web Technologies Material For Degree Students
Web Technologies Material For Degree Students
Eg:
<!DOCTYPE html>
<html>
<head>
<title>Demo</title>
</head>
<body>
</body>
</html>
Table Tag
==============
The Table tag is the container tag which is used to create the table on the web page.
The Table contains the different following sub tags are as follows:
1. <TH> Tag
2. <TR> Tag
3. <TD> Tag
1. <Th> Tag
===============
It is the container tag which is used to display the table heading in the table on the web page.
Syntax:
<table>
</table>
2. <Tr> Tag
===============
It is the container tag which is used to display or create the table row on the web page for the
existed or particular table.
Syntax:
<table>
</table>
3. <TD> Tag
===============
It is the container tag which is used to write the contents for the given table.
Syntax:
<Table>
</table>
The Table Tag and its the following tags contains the different attributes are as follows:
1. Align
2. border
3. BgColor
4. Cell Spacing
5. Cell Padding
6. Border Color
7. Rowspan
8. colspan
1. Align
==========
This attribute is used to set the table or data of the table in particular alignments like:
Left/Center/Right
2. Border
============
3. BGcolor
==============
This attribute is used to set the background color for the given table
4. Cellspacing
=================
This attribute is used to set the cell spacing in between the cells.
5. Cellpadding
==================
This attribute is used to set the length in between the cell and the cell data.
6. BorderColor
=================
7. Colspan
==============
This attribute is used to divide the table's column in the particular no. of columns.
8. Rowspan
===============
This attribute is used to divide the table's Row in the particular no. of Rows.
Syntax:
<th>............. </th>
<tr>.............. </tr>
<td>..............</td>
</Table>
Eg:
<html>
<head>
<body>
<tr bgcolor="Orange">
<th> Name</th>
<th> Course</th>
</tr>
<tr bgcolor="pink">
</tr>
<tr bgcolor="pink">
</tr>
<tr bgcolor="pink">
</tr>
</TABLE>
</BODY>
</HEAD>
</HTML>
Ans:
DOM
The DOM is a W3C (World Wide Web Consortium) standard.
The W3C DOM is used to allows programs and scripts to access the data and
update the data dynamically to the content, structure and style of the document
HTML DOM
The HTML DOM is a standard object model and programming interface for
HTML. It defines:
Through the help of Document Object Model, Javascript allows to create the dynamic HTML such as
follows:
HTML DOM properties are values (of HTML Elements) that you can set or
change.
The DOM Programming Interface
The HTML DOM can be accessed with JavaScript (and with other programming
languages).
Eg:1
<!DOCTYPE html>
<html>
<body>
<p id="demo"></p>
<script>
</script>
</body>
</html>
Note:
If you want to access any element in an HTML page, you always start with
accessing the document object.
Method Description
Eg:
<!DOCTYPE html>
<html>
<body>
<p>Hello World!</p>
<p id="demo"></p>
<script>
var x = document.getElementsByTagName("p");
document.getElementById("demo").innerHTML =
</script>
</body>
</html>
Cascading style sheet is a simple mechanism for adding style (eg: fonts, style, colors, spacing) to
web documents
CSS allows documents authors to specify the presentation of elements on a web page (spacing,
margins, etc) separately from the structure of the document (section headless, body text, links,
etc.
This separation of structure from presentation simplifies maintaining and modifying a
document’s layout.
-----------------------------------------------------
This type of Style sheet is used to apply for the particular tag only.
or
That means where we want to change the document style at that place only can be done by using the
<style> tag.
c) The internal style sheet is used by using the <style> tag only
Syntax:
<head>
Hr {color: orange}
P {margin-left: 20px}
</style>
</head>
3. External style sheet:
The external style sheet is used to change the look of entire website by changing one file.
Syntax:
<head>
<Head>
The external style sheet can be written in any of the text editor.
The external style sheet does not contain any of the of the html tags.
P {margin-left: 20px}
Properties in Css :
1. Font:
The font has different types of properties such as follows:
Eg: <html>
<Head>
<style type=”text/css”>
H1 {color: #ooffo1}
h1 {text-align: center}
A {text-decoration: none}
</style>
</head>
</body>
</body>
</html>
2. Text Properties:
The text has different types of properties such as follows:
Color: Red/Blue/Green
Direction: LTR/RTL
Line-Height: Normal/Number/Length/%
Letter-spacing: Normal/Length
Text-Indent: Length/%
Vertical-Align: Baseline/Sub/Super/Top/Middle/Bottom
Eg: <html>
<Head>
h2 {font-size: 30px}
</style>
</head>
<body>
The box model is used to specify a box that wraps around html elements, are as follows:
The margins don’t have the background color and it is completely transparent
2.Borders: A border that lies around the padding on the text and content the border is affected by the
background color of the box
4.Actual contents: The content of the box where the text and images appear.
<Head>
<style type=”text/css”>
div.ex
Width: 220px;
Padding: 10px;
Margin; 0px;
<Style>
<Body>
</body>
</html>
4.Background properties:
CSS background properties are used to define the background effects of an element, as follows;
1. Background-Color:
4. Background-repeat
The background-repeat property sets if/how a background image will be
repeated.
5. Background-attachment
The background-attachment property sets whether a background image
scrolls with the rest of the page, or is fixed.
6. Background-position
An array is a special variable, which can hold more than one value at a time.
If you have a list of items (a list of car names, for example), storing the cars in
single variables such as follows:
var car1 = "Saab";
var car2 = "Volvo";
var car3 = "BMW";
An array can hold many values under a single name, and you can access the
values by referring to an index number.
Creating an Array
By Using an array literal is the easiest way to create a JavaScript Array.
Syntax:
Example
var cars = [
"Saab",
"Volvo",
"BMW"
];
Eg:1
var name = cars[0];
Eg: 2
var cars = ["Saab", "Volvo", "BMW"];
document.getElementById("demo").innerHTML = cars[0];
Eg:
Associative Arrays
Many programming languages support arrays with named indexes.
Arrays with named indexes are called associative arrays (or hashes).
Eg:
var person = [];
person[0] = "John";
person[1] = "Doe";
person[2] = 46;
var x = person.length; // person.length will return 3
var y = person[0]; // person[0] will return "John"
1) HTML is used to display data and XML is a software and hardware independent tool
focuses on how data looks. used to transport and store data. It focuses on
what data is.
5) HTML has its own predefined tags. You can define tags according to your need.
Ans:
An XML tree begins from root element and branches from the root to child
elements.
Syntax:
<root>
<child>
<subchild>.....</subchild>
</child>
</root>
The terms parent, child, and sibling are used to describe the relationships
between elements.
Eg:
<?xml version="1.0" encoding="UTF-8"?>
<note>
<to>Sadaq</to>
<from>Abdul</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
<?xml version="1.0" encoding="UTF-8"?>
The XML prolog is optional. If it exists, it must come first in the document.
XML documents can contain international charactersTo avoid errors, you should
specify the encoding used, or save your XML files as UTF-8.
UTF-8 is also the default encoding for HTML5, CSS, JavaScript, PHP, and SQL.
XML tags are case sensitive that means upper letters are differ from lower
letters
Data Validation
Data validation is the process of ensuring(guarantee) that user input is clean,
correct, and useful.
Most often, the purpose of data validation is to ensure correct user input.
Validation can be defined by many different methods, and deployed in many
different ways.
Server side validation is performed by a web server, after input has been
sent to the server.
Attribute Description
Selector Description
<!DOCTYPE html>
<html>
<head>
<script>
function validateForm() {
var x = document.forms["myForm"]["fname"].value;
if (x == "") {
return false;
</script>
</head>
<body>
</form>
</body>
</html>
9) What is a Function? Discuss about functions in Javascript.
Ans:
There are different types of components in Java Script Functions such as follows:
Function Declaration
JavaScript functions are defined with the function keyword.
A JavaScript function can also be defined using an expression.
Syntax:
function functionName(parameters) {
your code goes here ………….
}
eg:
<script>
document.getElementById("demo").innerHTML = x;
function myFunction(a, b) {
return a * b;
</script>
Note:
Functions can also be defined with a built-in JavaScript function constructor
called Function().
Eg:
<script>
</script>
Function Parameters
Function parameters are the names listed in the function definition.
Rules
JavaScript function definitions do not specify data types for parameters.
JavaScript functions do not perform type checking on the passed
arguments.
JavaScript functions do not check the number of arguments received.
Eg:
function myFunction(x, y) {
if (y === undefined) {
y = 0;
}
}
Function Invocation
The code inside a function is not executed when the function is defined.
Eg:
function myFunction(a, b) {
return a * b;
}
myFunction(10, 2); Function Invocation or Calling Function
Function Call
An object can be used a method which is in another object by using call()
Eg:
var person = {
fullName: function() {
return this.firstName + " " + this.lastName;
}
}
var person1 = {
firstName:"Abdul",
lastName: "Sadaq",
}
var person2 = {
firstName:"Shaik",
lastName: "Sultan",
}
person.fullName.call(person1);
Function Apply
It is just similar to call(), which can be taken arguments separetly but the
apply() can taken arguments as an array
If you want to use an array instead of an argument list then we have to use
apply()
Function Closures
The variables of JavaScript can be either the local or global.
Eg:
<!DOCTYPE html>
<html>
<body>
<p id="demo"></p>
<script>
var a = 4;
function myFunction() {
document.getElementById("demo").innerHTML = a * a;
</script>
</body>
</html>
10) What is an event? Explain various events supported by Java
Script
Or
onmouseover script Triggers when the mouse pointer moves over an element
Eg:
<html>
<head>
<script type="text/javascript">
<!--
function validation() {
.........
//-->
</script>
</head>
<body>
.......
</form>
</body>
</html>
Or
Ans:
JavaScript Popup Boxes
There are 3 different types of Pop up boxes in javascript
such as follows:
Alert box
Confirm box
Prompt box
Alert Box
It is used to display the altert message in the box model
When an alert box pops up, the user will have to click "OK" to proceed.
Syntax
window.alert("sometext");
Note:
Eg:
alert("I am Sadaq!");
Confirm Box
A confirm box is used when, if you want the user to verify or accept something.
When a confirm box pops up, the user will have to click either "OK" or "Cancel"
to proceed.
If the user clicks "OK", the box returns true. If the user clicks "Cancel", the box
returns false.
Syntax
window.confirm("sometext");
Note:
Example
if (confirm("Press a button!")) {
txt = "You pressed OK!";
} else {
txt = "You pressed Cancel!";
}
Prompt Box
A prompt box is used, when if you want the user to input a value before
entering a page.
When a prompt box pops up, the user will have to click either "OK" or
"Cancel" to proceed after entering an input value.
If the user clicks "OK" the box returns the input value.
Syntax
window.prompt("sometext","defaultText");
Note:
Eg:
Syntax:
try {
Block of code to try
}
catch(err) {
Block of code to handle errors
}
The throw Statement
The throw statement allows you to create a custom error.
Eg:
Syntax:
try {
Block of code to try
}
catch(err) {
Block of code to handle errors
}
finally {
Block of code to be executed regardless of the try / catch result
}
eg:
<!DOCTYPE html>
<html>
<body>
<p id="p01"></p>
<script>
function myFunction() {
var message, x;
message = document.getElementById("p01");
message.innerHTML = "";
x = document.getElementById("demo").value;
try {
x = Number(x);
catch(err) {
finally {
document.getElementById("demo").value = "";
</script>
</body>
</html>
Ans:
We can animate the image through java script as per the users’ requirement
Eg:
<!DOCTYPE html>
<html>
<style>
#myContainer {
width: 400px;
height: 400px;
position: relative;
background: yellow;
#myAnimation {
width: 50px;
height: 50px;
position: absolute;
background-color: red;
</style>
<body>
<p>
</p>
<div id ="myContainer">
<div id ="myAnimation"></div>
</div>
<script>
function myMove() {
var pos = 0;
function frame() {
if (pos == 350) {
clearInterval(id);
} else {
pos++;
}
</script>
</body>
</html>
Note: