Skip to main content

Command Palette

Search for a command to run...

๐Ÿ—๏ธ HTML Basics: Understanding the Skeleton of Web Pages

Simple Steps to Mastering HTML Basics

Published
โ€ข9 min read
๐Ÿ—๏ธ HTML Basics: Understanding the Skeleton of Web Pages

Hey everyone! ๐Ÿ‘‹

So I just started learning web development last week, and honestly, I was SO confused at first. Like, what even is HTML? Why do we need it? But after spending some time with it, things finally started clicking for me, and I wanted to share what I learned in a way that might help other beginners like me.

This is literally going to be me explaining HTML like I'm talking to my friend who knows nothing about coding. No fancy jargon, just simple stuff!


What is HTML and Why Do We Use It?

Okay, so HTML stands for HyperText Markup Language. I know, I know - that sounds super technical and scary. But here's how my teacher explained it to me, and it finally made sense:

HTML is like the skeleton of a website.

Think about it - before you can dress up nicely or move around, you need bones to hold everything together, right? That's what HTML does for websites! It's the basic structure that holds everything in place.

When I asked "but why do we even need this?", here is what I learned:

  • It tells the computer what's a heading, what's a paragraph, what's a link, etc.

  • Every single website uses it - Google, YouTube, Instagram, EVERYTHING

  • Without HTML, we literally can't make websites

  • It is like the first step before making things pretty with CSS or interactive with JavaScript

๐Ÿ’ก Pro Tip: Every website you visit, from Google to YouTube to Instagram, uses HTML as its foundation. Right-click on any webpage and select "View Page Source" to see the HTML code!


What is an HTML Tag?

At first, I kept confusing what a "tag" was. Then someone explained it using boxes, and it all made sense.

Imagine you are moving to a new house and you are packing boxes. You had write "Kitchen Stuff" on one box, "Books" on another, "Clothes" on another, right?

That's exactly what HTML tags do!

They label what type of content you have. You wrap your content in these tags so the browser knows what it is.

Tags look like this:

<p>This is a paragraph</p>
<h1>This is a heading</h1>

See those < > brackets? That's how you write tags! Pretty simple once you get it.


Opening Tag, Closing Tag, and Content

Okay, this part confused me for like an hour, but then I got it. Most HTML tags have THREE parts:

Let me show you with an example:

<p>Hello, I'm learning HTML!</p>

Here's the breakdown:

1. Opening Tag: <p>
This is like saying "Hey browser, a paragraph is starting HERE!"

2. Content: Hello, I'm learning HTML!
This is the actual stuff you want to show on the page

3. Closing Tag: </p>
This is like saying "Okay browser, the paragraph ENDS here!"

See that / before the p in the closing tag? That's super important! I kept forgetting it at first and my code wouldn't work ๐Ÿ˜…

Here's a simple diagram :

Real Examples:

<!-- A heading -->
<h1>Welcome to My Website</h1>

<!-- A paragraph -->
<p>This is my first paragraph. I am learning HTML!</p>

<!-- A division (container) -->
<div>This is a container that can hold other elements</div>

<!-- A span (inline container) -->
<span>This is an inline container</span>

โš ๏ธ Common Mistake: Forgetting the closing tag! Always remember to close your tags. If you open with <p>, you must close with </p>.I spent 20 minutes debugging once because I forgot a closing tag ๐Ÿคฆโ€โ™‚๏ธ


Tag vs Element - Wait, They're Different?!

This one really confused me. I thought "tag" and "element" were the same thing. THEY ARE NOT!

Here's how I finally understood it:

Tags are the individual parts (the bookends)
Element is the WHOLE thing together

Think of it like shoes:

  • A tag is like one shoe (just the opening <p> or just the closing </p>)

  • An element is like both shoes on your feet (the complete thing: <p>content</p>)

Visual example:

So when someone says "add a paragraph element", they mean add the WHOLE thing with opening tag + content + closing tag!

I know it seems like a small difference, but understanding this helped me a lot when reading tutorials.


Self-Closing Tags (The Weird Ones)

Okay so this is where it gets a bit weird. Some tags don't need a closing tag!

I was like "wait what? I thought you said we always need to close tags??" But these are special. They are called self-closing tags or void elements.

Think of it like this:

  • Most tags are like doors (they open and close)

  • A doorbell button is just pressed once there is nothing inside it (like self-closing tags)

Common Self-Closing Tags:

TagWhat It DoesExample
<img>Displays an image<img src="photo.jpg" alt="My photo">
<br>Creates a line breakLine one<br>Line two
<hr>Creates a horizontal line<hr>
<input>Creates an input field<input type="text" placeholder="Name">
<meta>Provides metadata about the page<meta charset="UTF-8">
<link>Links external resources<link rel="stylesheet" href="style.css">

๐Ÿ’ก Remember: Self-closing tags don't need content, so they don't have closing tags. You can't put anything "inside" an image tag or a line break tag!


Block vs Inline - The Layout Thing That Clicked For Me

This was probably the hardest concept for me to understand at first, but once I got it, SO MANY THINGS made sense!

There are two main ways HTML elements behave:

Block Elements (The Stackers)

Block elements are like Lego blocks stacked on top of each other. Each one takes up the full width and the next one goes below it.

Common Block-Level Elements:

  • <div> - A generic container for grouping content

  • <p> - Paragraph

  • <h1> to <h6> - Headings (largest to smallest)

  • <ul> and <ol> - Lists

  • <header>, <footer>, <section> - Semantic containers

Inline Elements (The Flow-ers)

Inline elements are like words in a sentence - they flow next to each other!

Common Inline Elements:

  • <span> - A generic inline container

  • <a> - Links (anchor tags)

  • <strong> - Bold text

  • <em> - Italic text

  • <img> - Images (technically inline)

  • <button> - Buttons

Here's a real example that helped me understand:

<!-- Block elements stack -->
<div>First box</div>
<div>Second box</div>
<div>Third box</div>

<!-- Inline elements flow -->
<p>This is <span>inline text</span> in a sentence.</p>

๐Ÿ’ก Quick Rule: Block elements are like Lego bricks stacked vertically. Inline elements are like words in a sentence flowing horizontally.


The Tags I Actually Use

Okay, now let me show you the tags I actually use when making web pages. I'm not gonna list like 50 tags because that's overwhelming. These are the ones I use literally every time:

Heading Tags (h1 to h6)

Headings help organize your content. <h1> is the biggest and most important, while <h6> is the smallest.

<h1>Main Heading</h1>
<h2>Subheading</h2>
<h3>Smaller heading</h3>
<h4>Even smaller</h4>
<h5>Getting smaller</h5>
<h6>Smallest heading</h6>

Paragraph Tag (p)

Use <p> for paragraphs of text.

<p>This is a paragraph. It can contain multiple sentences and will display as a block of text.</p>

Division Tag (div)

The <div> is a container used to group other elements together. It's like a box that holds other content.

<div>
    <h2>A Section Title</h2>
    <p>Some paragraph text in this section.</p>
</div>

Span Tag (span)

The <span> is an inline container, perfect for styling part of a text.

<p>This is <span>highlighted text</span> in a paragraph.</p>

The anchor tag <a> creates clickable links.

<a href="https://www.google.com">Click here to visit Google</a>

Image Tag (img)

Display images using the <img> tag (self-closing).

<img src="photo.jpg" alt="Description of the image">

List Tags (ul, ol, li)

Create unordered (bullet) lists or ordered (numbered) lists.

<!-- Unordered list (bullets) -->
<ul>
    <li>First item</li>
    <li>Second item</li>
    <li>Third item</li>
</ul>

<!-- Ordered list (numbers) -->
<ol>
    <li>First step</li>
    <li>Second step</li>
    <li>Third step</li>
</ol>

Button Tag (button)

Create clickable buttons.

<button>Click Me!</button>

Input Tag (input)

Create input fields for forms (self-closing).

<input type="text" placeholder="Enter your name">
<input type="email" placeholder="Enter your email">
<input type="password" placeholder="Enter password">

Text Formatting Tags

<strong>Bold text</strong>
<em>Italic text</em>
<u>Underlined text</u>
<mark>Highlighted text</mark>

Complete Example

Here's a simple webpage using all these tags together:

<!-- A complete simple webpage -->
<div>
    <h1>Welcome to My Website</h1>

    <p>This is my <strong>first webpage</strong>. I'm learning HTML!</p>

    <h2>My Hobbies</h2>
    <ul>
        <li>Reading books</li>
        <li>Playing guitar</li>
        <li>Coding websites</li>
    </ul>

    <img src="my-photo.jpg" alt="My photo">

    <p>
        Visit my <a href="https://github.com">GitHub profile</a>
    </p>

    <button>Contact Me</button>
</div>

๐Ÿ” Try This Yourself! Open any website, right-click on it, and select "Inspect" or "View Page Source." You'll see all the HTML code that makes up that page. This is a great way to learn by seeing how real websites are built!


Mistakes I Made (So You Don't Have To!)

Let me be real with you - I made SO MANY mistakes. Here are the common ones:

โŒ Forgetting closing tags
I'd write <p>Some text and wonder why my page looked weird. Always close your tags!

โŒ Not using proper nesting

<!-- WRONG -->
<div><p>Text</div></p>

<!-- RIGHT -->
<div><p>Text</p></div>

โŒ Forgetting the alt on images
Screen readers need this! It's important for accessibility.


Quick Reference Table

TagTypePurpose
<h1> to <h6>BlockHeadings (largest to smallest)
<p>BlockParagraph of text
<div>BlockGeneric container
<span>InlineInline container
<a>InlineHyperlink
<img>Inline (self-closing)Image
<ul> / <ol>BlockUnordered / Ordered list
<li>BlockList item
<button>InlineClickable button
<input>Inline (self-closing)Form input field
<strong>InlineBold text
<em>InlineItalic text
<br>Inline (self-closing)Line break
<hr>Block (self-closing)Horizontal line

๐ŸŽ‰ Congratulations!

You've just learned the foundation of web development! You now understand:

โœ… What HTML is and why it's the skeleton of webpages
โœ… How tags and elements work
โœ… The difference between block and inline elements
โœ… Many commonly used HTML tags

Remember: Every expert was once a beginner. Keep practicing, keep building, and most importantly, have fun creating amazing things on the web! ๐Ÿš€

Happy coding! ๐Ÿ’ป (Wow, I sound like a real developer now ๐Ÿ˜‚)