Full Stack Development - Part 1
Full Stack Development - Part 1
Unit I
HTML: Tags -structuring document -web page–Make it Prettier with CSS-
Loading background images–Organizing files-JavaScript- variables-
Controlling HTML and CSS-Organizing JavaScript code
Root
Meta Information
<head> meta-information
Example 1:
<!DOCTYPE html>
<html>
<head>
<!-- Base URL for all relative links -->
<base href="https://www.sairam.edu.in/">
<!-- Metadata -->
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="This is a sample HTML page using ba
se, link, meta, head, and title tags.">
Tags Description
Sectioning Root
Example 2:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Introduction to HTML</title>
</head>
<body>
<header>
Tags Description
Text content
<p> Paragraph
<sub> Subscript
<sup> Superscript
Example 3:
<!DOCTYPE html>
<html>
<head>
<title>Formatted Text Example</title>
</head>
<body>
<h1>Text Formatting Showcase</h1>
<p>This is a <strong>strong</strong> and <em>emphasized</em> senten
ce with <mark>highlighted</mark> text.</p>
<p><b>Bold</b>, <i>Italic</i>, <u>Underline</u>, <s>Strikethrough</s>
</p>
<p>H<sub>2</sub>O and x<sup>2</sup></p>
<p><del>Old Price</del> <ins>New Price</ins></p>
<pre>
for (int i = 0; i < 5; i++) {
print(i);
Tag Purpose
Multimedia
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Image and Multimedia Gallery</title>
</head>
<body>
<h1>Welcome to the Multimedia Gallery</h1>
<!-- Image Tag -->
Lists
Tag Description Example
<ul> Unordered list (bullets) <ul><li>Item</li></ul>
Table
Tag Description Example
<table> Table container <table>...</table>
Attributes
To represent further information about how an element should be displayed -
Each element can have an attribute - They are always defined in the opening
tag
name = "value"
Mouse button is
onmouseup <div onmouseup="console.log('Up')">Release</div>
released
Keyboard Events
Form Events
Attribute Triggered When Example
Element gains
onfocus <input onfocus="this.style.background='yellow'">
focus
Element loses
onblur <input onblur="this.style.background='white'">
focus
Value changes
onchange <input onchange="alert('Changed!')">
and loses focus
Value changes
oninput <input oninput="console.log(this.value)">
(while typing)
Form is
onsubmit <form onsubmit="alert('Submitted!')">
submitted
onreset Form is reset <form onreset="alert('Form Reset')">
Text is selected
onselect <input onselect="alert('Text selected!')">
in input/textarea
The structure is like the skeleton of your webpage — it defines the order
and grouping of content.
Why CSS?
Separates content (HTML) from presentation (CSS)
Internal CSS
<style>
p { color: green; font-size: 18px; }
</style>
External CSS
CSS Selectors
Element Selector: p{} → Targets all <p> tags
CSS Properties
Text & Font Styling
color → Text color
Backgrounds
Colors
Named colors (e.g., red, blue)
Example 4:
<!DOCTYPE html>
<html>
<head>
<title>Styled Page</title>
<style>
body {
background-color: #f0f8ff;
font-family: Arial, sans-serif;
}
h1 {
color: #2e8b57;
text-align: center;
}
p{
color: #333;
font-size: 18px;
line-height: 1.6;
}
CSS Position
Position Behavior
static Default, normal flow
relative Moves relative to itself
absolute Moves relative to nearest positioned parent
fixed Stays fixed in viewport
sticky Sticks when scrolling
2. relative
Positioned relative to its normal position.
Use top , left , right , bottom to move slightly.
<div style="position: relative; top: 10px; left: 20px; border: 2px solid gree
n;">
I moved 10px down and 20px right.
</div>
3. absolute
Positioned relative to the nearest positioned ancestor (not the viewport).
If no ancestor has position set, it uses the <body> .
4. fixed
Positioned relative to the viewport (stays in place when scrolling).
5. sticky
Behaves like relative until you scroll, then it "sticks" to a position.
Setting up Flexbox
.container
{
display: flex;
}
gap / row-gap ,
Space between grid items gap: 20px;
column-gap
.grid-item {
background: lightblue;
border: 2px solid #333;
padding: 20px;
text-align: center;
font-size: 18px;
border-radius: 8px;
}
</style>
</head>
<body>
<h2>Simple Grid Layout</h2>
<div class="grid-container">
<div class="grid-item">1</div>
<div class="grid-item">2</div>
<div class="grid-item">3</div>
Flexbox vs Grid
Feature Flexbox Grid
Alignment Easy along main/cross axis Full control over rows & columns
{
background-image: url("image.jpg");
}
Common Properties
background-repeat → repeats the image (default).
Values: cover (fills the area), contain (fits inside), auto (default).
Values: left , center , right , top , bottom , or coordinates (e.g., 50% 50% ).
project-folder/
│── index.html (main web page)
│── about.html (another page)
│
├── css/ (all stylesheets)
│ └── style.css
│
├── js/ (all JavaScript files)
│ └── script.js
│
├── images/ (all images)
│ ├── logo.png
│ └── background.jpg
│
├── fonts/ (custom fonts if any)
│ └── myFont.ttf
│
└── assets/ (other files like videos, pdfs, icons)
└── video.mp4
Bytes
inline: Elements do not start on a new line, and you cannot set
width/height. (e.g., <span> )
inline-block: Elements do not start on a new line, but you can set
width/height.
<style>
.inline {
display: inline;
background: lightcoral;
width: 150px; /* will not work /
height: 50px; /* will not work */
}
.inline-block {
display: inline-block;
background: lightgreen;
width: 150px; /* works */
height: 50px; /* works */
}
</style>
<!DOCTYPE html>
<html>
<head>
<style>
.ball {
width: 50px;
height: 50px;
background: red;
border-radius: 50%;
position: relative;
animation: bounce 1s infinite alternate;
}
Box-Sizing Property
The box-sizing property in CSS defines how the total width and height of an
element are calculated.
padding/border.
<!DOCTYPE html>
<html>
<head>
<style>
body {
display: flex;
justify-content: center; /* horizontal center */
align-items: center; /* vertical center */
height: 100vh; /* full screen height */
margin: 0;
}
.box {
width: 200px;
height: 100px;
background: lightblue;
text-align: center;
line-height: 100px;
}
</style>
</head>
<body>
<div class="box">Centered Div</div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<style>
body {
height: 100vh;
defer attribute
The defer attribute in the <script> tag makes the script load in the background
and execute only after the HTML document has been fully parsed.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.
0">
<title>Login Form</title>
<style>
body {
font-family: Arial, sans-serif;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background: #f3f4f6;
}
.form-container {
background: white;
.remember {
margin: 10px 0;
font-size: 14px;
}
button {
width: 100%;
padding: 10px;
background: #007bff;
border: none;
color: white;
border-radius: 5px;
font-size: 16px;
cursor: pointer;
}
button:hover {
background: #0056b3;
}
</style>
</head>
<body>
<div class="form-container">
<h2>Login</h2>
<form>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.
0">
<title>CSS Position Example</title>
<style>
body {
font-family: Arial, sans-serif;
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.
0">
<title>Responsive Flexbox Cards</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 20px;
background: #f4f4f9;
}
.card-container {
display: flex; /*Turns container into Flexbox layout.*/
flex-wrap: wrap; /*Cards will wrap to the next line if screen is small. */
gap: 20px; /*Adds spacing between cards. */
.card {
background: #fff;
border-radius: 12px;
box-shadow: 0 4px 8px rgba(0,0,0,0.1);
width: 300px;
overflow: hidden; /* hides any extra content that spills out of the contai
ner. */
transition: transform 0.2s; /* Smooth animation when hovering. */
}
.card:hover {
transform: translateY(-5px); /* moves 5px in y direction when hovered
*/
}
.card img {
width: 100%;
height: 200px;
object-fit: cover; /* Image keeps its original shape */
}
.card-content {
padding: 15px;
}
.card-content h3 {
margin: 0 0 10px;
font-size: 1.2rem;
color: #333;
}
.card-content p {
margin: 0;
font-size: 0.95rem;
color: #666;
</style>
</head>
<body>
<h1 style="text-align:center;">Responsive Flexbox Cards</h1>
<div class="card-container">
<div class="card">
<img src="https://picsum.photos/300/200?1" alt="Card Image 1">
<div class="card-content">
<h3>Card Title 1</h3>
<p>This is a description for the first card.</p>
</div>
</div>
<div class="card">
<img src="https://picsum.photos/300/200?2" alt="Card Image 2">
<div class="card-content">
<h3>Card Title 2</h3>
<p>This is a description for the second card.</p>
</div>
</div>
<div class="card">
<img src="https://picsum.photos/300/200?3" alt="Card Image 3">
<div class="card-content">
<h3>Card Title 3</h3>
<p>This is a description for the third card.</p>
</div>
</div>
</div>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.
0">
<title>Basic Navbar</title>
<style>
body {
margin: 0;
font-family: Arial, sans-serif;
}
/* Navbar container */
.navbar {
display: flex;
justify-content: space-between;
align-items: center;
background-color: #333;
padding: 10px 20px;
}
/* Navigation links */
.nav-links a {
color: white;
text-decoration: none;
padding: 5px 10px;
}
.nav-links a:hover {
background: #555;
border-radius: 5px;
}
</style>
</head>
<body>
<div class="navbar">
<div class="logo">MySite</div>
<div class="nav-links">
<a href="#">Home</a>
<a href="#">About</a>
<a href="#">Services</a>
<a href="#">Contact</a>
</div>
</div>
</body>
</html>