Introduction to HTML, CSS, and JavaScript
From the https://youtu.be/QTv5VXeX9nw curriculum
TL;DR
HTML structures your web content, CSS styles how it looks, and JavaScript adds interactivity to make your web pages dynamic. These three technologies work together to build almost everything you see and do on the web. Mastering them is key to becoming a web developer.
1. The Mental Model
Think of building a house: HTML is like the blueprint and frame, defining where the rooms, windows, and doors are. CSS is the interior designer, picking paint colors, furniture styles, and decorations. JavaScript is the smart home system, making lights turn on, doors open, or alarms sound when triggered.
2. The Core Material
HTML, CSS, and JavaScript are the foundational languages for front-end web development, meaning they create what you directly interact with in your browser. They each have distinct roles but are rarely used in isolation.
HTML: Structuring Your Content

Photo by anshul kumar on Pexels
HTML stands for HyperText Markup Language. It's not a programming language; it's a markup language that uses elements (tags) to define the structure and content of a web page. Every heading, paragraph, image, or link on a webpage is an HTML element.
Here's a basic HTML structure:
<!DOCTYPE html>
<html>
<head>
<title>My First Web Page</title>
</head>
<body>
<h1>Welcome!</h1>
<p>This is a paragraph of text.</p>
<a href="https://www.example.com">Visit Example</a>
</body>
</html>
<!DOCTYPE html>tells the browser what kind of document it's reading.<html>is the root element.<head>contains meta-information about the page (like the title that shows in the browser tab).<body>contains all the visible content of your web page.
CSS: Styling Your Content

Photo by anshul kumar on Pexels
CSS stands for Cascading Style Sheets. It's used to control the presentation and styling of HTML documents. Think colors, fonts, spacing, layout, and even animations. CSS can be applied in three ways: inline, internal, or external (most common and recommended).
/* This is an external CSS file or inside a <style> tag */
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
margin: 20px;
}
h1 {
color: #333;
text-align: center;
}
p {
font-size: 16px;
line-height: 1.6;
}
You link an external CSS file in your HTML <head> like this:
<link rel="stylesheet" href="styles.css">
JavaScript: Adding Interactivity

Photo by Marek Prášil on Pexels
JavaScript is a full-fledged programming language that enables interactive web pages. It can manipulate HTML and CSS, handle user input, communicate with servers, and much more. It's what makes websites dynamic, allowing for features like dropdown menus, image carousels, form validation, and real-time updates.
// This script could be in an external .js file or inside <script> tags
document.addEventListener('DOMContentLoaded', function() {
const heading = document.querySelector('h1');
heading.style.color = 'blue'; // Change heading color with JS
heading.addEventListener('click', function() {
alert('You clicked the heading!'); // Pop-up when clicked
});
});
You link an external JavaScript file, usually at the end of the <body> tag for performance:
<script src="script.js"></script>
Here's how they fit together:
graph TD
A["HTML (Structure)"] --> B["CSS (Style)"]
A["HTML (Structure)"] --> C["JavaScript (Behavior)"]
B["CSS (Style)"] --> D["Browser Renders Page"]
C["JavaScript (Behavior)"] --> D["Browser Renders Page"]
C["JavaScript (Behavior)"] -- Modifies --> A
C["JavaScript (Behavior)"] -- Modifies --> B
3. Worked Example
Let's create a simple webpage with a button that changes the text of a paragraph when clicked.
First, your index.html file:
<!DOCTYPE html>
<html>
<head>
<title>HTML, CSS, JS Example</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>My Interactive Page</h1>
<p id="myParagraph">This text will change.</p>
<button id="changeTextBtn">Click Me!</button>
<script src="script.js"></script>
</body>
</html>
Next, your style.css file:
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
text-align: center;
margin-top: 50px;
background-color: #e0f2f7;
}
h1 {
color: #007bff;
}
p {
font-size: 1.2em;
color: #333;
margin-bottom: 20px;
}
button {
padding: 10px 20px;
font-size: 1em;
background-color: #28a745;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
transition: background-color 0.3s ease;
}
button:hover {
background-color: #218838;
}
Finally, your script.js file:
document.addEventListener('DOMContentLoaded', function() {
const paragraph = document.getElementById('myParagraph');
const button = document.getElementById('changeTextBtn');
button.addEventListener('click', function() {
paragraph.textContent = "You clicked the button! The text has changed.";
paragraph.style.color = 'red'; // Change paragraph color too
});
});
When you open index.html in a browser, you'll see "My Interactive Page", "This text will change.", and a "Click Me!" button. Clicking the button will change the paragraph's text and color, demonstrating how JavaScript modifies HTML and CSS.
4. Key Takeaways
- HTML provides the structure and content of a web page using elements and tags.
- CSS defines the visual presentation and style of HTML elements.
- JavaScript adds interactivity and dynamic behavior to web pages.
- These three technologies are distinct but work together to create rich web experiences.
- You typically link external CSS (
.css) and JavaScript (.js) files to your HTML for better organization. - JavaScript can read and change both the HTML structure and CSS styles of elements on a page.
Common Mistakes to Avoid:
- Mixing up their roles: Don't try to style with HTML or structure with CSS.
- Forgetting to link CSS or JS files: Your styles or scripts won't apply.
- Putting <script> tags in the <head> without defer or async for scripts that modify <body> content, as the HTML might not be fully loaded yet.
- Not using semantic HTML: Choose tags that describe content (<nav>, <footer>) rather than just styling (<div> everywhere).
5. Now Try It
Create a new HTML file called my_profile.html, a CSS file profile.css, and a JavaScript file profile.js.
1. HTML: Create a simple profile page. Include your name as an <h1>, a short bio in a <p>, and an image of yourself (or a placeholder) using an <img> tag. Add a new button to your HTML with an id like "toggleBio".
2. CSS: Style your name, bio, image (e.g., add a border, center it), and the new button to make it look nice.
3. JavaScript: Write a script that, when the "toggleBio" button is clicked, either shows or hides your bio paragraph. (Hint: you can change paragraph.style.display to 'none' or 'block'.)
Success looks like: A styled profile page where clicking a button makes your bio paragraph disappear and reappear.
Frequently asked about Introduction to HTML, CSS, and JavaScript
Study this next
Get the full https://youtu.be/QTv5VXeX9nw curriculum
Clone the complete plan to your dashboard for unlimited AI-generated notes, practice quizzes, and a personalised revision schedule.
Save this course free