Day - 1
Day - 1
React
Day 1 - Topics
• Revision of HTML
• Revision of CSS
• Revision of JavaScript
Revision of HTML
• Here are some basics of HTML that are
important to know when learning React:
– HTML Structure
– Elements and Tags
– Attributes
– Lists
– Forms
– Div and Spans
HTML Structure
• HTML documents have a basic structure with
an opening <html> tag and a closing </html>
tag.
• Inside the <html> tag, you have <head> and
<body> sections.
• The <head> section typically contains
metadata like the page title, character set,
stylesheets, and scripts.
• The main content of your page goes in the
<body> section.
Example
<!DOCTYPE html>
<html>
<head>
<title>Your Page Title</title>
<!-- Other metadata, stylesheets, and scripts go here --
>
</head>
<body>
<!-- Your page content goes here -->
</body>
</html>
Elements and Tags
• HTML is made up of elements represented by
tags.
• Tags are enclosed in angle brackets, like
<tagname>content</tagname>.
• Some common tags include <p> for
paragraphs, <h1> to <h6> for headings, <a>
for links, <img> for images, etc.
Example
<p>This is a paragraph.</p>
<h1>This is a heading level 1</h1>
<a href="https://example.com">Visit
Example</a>
<img src="image.jpg" alt="Description of the
image">
Attributes
• HTML tags can have attributes that provide
additional information about an element.
<ol>
<li>First</li>
<li>Second</li>
</ol>
Forms
/* Class Selector */
.myClass {
font-size: 18px;
}
/* ID Selector */
#myId {
background-color: lightblue;
}
Properties and Values
• CSS properties define the style aspects of an
element (e.g., color, font-size, margin).
.flex-item {
flex: 1;
}
Grid
• CSS Grid is another layout model that
provides a two-dimensional grid system.
• It's useful for creating more advanced and
responsive layouts.
• Properties include display: grid, grid-template-
columns, and grid-template-rows.
Example
/* Grid Example */
.grid-container {
display: grid;
grid-template-columns: repeat(3, 1fr);
grid-gap: 10px;
}
.grid-item {
background-color: lightblue;
padding: 15px;
}
Positioning
• The position property is used to control the
positioning of elements on the page.
/* Animation Example */
@keyframes slide-in {
from {
transform: translateX(-100%);
}
to {
transform: translateX(0);
}
}
.animated-element {
animation: slide-in 1s ease-in-out;
}
Selectors and Combinators
• CSS provides various ways to select elements
using combinators like descendant ( ), child
(>), and sibling (+, ~) selectors.
Example
/* Descendant Selector */
article p {
font-style: italic;
}
/* Child Selector */
.parent > .child {
border: 1px solid red;
}
/* Sibling Selector */
h2 + p {
margin-top: 10px;
}
Pseudo-Classes and Pseudo-
Elements
/* Pseudo-element Example */
.styled-element::before {
content: "🔒 ";
color: green;
}
Revision of JavaScript
• Here are some basics of JavaScript that are important to
know:
– Variables
– Data Types
– Functions
– Control Flow
– Objects
– Arrays
– DOM Manipulation
– Event Handling
– Asynchronous JavaScript
– Modules
Variables
• Declare variables using var, let, or const.
• var has function scope, while let and const
have block scope.
Example:
let message = "Hello, World!";
const pi = 3.14;
Data Types
• Primitive data types include strings, numbers,
booleans, null, and undefined.
• Objects and arrays are complex data types.
Example:
let name = "John";
let age = 25;
let isStudent = true;
let person = { name: "John", age: 25 };
let numbers = [1, 2, 3, 4, 5];
Functions
• Declare functions using the function keyword or
use arrow functions (() => {}).
• Functions can take parameters and return values.
Example:
function add(a, b) {
return a + b;
}
Example:
if (condition) {
// code to run if the condition is true
} else {
// code to run if the condition is false
}
Example:
let person = {
name: "Alice",
age: 30,
isStudent: false
};
console.log(person.name); // Output: Alice
Arrays
• Arrays store ordered collections of values.
• Access array elements using square brackets
and zero-based indexing.
Example:
let fruits = ["apple", "banana", "orange"];
console.log(fruits[1]); // Output: banana
DOM Manipulation
• JavaScript can manipulate the Document
Object Model (DOM) to interact with HTML
and CSS.
• Use methods like getElementById,
querySelector, and innerHTML.
Example:
document.getElementById("myElement").inner
HTML = "New content";
Event Handling
• Reacting to user interactions is crucial. Use
event listeners.
Example:
document.getElementById("myButton").addEve
ntListener("click", function() {
alert("Button clicked!");
});
Asynchronous JavaScript
• JavaScript supports asynchronous operations using
callbacks, promises, and async/await.
Example:
// Using Promises
fetch("https://api.example.com/data")
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error(error));
Modules
• JavaScript can be organized into modules for better
code structure.
• Export and import functionality using export and
import.
Example:
// in module1.js
export const sum = (a, b) => a + b;
// in module2.js
import { sum } from "./module1.js";
Thank You