No history yet

Web Development Basics

The Trio of Web Development

Every website you visit, from a simple blog to a complex booking site, is built using three core technologies: HTML, CSS, and JavaScript. Think of them as a team. Each one has a distinct job, but they work together to create the web pages we use every day.

Let's break down what each one does using the analogy of building a house. You can't build a house with just wood, or just paint, or just electrical wiring. You need all three working in concert.

HTML: The Skeleton

HTML, which stands for HyperText Markup Language, provides the fundamental structure of a webpage. It's the framing of the house. It defines the different parts of your page, like headings, paragraphs, images, and links. HTML tells the browser what the content is, but not how it should look.

HTML is about content and structure. It's the nouns of your webpage: a header, a paragraph, a list, an image.

This structure is created using elements, which are represented by tags. For example, to create a main heading, you'd wrap your text in <h1> tags. For a paragraph, you'd use <p> tags. Here’s a look at a very basic HTML document.

<!DOCTYPE html>
<html>
<head>
    <title>My First Webpage</title>
</head>
<body>
    <h1>Welcome to the Hotel</h1>
    <p>Please check in at the front desk.</p>
</body>
</html>

When a web browser reads this file, it understands how to display the content. It knows "Welcome to the Hotel" is a top-level heading and the next line is a paragraph. But without anything else, it will look very plain.

Lesson image

CSS: The Style

CSS, or Cascading Style Sheets, is the interior and exterior designer for our house. It takes the raw structure provided by HTML and makes it look good. CSS handles all the visual presentation: colors, fonts, spacing, and the layout of elements on the page.

By linking a CSS file to our HTML, we can write rules to style our elements. For example, we could make all <h1> elements blue and change the font for all <p> elements.

h1 {
    color: navy;
    font-family: sans-serif;
}

p {
    font-size: 16px;
    color: #333;
}

This code tells the browser to find every <h1> and make it navy blue, and to find every <p> and set its font size and color. CSS separates style from structure, which makes websites much easier to manage. You can change the entire look of a site just by editing the CSS file, without ever touching the HTML.

JavaScript: The Interactivity

If HTML is the framing and CSS is the design, JavaScript is the electricity, plumbing, and all the things that make the house functional. JavaScript is a programming language that brings websites to life. It handles interactivity and dynamic behavior.

When you click a button and a menu appears, fill out a form and get an instant validation message, or see a photo gallery slideshow, that's JavaScript at work. It allows the webpage to respond to user actions without needing to reload the entire page.

Let's imagine we add a button to our simple HTML page to show a special offer. The HTML would define the button, and JavaScript would define what happens when you click it.

// First, we get a reference to our button element
const offerButton = document.getElementById('offerBtn');

// Next, we get a reference to our paragraph
const message = document.getElementById('message');

// We add a 'click' event listener to the button
offerButton.addEventListener('click', function() {
  // When the button is clicked, change the paragraph's text
  message.textContent = 'You get 20% off your stay!';
});

HTML creates the button. CSS styles the button. JavaScript makes the button do something.

These three languages are the foundation of front-end web development. By understanding their distinct roles, you have the key to building any website you can imagine. HTML provides the structure, CSS adds the style, and JavaScript powers the interactivity.

Quiz Questions 1/5

In the analogy of building a house, what is the role of HTML?

Quiz Questions 2/5

If you wanted to change the font size and color of all the paragraphs on your website, which language would you use?