BIT - Web3
BIT - Web3
HTML,
CSS & JS
The Building Blocks of the Web diagram
showcases how HTML, CSS, and JavaScript
contribute to web development. HTML
provides structure, CSS adds styling, and
JavaScript enabled interactivity in web
development. Their integration creates
functional and visually appealing websites.
History
Inventor of the
World wide
web and HTML
at CERN 1993
What is HTML ?
<!DOCTYPE html>
● HTML stands for HyperText Markup <html>
Language. <head>
<title>HTML</title>
● It is used to structure content on the web. </head>
● HTML is not a programming language; it is <body>
<h1>Welcome to HTML</h1>
a markup language. <p>This is a paragraph.</p>
● Works alongside CSS for styling and </body>
</html>
JavaScript for interactivity
Evolution of Markup Language
First website on WWW
Normal text is simple, plain text that is displayed on a webpage without any
special linking capabilities. It does not have any interactive features.
Hyper text in HTML
Web generation describes the different evolutionary stages of the internet's development,
where each phase introduces new technologies and ways people use the web.
Different Generations of web
</body>
</html>
Web 2.0 <html>
<head>
<title>Web 2.0 Example</title>
User-generated content (social media, blogs, </head>
forums). <body>
<h1>Leave a Comment</h1>
Dynamic and interactive web applications. <input type="text" placeholder="Enter your
comment">
Examples: Facebook, YouTube, Wikipedia.
<button onclick="alert('Comment
submitted!')">Submit</button>
</body>
</html>
Web 3.0
Web 3.0 is the next generation of the internet that focuses on decentralization, meaning no
single company controls data. It uses blockchain technology, artificial intelligence, and the
semantic web to create a smarter, more private, and user-controlled online experience.
Web 4.0
Tag Closing Some tags can remain All tags must be properly
unclosed (e.g., <br>, <img>, closed (e.g., <br />, <img />).
<p>).
List Tags
Table Tags
Form Tags
<!DOCTYPE> <html>
layout. <style></style>
<script>
</head>
<style>
<body></body>
</html>
Tag Explanation Example
presentation and style of text. <em> Indicates emphasized text (italic by default). <em>Emphasized
text.</em>
These tags affect how the text <span> Inline container for styling or scripting. <span
style="color:red;">Red
appears on the webpage, such as text</span>
making it bold, italic, underlined, or <pre> Displays preformatted text (preserves spaces <pre>Hello World</pre>
and line breaks).
accessible, and better optimized for <main> Defines the main content of the <main><h1>Main Content</h1></main>
document.
search engines.
Tag Explanation Example
group and organize items in a <li> Defines a list item (used <li>List Item</li>
inside <ul> or <ol>).
list format.
<dl> Defines a description <dl><dt>Term</dt><dd>Definiti
list. on</dd></dl>
Link and Media tags in HTML are used to reference external resources such as stylesheets,
images, videos, audio, and other media content.
Tag Explanation Example
Table tags in HTML are used <td> Defines a table cell. <td>Cell Data</td>
An HTML Element includes everything from HTML Tags are the actual keywords
the opening tag, the content inside, and the enclosed in angle brackets (< >) that define
closing tag if required. the beginning and the end of the element.
It represents the complete structure of an Tags are used to create elements but do not
HTML component. include the content inside them
HTML Element vs HTML Tag
These elements take up only the space required for their content.
Assignment
Global Attributes Event Attributes Special Attributes
Attributes that can be applied to Attributes are used to handle Attributes that are specific to
any HTML element. events such as clicks, mouse particular HTML elements.
movements, and other user
actions.
Attributes that are specific to onclick, onmouseover, onfocus href, src, alt
particular HTML elements.
applied to any HTML element, regardless of its class For adding and same element, add classes
for styling purposes
type. These attributes allow customization and
title To Provide additional information about
provide additional functionality like styling, the content inside the element
typing, or focusing on an element. onfocus Executes when the element gains focus
<div id="eventExample" class="event-highlight"
onclick="alert('You clicked me!')" onblur Executes when the element loses focus
onmouseover="this.style.backgroundColor='yellow'"
onsubmit Executes when a form is submitted.
onmouseout="this.style.backgroundColor='white'">
Event Attribute Example </div>
src Specifies the source of an embedded resource
Special Attributes
like an image, video,
Numerical ordered list Alphabetical ordered list Roman numeric ordered list
<dt>HTML</dt>
Description List <dd>HyperText Markup Language - used to structure
web pages.</dd>
A description list in HTML is used to define a
list of terms with their corresponding <dt>CSS</dt>
descriptions. It is created using the <dl> <dd>Cascading Style Sheets - used to style web
(description list) tag, along with <dt> pages.</dd>
(description term) for the term and <dd>
<dt>JavaScript</dt>
(description definition) for its description.
<dd>A programming language used to create dynamic
content on websites.</dd>
</dl>
Definition List
A Definition List (<dl>) in HTML is used to define terms and their corresponding descriptions. It
consists of three main tags:
The <table> tag in HTML is used to create tables for organizing and displaying data in a structured
format.
Classwork / Homework
Create a simple table having 3 rows and 3 columns using html.
White space refers to spaces, tabs, and line breaks (newlines) that are used in the HTML code.
HTML ignores extra white spaces when rendering a webpage, meaning multiple spaces will be
treated as a single space.
<p>This is an example.</p>
Even though there are multiple spaces between words, the browser will display it as: This is an
example.
<pre>
This is preserved.
</pre>
The <pre> tag maintains white spaces and line breaks as they are.
Indentation
Indentation refers to using spaces or tabs to organize HTML code properly. It makes the code
easier to read and understand but does not affect how the webpage is displayed.
HTML Meaning
With the <pre> tag, the text renders in the browser exactly as you type it. The <pre> tag is short
for preformat.
So if you press the ENTER or RETURN key several times to create line breaks within a <pre> tag,
you can expect to see all those line breaks in a browser.
The <pre> tag usually displays text in a monospaced font (i.e., Courier).
All tags and texts that apply to table go inside the <table> .. </table> tags.
Table attribute - BORDER
Table attribute - ALIGN
The align attribute specifies where the table will be positioned and how text will flow around it.
Table Attribute - WIDTH
Width = N% Where n is the width given as a percentage of the available browser window width
Table Attribute - CELLPADDING
Defines the space between the data in a cell and the border of the cell in pixels
Table Attribute - CELLSPACING
<caption> .. </caption>
The text inside the <caption> … </caption> Tags is inserted directly above the table in the browser
window
Table Row Element
<tr> .. </tr>
ALL OF THE CELLS IN A ROW BELONG WITHIN THE <tr> .. </tr> TAGS OF THAT ROW.
There are two types of data cells, located in the header (<th> .. </th>) or in the table body (</td> .. </td>)
Attributes that can be applied to the table row element (tr) are align and bgcolor
Table Row Element
<th> .. <th> - The table header elements are displayed in <strong> and provide a way of labeling rows and
columns.
Attributes that can be applied to the table header and table body are align, valign, width, colspan and
rowspan
Rowspan
Tells the browser that this data cell will span the area of two vertically adjacent cells
These cells will be joined vertically (and will thus span over two rows)
Colspan
GIF - Types
JPEG
PNG
Uses a 256-color palette – Limited to 256 colors, making it less suitable for complex images.
Best for specific image types – Ideal for screenshots, line drawings, and images with sharp edges.
Larger file size than JPEG – If space is an issue and the image has many colors, JPEG is a better
choice.
Plain GIF
Transparent GIF
Animated GIF
Plain GIF
A Plain GIF is a non-animated GIF that contains only a single image. It does not have multiple
frames like an animated GIF. It is also called as Static GIF
Best for simple images – Used for icons, logos, and diagrams.
Examples ..
Source: Internet
Example of Transparent
and Animated GIF
A Transparent GIF is a GIF image with a see-through background instead of a solid color. This
allows the image to blend smoothly with any webpage or background color.
Supports transparency – One color in the image can be made fully transparent (but not
semi-transparent).
Best for logos, icons, and web graphics – Helps images look clean on different backgrounds.
Examples..
Source: Internet
Animated GIF
An Animated GIF is a GIF file that contains multiple images (frames) played in a sequence to
create a motion effect, like a short video.
Best for memes, stickers, and web animations – Used for fun or informative motion graphics.
Examples of Animated GIF
JPEG - Joint Photographic Experts Group
JPEG is a type of image format that uses a method of compression called "lossy
compression." This means it reduces the image size by removing some details, which can
make the image quality a little worse. However, this loss of quality is usually not noticeable
because our eyes can't easily tell the difference between very similar colors.
Features..
Compression: Uses lossy compression to reduce file size, making it ideal for web usage and
storage efficiency.
There is no difference between .jpg and .jpeg in terms of functionality, quality, or compression.
Both are the same file format (JPEG - Joint Photographic Experts Group). The difference exists
only due to naming conventions in different operating systems.
Key Differences:
.jpg: Used because older Windows versions (like Windows 95 and earlier) only allowed
three-letter file extensions.
PNG - Portable Network Graphics
PNG, pronounced as "PING," is a great alternative to both GIF and JPEG formats.
It offers lossless compression, which means no loss in image quality, and the file size is often smaller
than GIF without compromising quality.
PNG supports RGBA (Red, Green, Blue, Alpha), which means it can handle transparency in images,
allowing them to blend seamlessly with different backgrounds.
It's supported by modern programs like Paint Shop Pro, Netscape Navigator, and Internet Explorer.
PNG works with indexed color, grayscale, and true-color images, and also includes an optional alpha
channel for transparency. Additionally, it provides a patent-free replacement for GIF.
Features..
Compression: Uses lossless compression, meaning no image quality is lost when saving.
Quality: Maintains high-quality images, making it ideal for graphics, logos, and screenshots.
Transparency: Supports transparent backgrounds, unlike JPEG, making it useful for logos and
layered images.
Using Anchor Tag
The <a> (anchor) tag creates a hyperlink, making the enclosed text clickable and typically
highlighted. It requires an opening and closing tag, with the linked text placed in between. The
href attribute specifies the URL, which defines the file type and location. When clicked, the
browser navigates to the specified page or file. The target attribute controls how the link opens,
such as in a new tab or the same window.
It displays like this in a web browser: Hello World! How Are You?
Anchor Tag Example
When your readers click on the link they go to the file described by that link. Most browsers are,
by default, configured to underline links as well.
Anchor Attribute
The anchor tag has three attributes that you'll use for making a link:
• href
• target
• name
href (hypertext reference)
The href attribute in the <a> tag specifies the destination URL for the hyperlink. The URL
should be enclosed in quotes. For example, <a href="http://www.projectcool.com">Go to
Project Cool's Home Page.</a> links to a webpage, while <a
href="mailto:[email protected]">Send Me Mail!</a> creates an email link.
Target
The target attribute in the <a> tag controls where the linked file will open. It is especially useful
when working with frames, but if not using frames, it can open the link in a new window.
_top: Opens in the full browser window, breaking out of any frames.
Cascading Style Sheets (CSS) is a stylesheet language used to control the presentation and layout
of web pages. It works by defining styles (such as colors, fonts, spacing, and positioning) that are
applied to HTML elements.
Types of CSS
Inline CSS
Internal CSS
External CSS
Inline CSS
Inline CSS involves applying styles directly to individual HTML elements using the style attribute.
<p style="color:#009900;
font-size:50px;
font-style:italic;
text-align:center;">
Inline CSS
</p>
Internal CSS
Internal / Embedded CSS is defined within the HTML document’s <style> element. It applies
styles to specific HTML elements. The CSS rule set should be within the HTML file in the head
section i.e. the CSS is embedded within the <style> tag inside the head section of the HTML file.
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,
initial-scale=1.0">
<title>Internal CSS Example</title>
<style>
body {
background-color: lightblue;
font-family: Arial, sans-serif;
}
h1 {
color: darkblue;
text-align: center;
}
p {
color: darkgreen;
font-size: 18px;
}
</style>
</head>
External CSS
External CSS contains separate CSS files that contain only style properties with the help of tag
attributes (For example class, id, heading, … etc). CSS property is written in a separate file with a
.css extension and should be linked to the HTML document using a link tag. It means that, for
each element, style can be set only once and will be applied across web pages.
External CSS (style.css) body {
background-color: lightyellow;
font-family: Verdana, sans-serif;
}
h1 {
color: darkred;
text-align: center;
}
p {
color: navy;
font-size: 18px;
}
CSS Colors
Color
background-color
border-color
CSS allows you to style elements using different colors.
Example:
p {
color: blue;
}
Background color in CSS
Example:
div {
background-color: red;
}
Border colors in CSS
The border-color property sets the color of the border around an element.
Example:
div {
border-color: red;
}
Combining color, background-color, and border-color
div {
color: white;
background-color: darkblue;
}
Introduction to CSS
CSS Properties
font-family
font-size
font-weight
font-style
Typography
color
line-height
text-align
text-decoration
letter-spacing
word-spacing
font-family
It defines the type of font used for text. If the first font
is not available, the browser uses the next one in the list.
Example:
Example:
font-size: 20px;
Example
font-weight: bold;
Example
font-style: italic;
Example
color: red;
Example
line-height: 1.5;
Example
text-align: center;
Example
text-decoration: underline;
Example
letter-spacing: 2px;
Example
word-spacing: 5px;
height
margin
Box Model
padding
border
box-sizing
width
Example
width: 200px;
Example
height: 100px;
Example
margin: 20px;
Example
padding: 10px;
Example
Example
box-sizing: border-box;
background-image
background-position
background-repeat
Borders border-style
border-width
border-radius
box-shadow
background-color
Example
background-color: lightblue;
Example
background-image: url('background.jpg');
Example
background-position: center;
Example
background-repeat: no-repeat;
Example
border-color: red;
Example
border-style: dashed;
Example
border-width: 3px;
Example
border-radius: 10px;
Example
This adds a shadow 5px right, 5px down, and blurred by 10px.
color
Colors
background-color
border-color
color
Example
color: red;
Example
background-color: blue;
Example
top
Positioning right
bottom
left
z-index
position
Example
position: absolute;
position: relative;
top: 20px;
left: 30px;
Example
z-index: 5;
position
float
clear
overflow
Layout
flexbox properties
(flex-direction, justify-content,
align-items, etc.)
grid properties
(grid-template-columns,
grid-template-rows, grid-gap,
etc.)
Animation & transition
Transitions
animation
transition
Used to create smooth changes when a property (like color or size) changes.
button {
background-color: blue;
button:hover {
background-color: red;
When you hover over the button, it smoothly changes from blue to red in 0.5
seconds.
Animation
Allows more complex effects by changing styles over time.
@keyframes move {
to { left: 100px; }
div {
position: absolute;
This moves a div back and forth from left 0px to left 100px in 2 seconds, repeating
forever
transform
Transforms
rotate
scale
translate
skew
Transforms allow element to be rotated, resized,
moved or skewed without affecting other element
transform
Example
transform: rotate(45deg);
Example
transform: rotate(90deg);
Example
transform: scale(1.5);
Example
Example
transform: skew(20deg);
Queries?
CSS rules to apply only
when certain conditions
are met (like screen
width).
Changing background for small screen
body {
background-color: white;
}
/* When the screen width is 600px or less */
@media (max-width: 600px) {
body {
background-color: lightblue;
}
}
Lists
list-style-type
list-style-image
list-style-position
list-style-type
Example
ul {
list-style-type: square;
Table border-collapse
border-spacing
caption-side
input styling (e.g.,
border, padding, width)
textarea styling (similar
to input)
button styling (similar to
opacity
Miscellaneous
visibility
outline
overflow
pointer-events
text-overflow
Unit - 4
Introduction to Javascript
Javascript is a programming language used to make
web pages interactive. It runs in the browser and
allows you to create dynamic content.
Introduction to Javascript
● Automatically
● Using var
● Using let
● Using const
Var
conditionals).
if (true) {
declared).
before declaration).
let Example
let city = "New York";
if (true) {
let x = 10;
const PI = 3.1416;
PI = 3.14; // ❌ Error: Cannot reassign a constant
The var keyword was used in all JavaScript code from 1995 to
2015.
Any text between // and the end of the line will be ignored
by JavaScript (will not be executed).
Multi-line comments
- Number - Object
- String - Array
- Boolean - Function
- Undefined
- Null
- Bigint
Number
let something;
console.log(something); // undefined
Null
Operators
types of mathematical and
logical computations.
Arithmetic Operators
Assignment Operators
Comparison Operators
String Operators
Types of Javascript Logical Operators
Ternary Operators
Type Operators
Javascript Arithmetic Operator
let a = 3;
let a = 10;
let b = 5;
console.log(a + b); // 15 (Addition)
console.log(a - b); // 5 (Subtraction)
console.log(a * b); // 50 (Multiplication)
console.log(a / b); // 2 (Division)
console.log(a % b); // 0 (Modulus - Remainder)
console.log(a ** 2); // 100 (Exponentiation - 10^2)
Operator Description
+ Addition
- Subtraction
* Multiplication
** Exponentiation (ES2016)
/ Division
++ Increment
-- Decrement
Assignment Operators
let x = 10;
x += 5;
Example - Assignment Operator
let x = 10;
x += 5; // Same as x = x + 5
console.log(x); // 15
x -= 3; // x = x - 3
console.log(x); // 12
x *= 2; // x = x * 2
console.log(x); // 24
x /= 4; // x = x / 4
console.log(x); // 6
Operator Example Same As
= x=y x=y
+= x += y x=x+y
-= x -= y x=x-y
*= x *= y x=x*y
/= x /= y x=x/y
%= x %= y x=x%y
**= x **= y x = x ** y
Comparison Operators
== equal to
!= not equal
? ternary operator
String Operators
|| logical or
! logical not
Javascript Type Operators
● 5 → 0101
● 1 → 0001
The & (AND) operator compares each bit and returns 1 only if
both bits are 1.
Final Binary Result → 0001
Decimal Equivalent → 1
Assignment - Bitwise Operators write and explain
Operator Description Example Same as Result Decimal
return p1 * p2;
<html>
}
<body>
let result = myFunction(4, 3);
It is used to take input from the user and returns the user
input as a string.
if (response) {
} else {
}
Conditional statements in
statements
make decisions in code
based on conditions.
if Statement
}
if...else Statement
if (number % 2 === 0) {
console.log("Even number");
} else {
console.log("Odd number");
}
if...else if...else Statement
It checks multiple conditions, executing the first true block.
console.log("Grade: A");
console.log("Grade: B");
} else {
console.log("Grade: C");
}
Switch Statement
console.log(message);
Nested if Statements
An if statement inside another if statement.
fruits[1] = "Orange";
let matrix = [
[1, 2, 3],
[4, 5, 6],
[7, 8, 9]
];
console.log(matrix[1][2]); // Output: 6
Sparse Array
DOM
a tree structure, where
each element is a node
that can be accessed,
modified, or deleted using
JavaScript.
When a web page is loaded, the browser creates a
Document Object Model of the page.
The HTML DOM Tree of Objects
Why is the DOM Important?
events.
3 Ways to handle events
<script>
document.getElementById("myButton").onclick = function() {
alert("Button Clicked!");
};
</script>
Using addEventListener()
<script>
document.getElementById("btn").addEventListener("click", function() {
});
</script>
onClick
The onmouseover event is triggered when the mouse pointer enters an element.
The onmouseout event is triggered when the mouse pointer leaves an element.
</p>
onSubmit
<script>
function validateForm() {
let name = document.getElementById("name").value;
if (name === "") {
alert("Name cannot be empty!");
return false; // Prevents form submission
}
return true; // Allows form submission
}
</script>
onFocus and onBlur
away (onBlur).
onFocus and onBlur (Contd..)
<script>
function validateInput() {
let name = document.getElementById("name").value;
let error = document.getElementById("error");
<noscript>
</noscript>