Web Development Basics: HTML & CSS
Web Development Basics: HTML & CSS
Front-end Development:
Back-end Development:
backend: functionality
Introduction to HTML:
HTML (Hypertext Markup Language) is the fundamental building block of the World Wide
Web. It is a standard markup language used to create and structure the content of web
pages. Developed by Tim Berners-Lee in 1991, HTML allows web developers to define the
elements and layout of a webpage, making it accessible and readable by web browsers.
Structure of HTML:
HTML is comprised of elements, represented by tags, which define the structure and content
of a web page. Each HTML document starts with a <!DOCTYPE> declaration that specifies
the version of HTML being used. The basic structure of an HTML document is as follows:
1|Page
<!DOCTYPE html>
<html>
<head>
</head>
<body>
</body>
</html>
The <!DOCTYPE html> declaration informs the browser that the document is written in
HTML5, the latest version of HTML.
The <html> element is the root element of the HTML document and contains all the
other elements.
The <head> element contains meta-information about the page, such as the title, links
to external stylesheets, or scripts.
The <body> element contains the visible content of the webpage, including headings,
paragraphs, images, links, and other elements.
HTML elements are represented by tags, which are enclosed in angle brackets < >. Tags
come in pairs, with an opening tag to define the beginning of an element and a closing
tag to define the end. The content to be displayed on the webpage is placed between
the opening and closing tags.
For example, a basic paragraph element is defined using the <p> tag:
<p>This is a paragraph.</p>
<p> tag
<pre> tag
2|Page
The <pre> tag defines preformatted text.
heading :
HTML headings are titles or subtitles that you want to display on a webpage.
list in HTML
HTML lists allow web developers to group a set of related items in lists.
Unordered HTML List:An unordered list starts with the <ul> tag. Each list
item starts with the <li> [Link] list items will be marked with bullets (small
black circles) by default.
Ordered HTML List:An ordered list starts with the <ol> tag. Each list item
starts with the <li> [Link] list items will be marked with numbers by
default.
<li>Coffee</li><li>Tea</li>
<li>Milk</li>
</ul>
<h2>An Ordered HTML List</h2>
<ol>
<li>Coffee</li><li>Tea</li>
<li>Milk</li>
</ol>
3|Page
<h2>A Description List</h2>
<dl>
<dt>Coffee</dt>
<dd>- black hot drink</dd>
<dt>Milk</dt>
<dd>- white cold drink</dd>
</dl>
HTML Attributes:
For example:
class,id,name etc..
Block-level Elements
A block-level element always takes up the full width available (stretches out
to the left and right as far as it can).
Inline Elements
4|Page
DAY-2
Basic introduction of css:
1 inline: within the opening tags of the element. If we use inline css
and also use external or internal than first priority is given to inline
css.
2 internal: style tag within the head tag. If we use internal and
external css than first priority is given to internal css.
<!DOCTYPE html>
<html>
<head>
<style>
h1 {
color: maroon;
margin-left: 40px;
}
</style>
</head>
<body>
<h1>This is a heading</h1>
</body>
</html>
5|Page
<!DOCTYPE html> [Link]
<html>
<head>
<link rel="stylesheet" href="my body {
[Link]"> background-color: lightblue;
</head> }
<body>
h1 {
<h1>This is a heading</h1> color: navy;
<p>This is a paragraph.</p> margin-left: 20px;
}
</body>
</html>
CSS Selectors:
1 Id:
2 Class:
3 Tag:
4 Universal:
The universal selector (*) selects all HTML elements on the page.
5 Group:
The grouping selector selects all the HTML elements with the same
style definitions.
6|Page
Padding: The CSS padding properties are used to generate space around an
element's content, inside of any defined borders. There are properties for
setting the padding for each side of an element (top, right, bottom, and left).
Margin: The CSS margin properties are used to create space around
elements, outside of any defined [Link] are properties for setting the
margin for each side of an element (top, right, bottom, and left).
Example: <head>
<style>
div {
margin: 100px;
padding:100px;
border: 1px solid #4CAF50;
}</style></head>
<body>
<div>This element</div>
</body>
7|Page
DAY-3
CSS Properties:
Text-decoration-line
text- The text-decoration property text-decoration-color
decoration specifies the decoration added text-decoration-style
to text, and is a shorthand text-decoration-
property for: thickness
8|Page
alignment of text in an center,justify
element.
Task1:
Aim: Create a card with image, title text and description using css.
Code:[Link]
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="./css/[Link]"/>
<title>Document</title>
</head>
<body>
<center>
<div class="card">
<img src="./image/[Link]" alt="img">
<h4>Title</h4>
<p>This is description about above thing
chfaehhgeur23y23ugqhqh you can see it in image above.</p>
<button>Click</button>
</div>
</center>
</body>
</html>
9|Page
Code:[Link]
.card{
border:2px solid black;
width:250px;
border-radius: 15px;
background-color: rgb(201, 193, 193);}
img{
height:150px;
width:250px;
border-radius: 15px 15px 0px 0px;}
button{
height:50px;
width:100px;
10 | P a g e
DAY-4
Background-image and it’s properties:
background-size property:
Values:
contain: Resize the background image to make sure the image is fully
visible.
background-repeat property:
Values:
background-position property:
11 | P a g e
The background-position property sets the starting position of a
background image.
Values: left top, left center, left bottom, right top, right center, center
top, center center, center bottom
Float property:
The float property specifies whether an element should float to the left, right,
or not at all.
Clear property:
The clear property specifies what should happen with the element that is
next to a floating element.
Task1:
Aim: Create two rectangular card with image, title text and description using
css float property.
Code:[Link]
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="./css/[Link]"/>
<title>Document</title>
</head>
<body>
<center>
<div class="container">
<div class="card">
<img src="./image/[Link]" alt="img">
<h4>Title</h4>
12 | P a g e
<p>This is description about above thing
chfaehhgeur23y23ugqhqh you can see it in image above.</p>
<button>Click</button>
</div>
<div class="card">
<img src="./image/[Link]" alt="img">
<h4>Title</h4>
<p>This is description about above thing
chfaehhgeur23y23ugqhqh you can see it in image above.</p>
<button>Click</button>
</div>
</div>
</center>
</body>
</html>
Code:[Link]
.card{
border:2px solid black;
float:left;
width:400px;
height:255px;
background-color:whitesmoke;
margin:30px;
text-align: left;
}
img{
height:150px;
width:400px;
}
13 | P a g e
button{
background-color: rgb(126, 214, 97);
border-radius:15px
}
p,button,h4{
margin:5px;
}
.container{
margin:30px;
display:inline-block;
}
center{
background-color:rgb(231, 221, 221);
}
Output:
Task 2: create navbar with logo image and items using css float property.
Code:[Link]
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<link rel="stylesheet" href=".\css\[Link]"></head>
14 | P a g e
<body>
<div class="nav">
<ul>
<li><img src=".\image\[Link]" class="logo"></li>
<li class="l-item">Python</li>
<li class="l-item">SkLearn</li>
<li class="l-item">Pandas</li>
<li class="l-item">Keras</li>
</ul>
</div>
</body>
</html>
Code:[Link]
ul{
list-style-type: none;}
li{
float:left;}
[Link]{
height:55px;}
.nav{
height: 55px;
background-color: rgb(0, 200, 255);
color:white;
}
.l-item{
margin: 15px;
font-size: 20px;}
15 | P a g e
output:
Task 3: create card with left side image and right side text using css float
property.
Code:[Link]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="./css/[Link]"/>
</head>
<body>
<div class="container">
<div id="p1">
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Nulla
consequatur doloribus reiciendis labore, odio libero ad, suscipit id quis,
quisquam aut quam? Ex hic distinctio nesciunt omnis, fugit tenetur
beatae.
</p>
</div>
<div id="i1">
<img src="./image/[Link]" alt="img">
</div>
</div>
16 | P a g e
<div class="container">
<div id="i1">
<img src="./image/[Link]" alt="img">
</div>
<div id="p1">
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Nulla
consequatur doloribus reiciendis labore, odio libero ad, suscipit id quis,
quisquam aut quam? Ex hic distinctio nesciunt omnis, fugit tenetur
beatae.
</p>
</div>
</div>
</body>
</html>
Code:[Link]
#p1{
float:left;
height: 255px;
width:455px;
}
#i1{
float:left;
height: 255px;
width:355px;
margin-left: 5px;
margin-right:5px;
}
17 | P a g e
img{
height: 255px;
width:355px;
}
.container{
display:block;
height: 255px;
width:820px;
margin:25px;
background-color: whitesmoke;
}
Output:
Code:[Link]:
<html lang="en">
18 | P a g e
<head>
<meta charset="UTF-8">
<link href=".\css\[Link]" rel="stylesheet">
<title>Document</title>
</head>
<body>
<div>
<ul class="nav">
<div class="nav-item"> <li > <img class="logo"
src="[Link] alt="img"></li></div>
<div class="nav-item"> <li>Python</li></div>
<div class="nav-item"><li >JavaScript</li></div>
<div class="nav-item"><li >Java</li></div>
<div class="nav-item"><li >HTML</li></div>
<div class="nav-item"><li >C++</li></div>
</ul>
</div>
<div class="container1">
<ul class="ul2">
<div class="col"> <li>column1</li></div>
<div class="col"> <li>column2</li></div>
<div class="col"> <li>column3</li></div>
<div class="col"> <li>column4</li></div>
<div class="col"> <li>column5</li></div>
<div class="col"> <li>column6</li></div>
<div class="col"> <li>column7</li></div>
<div class="col"> <li>column8</li></div>
<div class="col"> <li>column9</li></div>
</ul>
</div>
19 | P a g e
<div class="container2">
<div class="p1">
<p>
Lorem ipsum dolor sit amet consectetur, adipisicing elit. Explicabo
aut ut quasi! Ullam dolore vitae magnam non nihil nisi autem natus
</p>
</div>
<div class="p1">
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Cum
voluptas consectetur ullam ex suscipit. Molestiae repudiandae maxime
ipsa suscipit, error
</p>
</div>
<div class="p1">
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Cum
voluptas consectetur ullam ex suscipit. Molestiae repudiandae maxime
ipsa suscipit, error
</p>
</div>
<div class="p1">
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Cum
voluptas consectetur ullam ex suscipit. Molestiae repudiandae maxime
ipsa suscipit, error
</p>
</div>
</div>
</body>
</html>
20 | P a g e
Code:[Link]
.nav-item{
float:left;
margin:15px; }
.nav{
list-style-type: none;
display:block;
height:55px;
background-color:black;
color: white;
padding-left: 2px;
margin-left:30%;
margin-right:30%;
border:2px solid white;
border-radius:15px;}
.logo{
height:25px;
width:25px;
border-radius: 50%;}
.container1{
height:100%;
float:left;
display:inline;
background-color: whitesmoke;}
.container2{
margin:20px;
height:100%;
width:60%;
border:2px solid green;
21 | P a g e
float:left;
display:inline;}
ul{list-style-type: none;}
.ul2{
list-style-type: none;
margin:0px;
padding:0px;}
.col{margin:30px;}
.p1{display:inline;}
p{margin:25px;}
output:
22 | P a g e
DAY-5
Position property:
The position property specifies the type of positioning method used for an
element (static, relative, absolute, fixed).
Overflow property:
Values:
hidden: The overflow is clipped, and the rest of the content will be
invisible.
scroll: The overflow is clipped, but a scroll-bar is added to see the rest
of the content.
Hover:
The :hover selector is used to select elements when you mouse over them.
Example:
<!DOCTYPE html>
<html>
<head>
<style>
.container{
margin:30px;
23 | P a g e
background-color: black;
display:inline-block;
height:400px;
width:400px;
}
.container:hover{
background-color: red;}
</style>
</head>
<body>
<div class="container">Hello</div>
</body>
</html>
On hover:
z-index:
When two or more containers are at same position or 1 container covers the
another container in that case we can assign priority that which element
show above by using [Link] can assign 1 or -1 to z-index.
<!DOCTYPE html>
<html>
<head>
<style>
.container{
margin:30%;
background-color: black;
display:inline-block;
height:400px;
width:400px;
opacity:0.5;
24 | P a g e
}
.container:hover{
opacity:1;
}
</style>
</head>
<body>
<div class="container">
</div>
</body>
</html>
Output:
On hover
Task 1: create 3 cards with image and text on image using position
property.
Code:[Link]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<link rel="stylesheet" href=".\css\[Link]">
25 | P a g e
</head>
<body>
<div class="container">
<div class="card">
<div class="img1">
<img src="[Link]
<div class="p1">
<h4>Title</h4>
<p>Lorem ipsum, dolor sit amet consectetur adipisicing elit.
Provident, facere.</p>
</div>
</div>
</div>
<div class="card">
<div class="img1">
<img src="[Link]
<div class="p1">
<h4>Title</h4>
<p>Lorem ipsum, dolor sit amet consectetur adipisicing elit.
Provident, facere.</p>
</div>
</div>
</div>
<div class="card">
<div class="img1">
<img src="[Link]
<div class="p1">
<h4>Title</h4>
<p>Lorem ipsum, dolor sit amet consectetur adipisicing elit.
Provident, facere.</p>
26 | P a g e
</div>
</div>
</div>
</div>
</body>
</html>
Code:[Link]
.card{
height:300px;
width:240px;
float:left;
margin:11px;}
.img1{
position:relative;
width:240px;
height:300px;}
img{
height:300px;
width:240px;}
.p1{
position:absolute;
left:0px;
bottom:0px;
margin:15px;
font-weight: bold;
color:whitesmoke;}
.container{
background-color:whitesmoke;
height: 330px;
27 | P a g e
padding:25px;}
output:
Task 2: create 3 cards with center image and text using position property.
Code:[Link]:
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href=".\css\[Link]">
<title>Document</title>
</head>
<body>
<div class="container">
<div class="card">
<div class="img1">
<img src="[Link]
</div>
<div class="p1">
<h4>Lorem, ipsum dolor.</h4>
<h4>Lorem.</h4>
28 | P a g e
<p>Lorem ipsum, dolor sit amet consectetur adipisicing elit.
Provident, facere.</p>
</div>
</div>
<div class="card">
<div class="img1">
<img src="[Link]
</div>
<div class="p1">
<h4>Lorem, ipsum dolor.</h4>
<h4>Lorem.</h4>
<p>Lorem ipsum, dolor sit amet consectetur adipisicing elit.
Provident, facere.</p>
</div>
</div>
<div class="card">
<div class="img1">
<img src="[Link]
</div>
<div class="p1">
<h4>Lorem, ipsum dolor.</h4>
<h4>Lorem.</h4>
<p>Lorem ipsum, dolor sit amet consectetur adipisicing elit.
Provident, facere.</p>
</div>
</div>
</div>
</body>
</html>
29 | P a g e
Code:[Link]
.card{
float:left;
height:250px;
width:300px;
position:relative;
border-radius: 15px;
margin:50px;
border:2px solid greenyellow;
background-color:whitesmoke; }
.img1{
height:70px;
width:70px;
border:2px solid greenyellow;
border-radius: 50%;
position:absolute;
top:-35px;
left:115px;}
img{
height:70px;
width:70px;
border-radius: 50%;}
.p1{
position:absolute;
top:40px;
left:0px;}
h4{
margin-left:70px;
margin-right: 70px;}
30 | P a g e
p{margin:25px;}
.container{
height:400px;
width:100%;
background-color: aliceblue;
position:absolute;
top:150px;
left:0px;
padding:50px;}
output:
Task 2:
Code:[Link]
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<link href=".\css\[Link]" rel="stylesheet">
</head>
<body>
31 | P a g e
<div class="container2">
<div class="i2"><img src="[Link] style="
height:700px;width:450px;border-radius:15px">
<div class="p1">Lorem ipsum dolor sit amet, consectetur
adipisicing elit. Saepe, enim?</div>
</div>
</div>
<div class="container">
<div class="container1">
<div class="i1"><img src="[Link] style="
height:300px;width:800px;border-radius:15px">
<div class="p1">Lorem ipsum dolor sit amet, consectetur
adipisicing elit. Saepe, enim?</div>
</div>
</div>
<div class="container3">
<div class="i3"><img src="[Link] style="
height:350px;width:350px;border-radius:15px">
<div class="p1">Lorem ipsum dolor sit amet, consectetur
adipisicing elit. Saepe, enim?</div>
</div>
</div>
<div class="container4">
<div class="i3"><img src="[Link] style="
height:350px;width:350px;border-radius:15px">
<div class="p1">Lorem ipsum dolor sit amet, consectetur
adipisicing elit. Saepe, enim?</div>
</div>
</div>
</div>
</body>
</html>
32 | P a g e
Code:[Link]
.p1{
margin:20px;
color:whitesmoke;
position:absolute;
bottom:0px;
left:0px;}
.i1{
height:300px;
width:800px;
position:relative;
border-radius: 15px;}
.i2{
height:700px;
width:450px;
position:relative;
border-radius: 15px;}
.i3{
height:350px;
width:350px;
position:relative;
border-radius: 15px;}
.container1{
position:absolute;
top:0px;
left:0px;}
.container2{
position:absolute;
top:10px;
33 | P a g e
right:100px;} Output:
.container3{
position:absolute;
bottom:0px;
left:0px;}
.container4{
position:absolute;
bottom:0px;
right:0px;}
.container{
position: relative;
height: 700px;
width:800px;}
34 | P a g e
DAY-6
Flex property in css:
CSS Flexbox is a powerful layout model that allows you to create flexible and
responsive designs for web pages. It provides an efficient way to distribute
space, alignment, and positioning of elements within a container. The flex
layout consists of a parent container (flex container) and its child elements
(flex items). The flex container can be displayed horizontally or vertically,
and it controls the layout of its flex items.
To use flexbox, you need to set the display property of the container to flex,
and then use various flex-related properties to control the layout of the child
elements.
flex-direction:
Values:row,column.
justify-content:
Values:
space-around: Items will have space before, between, and after them.
align-content:
CSS Gradients:
35 | P a g e
To create a linear gradient you must define at least two color stops. Color
stops are the colors you want to render smooth transitions among. You can
also set a starting point and a direction (or an angle) along with the gradient
effect.
Syntax:
To create a radial gradient you must also define at least two color stops.
Syntax
<!DOCTYPE html>
<html>
<head>
<title>linear-gradient function</title>
<style>
.gradient {
height: 100px;
background:
linear-gradient(to left
,green, yellow, blue);
Text-align: center;
padding-top: 40px;
font-size: 40px;
color: white;
font-weight: bold;
}
</style>
</head>
<body>
<h2>linear-gradient: Top to Bottom
property</h2>
<div class="gradient">Welcome</div>
</body>
</html>
36 | P a g e
Task1:create a navbar using flex property that have logo and items and
when hover on item sub-items dropdown display .
Code:[Link]
<html lang="en">
<head>
<meta charset="UTF-8">
<link href=".\css\[Link]" rel="stylesheet">
<title>Document</title>
</head>
<body>
<div class="nav">
<div class="logo">
<img src="./image/[Link]" alt="img">
</div>
<div class="sub-nav">
<div class="nav-items">Home</div>
<div class="nav-items con">contact
<div class="dd1"><ul>
<li class="di">contact1</li>
<li class="di sub2">contact2
<ul class="dd2">
<li class="di2">mobile</li>
<li class="di2">whatsapp</li>
<li class="di2">email</li>
</ul>
</li>
<li class="di">contact3</li>
<li class="di">contact4</li>
</ul></div>
</div>
37 | P a g e
<div class="nav-items">xyz</div>
<div class="nav-items">abc</div>
</div>
</div>
</body>
</html>
Code:[Link]
*{margin:0px;
padding:0px;
list-style-type: none;}
.nav{display:flex;
justify-content: space-around;
background-color: black;
color:white;
border:2px solid white;
width:70%;
border-radius:20px;
justify-content: space-between;
align-items: center;
margin-left:100px;}
.logo{margin-left:20px;
height:55px;
width:55px;}
img{height:55px;
width:55px;
border-radius: 50%;}
.sub-nav{display:flex;
align-items: center;
justify-content: center;
38 | P a g e
align-items: center;}
.nav-items{margin-left:10px;
height:40px;
width:60px;}
.con{position: relative;}
.dd1{position:absolute;
background-color: red;
display:none;
width:100%;}
.di{padding: 5px;
opacity:0.7;
border:1px solid black;
box-sizing: border-box;}
.di:hover{padding: 0px;
opacity:1;
box-sizing: border-box;}
.con:hover > .dd1{display:block;}
.sub2{position:relative;}
.dd2{display: none;
height:90px;
width:80px;
background-color: black;
color:white;
position: absolute;
right:-80px;
top:0px;}
.sub2:hover > .dd2{display: block;}
.di2{padding: 5px;
opacity:0.7;
39 | P a g e
border:1px solid white;
box-sizing: border-box; }
.di2:hover{padding: 0px;
opacity:1;
box-sizing: border-box;}
Output:
40 | P a g e
DAY7
Media-query: for making responsive website
Syntax:
css }
}
Example:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<style>
body{
background-color: black;
color:white;
body{background-color: white;
color:black;}
For apply media query we have to apply meta tag:
41 | P a g e
DAY8
Bootstrap:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<script src="[Link]
integrity="sha384-HwwvtgBNo3bZJJLYd8oVXjrBZt8cqVSpeBNS5n7C8IVInixGAoxmnlMuBnhbgrkm"
crossorigin="anonymous"></script>
<title>Document</title>
</head>
<body>
<p class="text-primary">.text-primary</p>
<p class="text-secondary">.text-secondary</p>
<p class="text-success">.text-success</p>
<p class="text-danger">.text-danger</p>
<p class="text-warning">.text-warning</p>
<p class="text-info">.text-info</p>
<p class="text-dark">.text-dark</p>
42 | P a g e
Output:
Background color:
Similar to the contextual text color classes, easily set the background of an
element to any contextual class. Anchor components will darken on hover,
just like the text classes. Background utilities do not set color, so in some
cases you’ll want to use .text-* utilities.
Output:
43 | P a g e
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link href="[Link]
rel="stylesheet" integrity="sha384-
4bw+/aepP/YC94hEpVNVgiZdgIC5+VKNBQNGCHeKRQN+PtmoHDEXuppvnDJzQIu9"
crossorigin="anonymous">
<script src="[Link]
integrity="sha384-HwwvtgBNo3bZJJLYd8oVXjrBZt8cqVSpeBNS5n7C8IVInixGAoxmnlMuBnhbgrkm"
crossorigin="anonymous"></script>
<title>Document</title>
</head>
<body>
44 | P a g e
DAY9
Bootstrap:
45 | P a g e
Cards .card, Bootstrap’s cards
.card-img-top, provide a flexible
.card-title, and extensible
.card-body, content container
.card-text, with multiple
.card-link, variants and
options.
Carousel carousel, A slideshow
carousel-item, component for
active, cycling through
carousel-control-prev, elements—images
carousel-control-next, or slides of text—
carousel-control-next-icon, like a carousel.
carousel-control-prev-icon
Task :create carousel with left side image and right side text using bootstrap.
Code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
46 | P a g e
<link
href="[Link]
[Link]" rel="stylesheet" integrity="sha384-
4bw+/aepP/YC94hEpVNVgiZdgIC5+VKNBQNGCHeKRQN+PtmoHDEXuppv
nDJzQIu9" crossorigin="anonymous">
<script
src="[Link]
[Link]" integrity="sha384-
HwwvtgBNo3bZJJLYd8oVXjrBZt8cqVSpeBNS5n7C8IVInixGAoxmnlMuBnhb
grkm" crossorigin="anonymous"></script>
<title>Document</title>
</head>
<body>
<div id="carouselExample" class="carousel slide" >
</div>
47 | P a g e
<div class="carousel-item">
</div>
<div class="carousel-item ">
48 | P a g e
</div>
</div>
<button class="carousel-control-prev" type="button" data-bs-
target="#carouselExample" data-bs-slide="prev">
<span class="carousel-control-prev-icon" aria-
hidden="true"></span>
<span class="visually-hidden">Previous</span>
</button>
<button class="carousel-control-next" type="button" data-bs-
target="#carouselExample" data-bs-slide="next">
<span class="carousel-control-next-icon" aria-
hidden="true"></span>
<span class="visually-hidden">Next</span>
</button>
</div>
</body>
</html>
Output:
49 | P a g e
DAY10
JavaScript
JavaScript is a widely used programming language primarily known for its
role in web development. It enables interactive and dynamic behavior on
websites, making them more engaging and user-friendly. JavaScript allows
you to create, manipulate, and modify website content in real-time without
requiring a page refresh.
Applications:
50 | P a g e
Front-End Frameworks and Libraries: JavaScript frameworks and
libraries like React, Angular, and [Link] are used to build complex user
interfaces and single-page applications (SPAs). These tools provide efficient
ways to manage state, handle routing, and create reusable UI components.
Datatypes in JS:
Primitive Data Types:
<script> </script>
Or we can also write JS in external file with extension .js and it can be import
using <script src=”PATH” ></script>.
51 | P a g e
Basic javascript program:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
Welcome!
<script>
</script>
</body>
</html>
alert() method:
The alert() method displays an alert box with a message and an OK button.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body> <script>
</script>
</body>
</html>
52 | P a g e
Document Object Model(DOM)
Method Description
getElementsByName() returns all the elements having the given name value.
getElementsByTagName() returns all the elements having the given tag name.
getElementsByClassName() returns all the elements having the given class name.
Operators in JS:
Arithmetic operators:
+ Addition 10+20 = 30
- Subtraction 20-10 = 10
53 | P a g e
* Multiplication 10*20 = 200
/ Division 20/10 = 2
54 | P a g e
&& Logical AND (10==20 && 20==33) = false
= Assign 10+10 = 20
55 | P a g e
DAY11
JavaScript If-else
1. If Statement
2. If else statement
3. if else if statement
JavaScript If statement
if(expression){
//content to be evaluated
}
if(expression){
//content to be evaluated if condition is true
}
else{
//content to be evaluated if condition is false
}
if(expression1){
//content to be evaluated if expression1 is true
}
else if(expression2){
56 | P a g e
//content to be evaluated if expression2 is true
}
else if(expression3){
//content to be evaluated if expression3 is true
}
else{
//content to be evaluated if no expression is true
}
JavaScript Loops
The JavaScript loops are used to iterate the piece of code using for, while,
do while or for-in loops. It makes the code compact. It is mostly used in array.
1. for loop
2. while loop
3. do-while loop
4. for-in loop
57 | P a g e
while (condition)
{
code to be executed
}
do{
code to be executed
}while (condition);
JavaScript Array
Array is an object that represents a collection of similar type of elements.
var arrayname=[value1,value2.....valueN];
<html>
<body>
<script>
var emp=["Sonoo","Vimal","Ratan"];
[Link](emp);
</script>
</body>
</html>
JavaScript Objects
58 | P a g e
JavaScript Objects is used to store key-value pair.
Syntax:
object={
key : value,
key : value,
key : value,
…
}
Example:
<html>
<body>
<script>
emp={id:102,name:”xyz”,salary:40000}
[Link]([Link]+" "+[Link]+"
"+[Link]);
</script>
</body>
</html>
59 | P a g e
//task1 odd-even // task2 percentage grade
[Link]("Task1: odd-even"); [Link]("Task2: percentage
grade.");
var n=prompt("Enter a
number:"); var percentage=prompt("Enter
percentage : ");
if(n%2==0)
if(percentage>=0 &&
{
percentage<=100)
[Link](n+" is even.");
{
}
if(percentage >= 80){
if(n%2==1)
[Link]("A Grade...");
{
}
[Link](n+" is odd.")
else if(percentage >= 70){
}
[Link]("B Grade...");
}
else if(percentage >= 60){
[Link]("C Grade...");
//task3 print 20 1
}
[Link]("sub-task3 20-1
else if(percentage >= 50){
using for loop");
[Link]("D Grade...");
for(i=20; i>0; i--){
}
[Link](i);
else{
}
[Link]("require more
[Link]("sub-task3 20-1
hordwork...");
using while loop");
}
var i=20
}
while(i>0){
else{
[Link](i);
[Link]("percentage value
i--;
must be range 0-100. ")
}
}
60 | P a g e
// task4 print all the even numbers between 1-20
[Link]("sub-task4 print all the even numbers
between 1-20");
var num=2;
while(num<=20){
[Link](num);
num+=2;
}
[Link]("sub-task4 print all the odd numbers
between 1-20");
num=1;
while(num<=20){
[Link](num);
num+=2;
}
61 | P a g e
DAY12
String methods
Array methods:
62 | P a g e
to a string of (comma separated)
array values.
Tasks:
63 | P a g e
//task3 convert characters at //task4 print sum of all elements
//even places in string into *. //present in array
var str=prompt("Enter String:"); arr=[1,2,5,9,11];
var str2=""; var sum=0;
for(var i=0;i<[Link];i++){ for(var i=0;i<[Link];i++){
if(i%2==0){ sum+=arr[i];
str2=[Link](str[i]); }
} [Link](sum);
else{
str2=[Link]("*");
}
}
[Link](str2);
64 | P a g e
//task6 evalute x per given values in array //one by one.
arr=["x++","++x","x++","x--","--x"];
var x=prompt("Enter value:");
for(var i=0;i<[Link];i++){
if(arr[i]=="++x" || arr[i]=="x++"){
x++;
}
else{
x--;
}
}
[Link]("x="+x);
65 | P a g e
DAY13
//task-1 write program that print both string //are equal after
combining each element of //array.
var arr1=["ab","cd"];
var arr2=["a","bcde"];
var str1="";
var str2="";
for(var i=0;i<[Link];i++){
str1+=arr1[i];
}
for(var i=0;i<[Link];i++){
str2+=arr2[i];
}
[Link](str1);
[Link](str2);
if(str1==str2){
[Link]("both strings are equal.");
}
else{
[Link]("both strings are not equal.");
}
66 | P a g e
//task2 print the string in reverse order word
//wise.
var str="hello world how are you";
var arr=[Link](" ");
var str2="";
for(i=[Link]-1;i>=0;i--){
str2+=arr[i]+" ";
}
[Link](str);
[Link](arr);
[Link](str2);
67 | P a g e