HTML Basics

Mastering HTML Basics: A Beginner’s Guide

HTML (HyperText Markup Language) is the foundation of the internet. It is the standard language used to structure web pages, telling your browser where to put text, images, and links. Over 95% of all websites use HTML, making it the most essential skill for any aspiring web developer.


1. The Core Structure of an HTML Document

Every webpage follows a specific "skeleton." Think of these tags as the containers that hold your content.

Essential Document Tags

Tag Description
<html> The "Root" element. Everything on the page lives inside this tag.
<head> The "Brain." Contains info not seen by users, like the page title and settings.
<title> Sets the name that appears on the browser tab.
<body> The "Content." Everything visible (text, images, videos) goes here.

Example Code:

<!DOCTYPE html>
<html lang="en">
<head>
    <title>My First Page</title>
</head>
<body>
    <p>Welcome to the world of web development!</p>
</body>
</html>

2. Organizing Content: Headings and Paragraphs

HTML Headings (<h1> to <h6>)

Headings create a hierarchy. Use <h1> for your main title and <h2> through <h6> for sub-sections.

Paragraphs and Line Breaks


3. Visual Separators and Images

The Horizontal Rule (<hr>)

Use the <hr> tag to create a thin horizontal line across the page. This is perfect for separating different topics or sections.

Adding Images (<img>)

To show an image, you use the src (source) attribute to tell the browser where the file is located.


4. Invisible Notes: HTML Comments

Comments are notes for yourself or other developers. Browsers ignore them, so they won't show up on the website.


5. How to "Peek" Behind the Scenes

You can learn a lot by looking at how professional websites are built!

  1. View Full Source: Press Ctrl + U (Windows) or Cmd + Option + U (Mac) to see the entire HTML file.
  2. Inspect Element: Right-click on any part of a webpage (like a button or image) and select "Inspect." This opens the Developer Tools, allowing you to see the specific code for that item.

Summary Checklist for Students

Exercise

?

Which HTML element acts as the container for all visible content on a webpage?

Example

<!DOCTYPE html>
<html lang="en">
<head>
    <title>My First Page</title>
</head>
<body>
    <h1>Hello World</h1>
    <p>Welcome to the world of web development!</p>
</body>
</html>