No history yet

Introduction to Web Development

The Blueprint of the Web

Every website you visit, from a simple blog to a complex online store, is built on a foundation of HTML. Think of HTML, or HyperText Markup Language, as the skeleton of a webpage. It provides the essential structure and organizes the content.

HTML isn't a programming language. It's a markup language, which means it uses tags to define different types of content. These tags tell the web browser how to display text, images, and other elements. For example, a tag can turn a piece of text into a headline, a paragraph, or a link.

Without HTML, a webpage would just be a single, unformatted block of text.

A basic HTML document has a standard structure. It always starts with a <!DOCTYPE html> declaration, followed by an <html> tag that wraps all the content. Inside, you'll find a <head> section for metadata (like the page title) and a <body> section for the visible content.

<!DOCTYPE html>
<html>
<head>
  <title>My First Webpage</title>
</head>
<body>
  <h1>Hello, World!</h1>
  <p>This is a paragraph of text.</p>
  <a href="#">This is a link.</a>
</body>
</html>

In the example above, <h1> creates a top-level heading, <p> creates a paragraph, and <a> (for "anchor") creates a link. These elements are the building blocks you'll use to structure any webpage.

Lesson image

Adding Style with CSS

While HTML provides the structure, Cascading Style Sheets (CSS) brings the style. If HTML is the skeleton, CSS is the clothing, the paint, and the interior design. It controls colors, fonts, spacing, and the overall layout of the webpage.

CSS works by selecting HTML elements and applying style rules to them. A rule consists of a selector and a declaration block. The selector points to the HTML element you want to style, and the declaration block contains one or more property-value pairs.

/* This is a CSS comment */
p {
  color: navy;
  font-size: 16px;
}

In this example, p is the selector. It targets all <p> (paragraph) elements. The properties are color and font-size, and their values are navy and 16px, respectively. This simple rule tells the browser to display all paragraphs in a navy blue color with a font size of 16 pixels.

You can select elements by their tag name (like p or h1), but you can also get more specific using classes or IDs. A class lets you style a group of elements, while an ID is used to style a single, unique element.

/* Class selector */
.highlight {
  background-color: yellow;
}

/* ID selector */
#main-header {
  border-bottom: 2px solid black;
}

The Box Model

Every element on a webpage can be thought of as a rectangular box. Understanding this concept, known as the box model, is key to managing layout and spacing in CSS. Each box is made up of four parts.

  1. Content: The actual content of the box, where text and images appear.
  2. Padding: The transparent space around the content, inside the border.
  3. Border: A line that goes around the padding and content.
  4. Margin: The transparent space outside the border, separating the element from other elements.

By adjusting these four properties, you can precisely control where elements are positioned on the page and how much space they take up.

Responsive Design

Today, people browse the web on all sorts of devices: phones, tablets, laptops, and large desktop monitors. A website that looks great on a desktop might be unusable on a small phone screen. This is where responsive design comes in.

Responsive design is the practice of building websites that adapt gracefully to different screen sizes.

CSS provides tools like media queries, flexible grids, and relative units to create responsive layouts. The goal is to provide a good user experience for everyone, regardless of their device. This often means rearranging elements, changing font sizes, or even hiding certain content on smaller screens.

HTML and CSS are the two core technologies for building web pages. HTML provides the raw structure and content, while CSS handles the presentation and layout. Mastering them is the first and most important step in becoming a web developer.

Quiz Questions 1/6

What is the primary role of HTML in web development?

Quiz Questions 2/6

True or False: HTML is considered a programming language because it uses tags to perform logic and calculations.