Welcome to the world of Web Development! If you are just starting out, you might have heard that HTML is the first thing you need to learn. But what exactly is it, and how does it work?
In this guide, we’ll break down the building blocks of the web—Tags and Elements—so you can start building your own websites with confidence.
1. What is HTML and Why Do We Use It?
HTML (HyperText Markup Language) is not a programming language; it is a markup language.
Think of a webpage like a human body. HTML is the skeleton. It provides the structure. It tells the browser: "This is a heading," "This is a paragraph," or "This is an image." Without HTML, the browser wouldn't know how to organize the content you see on your screen.
2. What is an HTML Tag?
A Tag is like a command that tells the browser how to treat a piece of text. Tags are always wrapped in "angle brackets" like this: < >.
Most tags come in pairs:
Opening Tag (
<p>): Tells the browser where the instruction starts.Content: The actual text or data you want to show.
Closing Tag (
</p>): Tells the browser where the instruction ends. Notice the forward slash (/)—that’s the secret code for "stop."
3. Tag vs. Element: What’s the Difference?
People often use these words interchangeably, but there is a small, important difference:
The Tag: Is just the individual piece of code (like
<p>or</p>).The Element: Is the whole package. It includes the opening tag, the content inside, and the closing tag.
Analogy: If a "Tag" is a cardboard box, the "Element" is the box plus whatever you put inside it.
4. Self-Closing (Void) Elements
Not every tag needs a closing tag. Some elements don't contain any text; they just "exist" on the page to perform a specific function. These are called Void Elements.
Common examples:
<img>: For adding images.<br>: For a simple line break.<input>: For a text box where users can type.
You don't write <img></img>. You just write <img>.
5. Block-Level vs. Inline Elements
This is a crucial concept for layout. HTML elements behave in two main ways:
Block-Level Elements
These are "greedy" elements. They always start on a new line and take up the full width available (from left to right).
Examples:
<h1>to<h6>,<p>,<div>,<ul>.Think of them as bricks in a wall—one sits on top of the other.
Inline Elements
These are "polite" elements. They only take up as much width as necessary and do not start on a new line. They sit next to each other.
Examples:
<span>,<a>(links),<strong>(bold text).Think of them as words in a sentence—they sit side-by-side.
6. Commonly Used HTML Tags
Here are the "Essential Seven" tags you will use in almost every project:
<h1>to<h6>: Headings (1 is the biggest, 6 is the smallest).<p>: Paragraphs for your main text.<a>: Anchors (Links) to other pages.<img>: To display images.<ul>and<li>: For creating bulleted lists.<div>: A generic container used to group other elements (Block-level).<span>: A generic container for styling specific bits of text (Inline).
Pro Tip: Inspect the Web!
Want to see HTML in action? Right-click anywhere on this page and select "Inspect" (or press F12). You will see the "Elements" tab. This is the real-time skeleton of the website you are looking at!
Summary
HTML is the structure (skeleton) of the web.
Tags are the labels (
<p>).Elements are the whole unit (Tag + Content).
Block elements take the whole line; Inline elements share the line.
Now that you know the basics, you're ready to start coding your first page!
