HTML
HTML
Let’s go through the basics of HTML, CSS, and JavaScript to prepare you for your
interview tomorrow. These are the core technologies for web development, and understanding
them well will help you in front-end development roles.
HTML is the foundation of any webpage. It structures the content and elements of a webpage
using tags.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>My Webpage</title>
</head>
<body>
<h1>Hello, World!</h1>
</body>
</html>
Explanation:
● <head>: Contains metadata like title, character set, and links to stylesheets or scripts.
●
●
<li>Item 1</li>
<li>Item 2</li>
</ul>
●
<tr>
</tr>
</table>
●
a. CSS Syntax
selector {
property: value;
Example:
h1 {
color: blue;
font-size: 24px;
This will make all <h1> elements blue and set their font size to 24 pixels.
Colors:
p{
color: red;
}
●
Background:
body {
background-color: lightgrey;
●
margin: 20px;
padding: 10px;
●
Borders:
img {
●
c. CSS Selectors
ID Selector (#idName):
#header {
color: green;
●
Class Selector (.className):
.box {
width: 100px;
height: 100px;
background-color: red;
●
font-size: 18px;
●
d. Positioning
.box {
position: absolute;
top: 20px;
left: 50px;
}
e. Flexbox (for layout)
.container {
display: flex;
justify-content: space-between;
align-items: center;
3. JavaScript (JS)
JavaScript is a scripting language used to make webpages interactive. It’s often used for DOM
manipulation, event handling, and much more.
a. Basic Syntax
b. Functions
function greet(name) {
}
greet("John"); // Output: Hello, John
c. Events
JavaScript is used to handle events, like button clicks, form submissions, etc.
Or using JavaScript:
document.getElementById("myButton").addEventListener("click", function() {
alert("Button clicked!");
});
d. DOM Manipulation
The DOM (Document Object Model) represents the page so you can modify it with JavaScript.
● Accessing an element:
heading.style.color = "blue";
e. Loops
// For Loop
console.log(i);
// While Loop
let i = 0;
while (i < 5) {
console.log(i);
i++;
f. Conditionals
} else {
console.log("You are a minor.");
name: "John",
age: 30,
greet: function() {
};
●
●
if(success) {
reject("Operation failed.");
});
promise.then((message) => {
console.log(message);
}).catch((message) => {
console.log(message);
});
○ id is unique and should only be used once per page, while class can be reused
multiple times.
○ Flexbox allows for easier and more flexible layouts, especially for aligning items
and distributing space within a container.
○ this refers to the context in which a function is called. It typically points to the
object from which the method was called.
5. What is event delegation in JavaScript?
1. Practice writing HTML and CSS code: Make sure you're comfortable building simple
websites and layouts.
2. Understand basic JavaScript concepts: Be prepared to demonstrate how you can
interact with the DOM, use events, and handle simple logic.
3. Know the differences between var, let, and const in JavaScript: let and const
are block-scoped, while var is function-scoped.
Good luck with your interview! Let me know if you'd like to dive deeper into any specific topic or
need more examples!