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.

Discover how to embed and control graphics in our HTML Images tutorial.
* **Syntax:**
<img src="image-name.jpg" alt="Image description">

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.

6. HTML Attributes: Adding Superpowers to Tags

Most HTML tags can be enhanced with Attributes. Attributes provide extra information about elements and are always specified in the starting tag. They usually come in name/value pairs like name="value".

Common Attributes You Will Use Constantly:

Pro-Tip: Common Beginner Mistakes
1. Forgetting to close tags: Leaving off the </div> or </p> can break your entire layout.
2. Missing quotes on attributes: Always write class="btn" instead of class=btn. While browsers are forgiving, missing quotes can lead to unpredictable bugs later on.

7. The Power of Semantic HTML

In the early days of the web, developers built entire layouts using hundreds of <div> tags. Today, modern web development relies on Semantic HTML.

Semantic tags clearly describe their meaning to both the browser and the developer. This is incredibly important for Search Engine Optimization (SEO) and Accessibility (helping screen readers understand your page for visually impaired users).

Key Semantic Elements:

By using these tags instead of generic <div> elements, you instantly make your code cleaner, more professional, and easier for Google Search bots to read—which is a huge plus when trying to rank in search results!


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>
ev: introduction
xt: elements
mmary: "**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."