Internal answer key
Internal answer key
Part-A
Inside the <form> element, create input fields for username and password: Use the <input> tag
with the type attribute set to “text” for username. Use the <input> tag with the type attribute set
to “password” for password. Add clear labels for each input field using the <label> tag.
Their syntaxes are still very similar and there are only a few differences between them. Both
languages come in three flavours: frameset, transitional and strict.
Separation of Content and Style. One of the most significant advantages of CSS is its ability to
separate content from presentation. ...
Consistency. ...
Faster Loading Times. ...
Responsive Design. ...
Ease of Maintenance. ...
Accessibility. ...
Print-Friendly Pages. ...
Global Styling
Client-side scripts are commonly used when we want to validate data before sending it to the
web server, adjusting the interface in response to user feedback, and for implementing other
advanced features.
The if/else statement executes a block of code if a specified condition is true. If the condition is
false, another block of code can be executed.
The if/else statement is a part of JavaScript's "Conditional" Statements, which are used to
perform different actions based on different conditions.
Part-B
6a )Define List and its types.Also write the necessary html program and Output
Over 95% of websites are coded in HTML. Lists in HTML display related information in an
organized and concise manner, making the website visually appealing and easily navigable for
the users. Therefore, understanding how to create lists with HTML is essential for a successful
web page design. In this blog, we will explore what is a list in HTML and the types of lists
available.
From a technical standpoint, having your data arranged into lists makes documents structured,
more accessible, and generally easier to update when needed. You can learn more about
HTML/CSS by taking an online web development course.
Types of Lists in HTML
The following are the types of lists in HTML.
Syntax:
<ol>
<li> ... </li>
<li> ... </li>
<li> ... </li>
</ol>
Example:
<!DOCTYPE html>
<html>
<body>
<h2>An ordered HTML list (Stationary Items)</h2>
<ol>
<li>Pen</li>
<li>Pencil</li>
<li>Paper</li>
</ol>
</body>
</html>
Unordered lists are used to indicate a list of items that don’t have any particular order or
hierarchy.
Syntax:
<ul>
<li>...</li>
<li>...</li >
<li>...</li >
</ul>
Example:
<!DOCTYPE html>
<html>
<body>
<ul>
<li>Washing Machine</li>
<li>Oven</li>
<li>Gyser</li>
</ul>
</body>
</html>
The HTML <form> element can contain one or more of the following form elements:
<input>
<label>
<select>
<textarea>
<button>
<fieldset>
<legend>
<datalist>
<output>
<option>
<optgroup>
The <input> element can be displayed in several ways, depending on the type attribute.
Example
<label for="fname">First name:</label>
<input type="text" id="fname" name="fname">
Try it Yourself »
All the different values of the type attribute are covered in the next chapter: HTML Input Types.
The <label> element is useful for screen-reader users, because the screen-reader will read out
loud the label when the user focus on the input element.
The <label> element also help users who have difficulty clicking on very small regions (such as
radio buttons or checkboxes) - because when the user clicks the text within the <label> element,
it toggles the radio button/checkbox.
The for attribute of the <label> tag should be equal to the id attribute of the <input> element to
bind them together.
Example
<label for="cars">Choose a car:</label>
<select id="cars" name="cars">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="fiat">Fiat</option>
<option value="audi">Audi</option>
</select>
Try it Yourself »
Example
<option value="fiat" selected>Fiat</option>
Try it Yourself »
Visible Values:
Example
<label for="cars">Choose a car:</label>
<select id="cars" name="cars" size="3">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="fiat">Fiat</option>
<option value="audi">Audi</option>
</select>
Try it Yourself »
Allow Multiple Selections:
Use the multiple attribute to allow the user to select more than one value:
Example
<label for="cars">Choose a car:</label>
<select id="cars" name="cars" size="4" multiple>
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="fiat">Fiat</option>
<option value="audi">Audi</option>
</select>
Try it Yourself »
Example
<textarea name="message" rows="10" cols="30">
The cat was playing in the garden.
</textarea>
Try it Yourself »
The rows attribute specifies the visible number of lines in a text area.
7a) Define Selectors and its types. Also write the necessary html program and Output
SS selectors are used to "find" (or select) the HTML elements you want to style.
The element selector selects HTML elements based on the element name.
Example
Here, all <p> elements on the page will be center-aligned, with a red text color:
p{
text-align: center;
color: red;
}
Try it Yourself »
The id selector uses the id attribute of an HTML element to select a specific element.
The id of an element is unique within a page, so the id selector is used to select one unique
element!
To select an element with a specific id, write a hash (#) character, followed by the id of the
element.
Example
The CSS rule below will be applied to the HTML element with id="para1":
#para1 {
text-align: center;
color: red;
}
The CSS class Selector
The class selector selects HTML elements with a specific class attribute.
To select elements with a specific class, write a period (.) character, followed by the class name.
Example
In this example all HTML elements with class="center" will be red and center-aligned:
.center {
text-align: center;
color: red;
}
The CSS Universal Selector
The universal selector (*) selects all HTML elements on the page.
Example
The CSS rule below will affect every HTML element on the page:
*{
text-align: center;
color: blue;
}
The CSS Grouping Selector
The grouping selector selects all the HTML elements with the same style definitions.
Look at the following CSS code (the h1, h2, and p elements have the same style definitions):
h1 {
text-align: center;
color: red;
}
h2 {
text-align: center;
color: red;
}
p{
text-align: center;
color: red;
}
SS Text Formatting refers to applying styles to text elements to control appearance and
layout. This includes properties for color, alignment, decoration, indentation, justification,
shadows, spacing, and direction. These properties enhance readability and aesthetics,
improving the presentation of textual content on web pages.
Syntax:
The Syntax to write this property:
Selector {
property-name : /*value*/
}
CSS Text Formatting Properties:
Example: In this example we demonstrates basic text formatting using CSS. It includes
paragraphs with different styles: changing color, aligning center, adding underline, setting
indentation, and adjusting letter spacing for improved readability and aesthetics.
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width,
initial-scale=1.0">
<title>Basic Text Formatting</title>
<style>
.text-color {
color: blue;
}
.text-align-center {
text-align: center;
}
.text-decoration {
text-decoration: underline;
}
.text-indent {
text-indent: 20px;
}
.letter-spacing {
letter-spacing: 2px;
}
</style>
</head>
<body>
<p class="text-color">Changing Text Color</p>
<p class="text-align-center">Aligning Text</p>
<p class="text-decoration">Adding Text Decoration</p>
<p class="text-indent">Setting Text Indentation</p>
<p class="letter-spacing">Adjusting Letter Spacing</p>
</body>
</html>
Part-c
8 a)What is meant by function in Javascript?
A JavaScript function is a block of code designed to perform a particular task.
A JavaScript function is defined with the function keyword, followed by a name, followed by
parentheses ().
Function names can contain letters, digits, underscores, and dollar signs (same rules as
variables).
Function parameters are listed inside the parentheses () in the function definition.
Function arguments are the values received by the function when it is invoked.
Inside the function, the arguments (the parameters) behave as local variables.
Function Invocation
The code inside the function will execute when "something" invokes (calls) the function:
You will learn a lot more about function invocation later in this tutorial.
Function Return
When JavaScript reaches a return statement, the function will stop executing.
If the function was invoked from a statement, JavaScript will "return" to execute the code after
the invoking statement.
Functions often compute a return value. The return value is "returned" back to the "caller":
Example
function myFunction(a, b) {
// Function returns the product of a and b
return a * b;
}
8b) Develop a simple online shopping application using javascript.(Assume your own data)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="css/style.css">
<script type="module"
src="https://unpkg.com/[email protected]/dist/ionicons/ionicons.esm.js"></script>
</head>
<body>
<header>
<div class="nav">
<div class="box">
<div class="cart-count">0</div>
<ion-icon name="cart" id="cart-icon" ></ion-icon>
</div>
<div class="cart">
<div class="cart-title">Cart Items</div>
<div class="cart-content">
<!--
<div class="cart-box">
<img src="images/97.jpg" class="cart-img">
<div class="detail-box">
<div class="cart-food-title">Special Dosai</div>
<div class="price-box">
<div class="cart-price">Rs.72</div>
<div class="cart-amt">Rs.72</div>
</div>
<input type="number" value="1" class="cart-quantity">
</div>
<ion-icon name="trash" class="cart-remove"></ion-icon>
</div>
<div class="cart-box">
<img src="images/97.jpg" class="cart-img">
<div class="detail-box">
<div class="cart-food-title">Special Dosai</div>
<div class="price-box">
<div class="cart-price">Rs.72</div>
<div class="cart-amt">Rs.72</div>
</div>
<input type="number" value="1" class="cart-quantity">
</div>
<ion-icon name="trash" class="cart-remove"></ion-icon>
</div>
-->
</div>
<div class="total">
<div class="total-title">Total</div>
<div class="total-price">Rs.0</div>
</div>
</div>
</div>
</header>
<div class="container">
<h2 class="title">Discover the Best Food</h2>
<div class="shop-content">
<div class="food-box">
<div class="pic">
<img src="images/97.jpg" class="food-img">
</div>
<h2 class="food-title">Plain</h2>
<span class="food-price">Rs.40</span>
<ion-icon name="cart" class="add-cart"></ion-icon>
</div>
<div class="food-box">
<div class="pic"><img src="images/98.jpg" class="food-img"></div>
<h2 class="food-title">Paper Roast</h2>
<span class="food-price">Rs.65</span>
<ion-icon name="cart" class="add-cart"></ion-icon>
</div>
<div class="food-box">
<div class="pic"><img src="images/99.jpg" class="food-img"></div>
<h2 class="food-title">Onion Roast</h2>
<span class="food-price">Rs.80</span>
<ion-icon name="cart" class="add-cart"></ion-icon>
</div>
<div class="food-box">
<div class="pic"><img src="images/100.jpg" class="food-img"></div>
<h2 class="food-title">Egg Parotta</h2>
<span class="food-price">Rs.55</span>
<ion-icon name="cart" class="add-cart"></ion-icon>
</div>
<div class="food-box">
<div class="pic"><img src="images/101.jpg" class="food-img"></div>
<h2 class="food-title">Plain Omelette</h2>
<span class="food-price">Rs.25</span>
<ion-icon name="cart" class="add-cart"></ion-icon>
</div>
<div class="food-box">
<div class="pic"><img src="images/102.jpg" class="food-img"></div>
<h2 class="food-title">Kadai Fry</h2>
<span class="food-price">Rs.150</span>
<ion-icon name="cart" class="add-cart"></ion-icon>
</div>
<div class="food-box">
<div class="pic"><img src="images/103.jpg" class="food-img"></div>
<h2 class="food-title">Egg Veechu</h2>
<span class="food-price">Rs.65</span>
<ion-icon name="cart" class="add-cart"></ion-icon>
</div>
<div class="food-box">
<div class="pic"><img src="images/104.jpg" class="food-img"></div>
<h2 class="food-title">Egg Roast</h2>
<span class="food-price">Rs.65</span>
<ion-icon name="cart" class="add-cart"></ion-icon>
</div>
</div>
</div>
<script src="js/script.js"></script>
</body>
</html>
css/style.css
@import url('https://fonts.googleapis.com/css2?
family=Poppins:wght@200;300;400;500;600;700;800;900&display=swap');
*{
font-family: 'Poppins', sans-serif;
margin: 0;
padding: 0;
box-sizing: border-box;
}
body{
background-color:#4b4b4b;
}
header{
position: fixed;
top: 0;
left: 0;
width: 100%;
z-index: 99;
background-color: #ff4757;
}
.nav{
max-width: 1200px;
margin: auto;
width: 100%;
height: 50px;
display: flex;
justify-content: space-between;
align-items: center;
}
.logo{
font-size: 1.1rem;
font-weight: 500;
text-decoration: none;
text-transform: uppercase;
color:#ffffff;
}
.box{
color:white;
width: 30px;
height: 30px;
text-align: center;
position: relative;
}
.cart-count{
position: absolute;
background-color: #2f3542;
top: -5px;
right: 0;
padding: 3px;
height: 20px;
width: 20px;
line-height:20px ;
border-radius: 50%;
z-index: 99;
}
#cart-icon{
font-size: 1.5rem;
cursor: pointer;
padding-top: 10px;
}
img{
width: 100%;
}
.container{
max-width: 1200px;
padding: 4rem;
margin: auto;
width: 100%;
}
h2.title{
font-size: 1.1rem;
font-weight: 500;
margin-bottom: 1.5rem;
color:#ffffff;
}
.shop-content{
display: grid;
grid-template-columns: repeat(auto-fit,minmax(220px,auto));
gap:1.5rem;
justify-content: center;
align-content: center;
}
.food-box{
position: relative;
background-color: #fff;
padding: 10px;
box-shadow: 0 1px 4px rgba(40, 37, 37, 0.1);
border-radius: 3px;
}
.pic{
overflow: hidden;
}
{
transform: scale(1.5);
}
.food-img{
transition: 0.4s;
aspect-ratio: 1/1;
object-fit: cover;
}
.food-title{
font-size: 1rem;
font-weight: 600;
color:#ff6348;
}
.food-price{
font-weight:500 ;
}
padding: 10px;
font-size: 1.1rem;
cursor: pointer;
transition: 0.5s;
.cart{
position: fixed;
top: 0;
right: -100%;
width: 400px;
height: 100vh;
overflow-y: auto;
overflow-x: hidden;
padding: 20px;
background-color: white;
box-shadow: 0 1px 4px rgba(40, 37, 37, 0.1);
z-index: 100;
}
.cart-active{
right:0;
transition: 0.5s;
}
.cart-title{
text-align: center;
font-size: 1.5rem;
font-weight: 500;
margin-bottom: 1rem;
padding-bottom:20px ;
border-bottom: 1px solid rgba(0,0,0,0.1);
}
.cart-box{
display: grid;
grid-template-columns: 32% 50% 18%;
align-items: center;
gap: 1rem;
margin-top: 1rem;
border-bottom: 1px solid rgba(0,0,0,0.1);
padding-bottom: 10px;
}
.cart-img{
width: 75px;
height: 75px;
object-fit: cover;
border:2px solid rgba(0,0,0,0.1);
padding: 5px;
}
.detail-box{
display: grid;
row-gap: 0.5rem;
}
.price-box{
display: flex;
justify-content: space-between;
}
.cart-food-title{
font-size: 1rem;
text-transform: uppercase;
color:#ff6348;
font-weight: 500;
}
.cart-price{
font-weight: 500;
}
.
}
.total-title{
font-size: 1rem;
font-weight: 600;
}
.total-price{
margin-left: 0.5rem;
}
.btn-buy{
padding: 12px 20px;
background-color:#2f3542;
color:#fff;
border: none;
font-size: 1rem;
font-weight: 500;
cursor: pointer;
}
#cart-close{
position: absolute;
top: 1rem;
right: 0.8rem;
font-size: 2rem;
cursor: pointer;
}