Professional Documents
Culture Documents
End Sem
End Sem
1. Use character entities to display the temperature symbol (the small raised circle)
and a nonbreaking space.
2. Insert a horizontal rule with a thickness of 3 pixels.
3. Include an image of a car with the file name "car.jpg." Set the alt attribute to "Pic
of a Car" and scale the image to occupy 50% of the display width.
4. Create a hypertext link with the text "Visit our homepage" that points to a
document named "index.html" in the same directory.
5. Add another hypertext link with the text "Contact us" that opens an email to
"info@example.com" when clicked.
6. Finally, create a link that opens a new window and points to a page named
"Image.html" with the text "Open Page in a new window."
ANS:
<html>
<title>sample page</title>
<body>
<hr/>
temperature symbol: ° <br>
nonbreaking space:
<hr/>
<img src='car.jpeg', alt='Pic of a Car', width=50%/>
<a href='index.html'>Visit our homepage</a>
<br>
<a href='info@example.com'>Contact us</a>
<br>
<a href='Image.html'>Open Page in a new window</a>
</body>
</html>
Question:
Create an HTML document that includes the following lists:
1. Create an unordered list (<ul>) with at least three list items (<li>). Use different
bullet types for each item: one with the default disc, one with a circle, and one
with a square.
2. Next, create an ordered list (<ol>) with at least three list items (<li>). Use different
numbering styles for each item: one with Arabic numerals (default), one with
uppercase letters, and one with lowercase Roman numerals.
3. Finally, create a definition list (<dl>) with at least three term-definition pairs. Use
the <dt> tag for terms and the <dd> tag for definitions. Include various HTML
elements like images or links within the list items.
ANS:
<html>
<title>sample page</title>
<body>
<ul>
<li type='disc'> hello</li>
<li type='circle'> hello</li>
<li type='square'> hello</li>
</ul>
<ol>
<li type='1'> hello</li>
<li type='A'> hello</li>
<li type='I'> hello</li>
</ol>
<dl>
<dt>hello</dt>
<dd>hi</dd>
</dl>
</body>
</html>
Question:
border='1', cellpadding='10', cellspacing='5'
ANS:
<html>
<title>sample page</title>
<body>
<table border='1', cellpadding='10', cellspacing='5'>
<thead>STUDENT DATA</thead>
<tr>
<th colspan=4>B TECH CSE</th>
</tr>
<tr>
<th rowspan=4>DETAILS</th>
<th>Roll NO</th>
<th>Name</th>
<th>DOB</th>
</tr>
<tr>
<td align='center'>1</td>
<td>AAA</td>
<td>01-01-1992</td>
</tr>
<tr>
<td align='center'>2</td>
<td>BBB</td>
<td>02-02-1992</td>
</tr>
<tr>
<td align='center'>3</td>
<td>CCC</td>
<td>03-03-1992</td>
</tr>
</table>
</body>
</html>
Question:
ANS:
<html>
<title>sample page</title>
<body>
<form>
Name:
<input type='text'/> <br><br>
Age:
<input type='text'/> <br><br>
Password:
<input type='password'/> <br><br>
Interests:
Movies<input type='checkbox', name = 'Interests', value =
'Movies', checked='checked'/>
Travel<input type='checkbox', name = 'Interests', value =
'Travel'/>
Music<input type='checkbox', name = 'Interests', value =
'Music'/> <br><br>
Gender:
Male<input type='radio', name = 'gender', value = 'male',
checked='checked'/>
Female<input type='radio', name = 'gender', value ='female'/>
<br><br>
<select>
<option value='in'>India</option>
<option value='ne'>Nepal</option>
<option value='sri'>Srilanka</option>
</select> <br><br>
Address:<br>
<textarea rows=5, cols=50></textarea> <br><br>
Question:
Create an HTML document that uses both inline styles, document-level styles, and an
external style sheet to style various elements. Apply different styles for the following:
1. Use inline styles to make a paragraph (<p>) have red text and a font size of 18px.
2. Use document-level styles to set the background color of all <h2> headings to
yellow and increase their font size to 30px.
3. Create an external style sheet named "styles.css" and link it to the HTML document
using the <link> tag. In this external style sheet, apply styles to make all paragraphs
(<p>) use a sans-serif font-family and have a red text color. Also, set the
background color of <h2> headings to yellow.
ANS:
<html>
<head>
<title>sample page</title>
<link type = 'text/css' href='style.css'/>
</head>
<body>
<p style = 'color:red; font-size=18px'>hi</p>
<h2>hello</h2>
<h1>hello</h1>
</body>
<style>
h2{background-color:yellow; font-size=30px}
</style>
</html>
Style.css
h1 {color:red; font-family: sans-serif; background-color:yellow;}
Question:
Create an HTML document with various elements and apply styles using different selector
forms in CSS. Demonstrate the use of the following selector forms:
2. Class Selectors:
Define two classes: .normal and .warning.
Apply the .normal class to a paragraph (<p>) and set specific styles.
Apply the .warning class to another paragraph and set different styles.
3. Generic Selectors:
Define a generic class named .sale that can be applied to both <h3> and <p>
elements.
Apply the .sale class to an <h3> and a <p> with specific styles.
4. id Selectors:
Define an id selector for an element with the id section14 and set a specific
style.
Apply this id selector to an <h2> element within the document.
5. Contextual Selectors:
Use a descendent selector to style ordered list items within unordered
elements.
Use a child selector to style list items (<li>) directly nested within an ordered
list (<ol>).
6. Pseudo Classes:
Apply styles using the :hover pseudo class for an interactive effect.
Apply styles using the :focus pseudo class for elements in focus.
7. Universal Selector:
Use the universal selector (*) to set a common style for all elements in the
document.
ANS:
<html>
<head>
<title>sample page</title>
</head>
<body>
<h1>H1</h1>
<h2 class=h23>h2</h2>
<h3 class=h23>h3</h3>
<p class=normal>nomral</p>
<p class=warning>warning</p>
<h3 class=sale>h3 sale</h3>
<p class=sale>p sale</h3>
<p id=section14>section14</p>
<h2 id=section14>h2 section14</h2>
<ul>
<li>One</li>
<ol>
<li>two</li>
<li>three</li>
</ol>
</ul>
</body>
<style>
h1{color:blue;}
.h23{color:green;}
.normal{color:blue;}
.warning{color:red;}
.sale{font-size:25px;}
#section14{color:white;background-color:blue;}
ul ol li {color:red;}
h1:hover{color:red}
h2:focus{color:red}
*{font-family:Arial}
</style>
</html>
The Box Model
Question:
Create an HTML document that includes a box with the following specifications:
1. Apply a border to the box with a style of "dotted," a width of "2px," and a color of
"green."
ANS:
<html>
<head>
<title>sample page</title>
</head>
<body>
<h1>INTRODUCTION TO HTML</h1>
</body>
<style>
h1{border-style:dotted; border-width:2px; border-color:green;
padding:15px; margin:10px; }
</style>
</html>
Question:
Create an HTML document that includes a body element with the following specifications:
1. Set a background image for the body using the background-image property. Use
the image "planes.jpg."
2. Ensure that the background image does not repeat using the background-repeat
property.
3. Position the background image at the bottom of the body using the background-
position property.
4. Additionally, set the background image to cover the entire screen using the
background-size property.
ANS:
<html>
<head>
<title>sample page</title>
</head>
<body>
<h1>INTRODUCTION TO HTML</h1>
</body>
<style>
body{background-image: url('car.jpeg');
background-repeat: no-repeat;
background-position: bottom;
background-size:100%}
</style>
</html>
Question
Java script vs Java (code: MUTE)
<!DOCTYPE html>
<html>
<head>
<title>sample page</title>
<script>
function al(){
alert('Hello world');
}
function conf(){
var a = confirm('Do you want to continue?');
if (a==1){
document.write('yes');
}
else{
document.write('no');
}
}
function prom(){
var name = prompt('Enter your name ');
document.write('welcome, ' + name);
}
</script>
</head>
<body>
<input type='submit' onclick='al()' value='alert'/>
<input type='submit' onclick='conf()' value='confirm'/>
<input type='submit' onclick='prom()' value='prompt'/>
</body>
</html>
Question:
Sum of two numbers using prompt
<!DOCTYPE html>
<html>
<head>
<title>sample page</title>
<script>
function sum(){
var a = prompt('Enter number 1');
var b = prompt('Enter number 2');
document.write(parseInt(a)+parseInt(b));
}
</script>
</head>
<body>
<input type='submit' onclick=sum() value='add'>
</body>
</html>
Question
Difference between pre increment and post increment
++a (pre-increment):
This form increments the value of a before the value is used in an expression.
The updated value is immediately used.
a = 5;
b = ++a; // Increment 'a' first, then assign to 'b'
// Now, a is 6, and b is 6
a++ (post-increment):
This form increments the value of a after the current value is used in an expression.
The original value is used before the increment takes place.
a = 5;
b = a++; // Assign the current value of 'a' to 'b', then increment
'a'
// Now, a is 6, but b is 5
TYPE CONVERSIONS
Creating objects:
Create my_car and add some properties.
delete my_car.model
FOR PHP
FOR JAVASCRIPT
MVC Architecture:
Model-View-Controller
Organizes code into three interconnected parts:
o Models:
Handle data interactions
Represent database tables
Define relationships between data
o Views:
Handle user interface and presentation
Contain HTML, CSS, and JavaScript
Render visual elements based on data from Models
o Controllers:
Act as "middlemen" between Models and Views
Handle incoming requests
Retrieve data from Models
Pass data to Views for rendering
Process user input