Skip to main content

Command Palette

Search for a command to run...

Beginner's Guide: How HTML Actually Work๐Ÿ—๏ธ

Published
โ€ข7 min read
Beginner's Guide: How HTML Actually Work๐Ÿ—๏ธ

By, Parth Kumbhar


Introduction

Ever find yourself staring at a website and thinking, "How does this thing actually manage to stand up?" ๐Ÿคฏ

Imagine a webpage like a human body.

  • HTML is the skeleton ๐Ÿ’€. It provides the structure (headings, paragraphs, images).

  • CSS is the skin and clothes ๐Ÿ‘•. It makes the skeleton look good (colors, fonts, layout).

  • JavaScript is the brain and muscles ๐Ÿง . It makes the page move and do things.

Today, we are going to concentrate solely on the skeletonโ€”HTML. We are going to address the biggest confusion for newbies: the difference between a Tag and an Element.


1. What is HTML?

Think of a Tag as a set of instructions for the browser. You are telling the browser: "Hey! The stuff I'm about to type is a Heading," or "Treat this text as a link."

Most tags come in pairs:

  1. Opening Tag (<p>): Tells the browser where the effect starts.

  2. Closing Tag (</p>): Tells the browser where the effect ends (always has a forward slash /).


2. Tag vs. Element: What's the difference? ๐Ÿค”

People often use these words interchangeably, but there is a slight difference:

TermWhat it isExample
TagThe individual "labels" or markers.<p> or </p>
ContentThe actual text or image inside the tags.Welcome to my blog!
ElementThe whole package (Tags + Content).<p>Welcome to my blog!</p>

Think of it like a sandwich:

  • The Tags are the slices of bread ๐Ÿž.

  • The Content is the cheese and ham ๐Ÿง€.

  • The Element is the entire sandwich! ๐Ÿฅช


4. The "Loners": Self-Closing (Void) Elements ๐ŸŒต

Some elements are "lonely"โ€”they don't need a closing tag because they don't wrap around any text. They just perform a single job.

Think of an Image. You don't put text "inside" an image; the image is the content.

The most common "loners" include:

  • <img>: Displays a picture.

  • <br>: Forces the text to jump to a new line (a "Line Break").

  • <hr>: Draws a horizontal line across the page to separate sections.

5. Block vs. Inline: The "Subway Seat" Rule ๐Ÿš‡

This is the most important concept for layout!

A. Block-Level Elements (The Greedy Ones) ๐Ÿงฑ

These elements are like someone sitting on a subway bench and putting their bags on the seats next to them. They take up the entire width of the page, even if they don't need it.

  • Examples: <div>, <h1>, <p>, <ul>.

  • Behavior: They always start on a brand-new line.

B. Inline Elements (The Polite Ones) ๐Ÿƒ

These elements only take up as much space as their content needs. They are happy to sit side-by-side with others.

  • Examples: <span>, <a>, <strong>.

  • Behavior: They stay on the same line as the text around them.


Sample HTML Code

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>My First Web Structure ๐Ÿ—๏ธ</title>
</head>
<body>

    <header>
        <h1>Welcome to My Awesome Blog!</h1>
        <p>Learning HTML is easier than you think. ๐Ÿ˜‰</p>
        <hr> </header>

    <main>
        <section>
            <h2>1. About Me</h2>
            <p>I am a <strong>Student Developer</strong> learning the <em>skeletal structure</em> of the web.</p>
            <p>Today, I've learned that <code>&lt;div&gt;</code> is a block element!</p>
        </section>

        <section>
            <h2>2. My Favorite Tech</h2>
            <ul>
                <li>HTML5 for Structure</li>
                <li>CSS3 for Styling</li>
                <li><a href="https://hashnode.com">Hashnode</a> for Blogging!</li>
            </ul>
        </section>

        <section>
            <h2>3. Comparison Table</h2>
            <table border="1">
                <tr>
                    <th>Tag Type</th>
                    <th>Example</th>
                    <th>Personal Space</th>
                </tr>
                <tr>
                    <td>Block</td>
                    <td>&lt;div&gt;</td>
                    <td>Greedy (takes full width)</td>
                </tr>
                <tr>
                    <td>Inline</td>
                    <td>&lt;span&gt;</td>
                    <td>Polite (shares the line)</td>
                </tr>
            </table>

            <br> <h3>Cool Image:</h3>
            <img src="https://via.placeholder.com/150" alt="Placeholder Image">
        </section>

        <section>
            <h2>4. Say Hello!</h2>
            <form>
                <label for="name">Name:</label>
                <input type="text" id="name" placeholder="Enter your name">
                <button type="button">Submit</button>
            </form>
        </section>
    </main>

    <hr>
    <footer>
        <p>&copy; 2026 My Coding Journey</p>
    </footer>

</body>
</html>

Output โ†’


Power Move: Use Your "X-Ray Vision" ๐Ÿฆธโ€โ™‚๏ธ

Did you know you can see the skeleton of any website?

  1. Go to a site like Google or Instagram.

  2. Right-click on a button or a heading.

  3. Select "Inspect".

  4. Boom! Youโ€™re looking at the raw HTML. Hover over the code, and youโ€™ll see the Block and Inline boxes light up in blue and orange.


The Master HTML Tag Cheat Sheet ๐Ÿ“œ

CategoryTagWhat it doesLife Example ๐Ÿ Type
Foundation<html>The container for the whole page.The entire property/land.Block
Foundation<head>Holds "hidden" info (CSS links, Metadata).The ID Card of the house.N/A
Foundation<body>Everything visible to the user goes here.The inside of the house.Block
Text<h1> - <h6>Headings (H1 is biggest, H6 smallest).Newspaper headlines.Block
Text<p>Standard paragraph text.A paragraph in a book.Block
Text<blockquote>For long quotes from other sources.A "pull-quote" in a magazine.Block
Text<br>A single line break.Hitting "Enter" once.Inline
Text<hr>A horizontal line separator.A physical divider on a page.Block
Formatting<strong>Makes text bold (and important).Shouting a keyword.Inline
Formatting<em>Makes text italic (emphasis).Saying something with flair.Inline
Formatting<code>For displaying computer code.A snippet in a manual.Inline
Links<a>The "Anchor" - creates a link.A teleportation portal.Inline
Lists<ul>An unordered (bulleted) list.A grocery list.Block
Lists<ol>An ordered (numbered) list.Steps in a recipe.Block
Lists<li>A single list item.One item on the list.Block
Media<img>Embeds an image.A picture in a frame.Inline
Media<video>Embeds a video player.A TV screen.Inline
Media<audio>Embeds a sound player.A radio or MP3 player.Inline
Containers<div>A generic container for grouping.A big moving box.Block
Containers<span>A container for small text parts.A sticky note on a page.Inline
Tables<table>Creates a data table.An Excel spreadsheet.Block
Tables<tr>A table row.A horizontal line in Excel.Block
Tables<th>A table header cell.The bold title in a column.Block
Tables<td>Standard table data cell.A single cell in Excel.Block
Forms<form>A container for user input.A physical job application.Block
Forms<input>A field where users type or click.A blank line to write on.Inline
Forms<label>The text description for an input.A "Name:" sticker.Inline
Forms<button>A clickable button.An "Eject" or "Submit" button.Inline
Forms<textarea>A large box for long text/comments.A "Comments" section.Inline
Semantic<header>The top section of a page or article.The roof of the house.Block
Semantic<footer>The bottom section (copyright, etc.).The basement/foundation.Block
Semantic<nav>A set of navigation links.A directional signpost.Block

โœ๏ธ Written By, Parth Kumbhar

๐Ÿ’ป Web Developer | CS Btech Student

๐ŸŒฑ Learning, building, and sharing tech every day


๐Ÿ”— Connect with me

Linkedin : Parth's Linkedin