# HTML for Beginners: Understanding the Basics

# HTML

If you want to build websites, there is one language you absolutely must learn first is HTML.

Before you worry about making things look pretty with colors and fonts (that’s CSS) or making things interactive (that’s JavaScript), you need structure.

## What is HTML?

HTML stands for **HyperText Markup Language**. It is not a programming language in the traditional sense (like Python or Java); it is a markup language.

Think of a webpage like a human body.

* HTML is the skeleton. It provides the essential structure and holds everything together. Without bones, a body is just a shapeless blob. Without HTML, a website is just a shapeless blob of unformatted text.
    
* CSS would be the skin, hair, and clothing (the style).
    
* JavaScript would be the muscles and brain (the movement and logic).
    

We use HTML to tell a web browser (like Chrome or Safari) what different parts of content are. We tell the browser, "This text is a main heading," "This block is a paragraph," and "This part is an image."

## HTML Tags

How do we tell the browser what something is? We use **tags**.

Imagine you are moving house and packing boxes. You wouldn't just throw everything into unlabeled boxes. You write labels on them: "Kitchen," "Books," "Bedroom."

HTML tags are those labels for your content. They are keywords surrounded by angle brackets: `<` and `>`.

### The Structure of a Tag

Most HTML elements follow a simple "sandwich" structure:

1. **An Opening Tag:** This marks the beginning of an element. It tells the browser, "Hey, a specific type of content starts here." (e.g., `<p>`)
    
2. **The Content:** The actual text, image, or other data goes here.
    
3. **A Closing Tag:** This marks the end. It looks just like the opening tag but has a forward slash (`/`) before the keyword. (e.g., `</p>`)
    

Here is a real example used for a paragraph of text:

```xml
<p>This is a paragraph of text.</p>
```

* `<p>` tells the browser: "Start a paragraph here."
    
* `This is a paragraph of text.` is the content displayed on the screen.
    
* `</p>` tells the browser: "End the paragraph here."
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1769702903450/73261baa-b071-4e54-be43-b1fc05549b5e.png align="center")

## Tag vs. Element: What’s the Difference?

As you learn, you will hear the words "tag" and "element" used interchangeably, but there is a slight difference.

* A Tag is just the part inside the angle brackets (e.g., `<p>` is a tag).
    
* An Element is the complete package: the opening tag, the content *inside*, AND the closing tag.
    

Think of it like a sandwich. The bread pieces are the tags. The whole thing bread, lettuce, tomato, and cheese together is the element.

## Self-Closing Elements

Most elements have content inside them, so they need a closing tag to know where that content ends.

However, some elements don't hold text. They just *are*. These are called self-closing or void elements. Because they don't have content inside, they don't need a closing tag.

A perfect example is a line break, which just forces text to drop to the next line. The tag is `<br>`.

```xml
<p>First line.<br>Second line.</p>
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1769702938170/7614af13-921f-49fb-969f-297ab46079f8.png align="center")

Another common one is an image (`<img>`). You don't put text *inside* an image tag; you just tell the browser where the image file sits.

## Block vs. Inline

When you put elements on a page, they generally fall into two categories based on how they arrange themselves: **Block-level** and **Inline**.

### 1\. Block-level Elements

Imagine these elements are greedy; they want the whole line to themselves.

* They always start on a new line.
    
* They stretch out to take up the full available width of the page (from left to right).
    

**T**hink of paragraphs in a book. Each new paragraph starts on a fresh line.

*Examples:* Headings (`<h1>`), Paragraphs (`<p>`), and dividers (`<div>`).

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1769703000806/bf351f4a-c77d-4d8f-9d33-6bfac4565810.png align="center")

### 2\. Inline Elements

These elements are cooperative. They only take up as much width as they need.

* They do *not* start on a new line.
    
* They sit next to other inline elements on the same line.
    

Think of bolding or highlighting a single word within a sentence. The highlighted word doesn't jump to a new line; it stays right there in the flow of text.

*Examples:* Spans (`<span>`), links (`<a>`), or emphasized text (`<em>`).

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1769703052287/39efc0ec-35f7-4bc0-9354-69bd9813c090.png align="center")

  
Here is a visual comparison:

```xml
<div>I am a block box.</div>
<div>I am another block box below it.</div>

<p>This is a paragraph with a <span>small inline span</span> inside it.</p>
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1769703085016/8b13d4de-932d-45fd-8363-5297c54cd655.png align="center")

## Common HTML Tags

You don't need to memorize hundreds of tags to start. You can build a lot with just these four:

### 1\. Headings (`<h1>` to `<h6>`)

These are block-level tags used for titles and subtitles. `<h1>` is the most important (usually the main page title), and `<h6>` is the least important.

```xml
<h1>Main Title</h1>
<h2>Section</h2>
<h3>Sub Section</h3>
<h4>Topic</h4>
<h5>Sub Topic</h5>
<h6>Note</h6>
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1769703167048/ca9a60f2-86dc-44b9-af72-d5c4445aaf56.png align="center")

### 2\. Paragraphs (`<p>`)

This is the standard block-level tag for regular blocks of text.

```xml
<p>Welcome to my first webpage. I am learning HTML!</p>
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1769703197270/22db7b8b-72b7-4fc5-8cd8-3ea0a92c11c2.png align="center")

### 3\. Division (`<div>`)

The `<div>` is a generic block-level container. It doesn't have a specific meaning on its own. Think of it as a plain cardboard box used to group other elements together for layout purposes.

```xml
<div>
  <h2>Grouped Section</h2>
  <p>This heading and paragraph are inside a div container.</p>
</div>
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1769703252511/565d12aa-e851-4ff9-8c08-455c9e290cc4.png align="center")

### 4\. Span (`<span>`)

The `<span>` is the inline version of a div. It's a generic container used to wrap small pieces of text *within* a larger block, usually to target them later with CSS colors or styles.

```xml
<p>My favorite color is <span>blue</span>.</p>
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1769703291758/28ff6c66-9083-402e-b58b-c79c3ec45f4a.png align="center")

### 5\. Links (`<a>`)

Used to navigate to another page or website.

```xml
<a href="https://google.com">Go to Google</a>
```

You can also open links in a new tab:

```xml
<a href="https://google.com" target="_blank">Open Google</a>
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1769704272933/9817f083-02ea-43b3-bfa4-41413fcac021.png align="center")

### 6\. Images (`<img>`)

Used to display images on the webpage. It is a self-closing tag.

```xml
<img src="cat.jpg" alt="A cute cat" />
```

* `src` → image path
    
* `alt` → text shown if image fails(important for accessibility)
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1769704528251/2cf785cd-4e59-4fdf-a569-6a80a66ee058.png align="center")

### 7\. Lists

Unordered List

```xml
<ul>
  <li>HTML</li>
  <li>CSS</li>
  <li>JavaScript</li>
</ul>
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1769704731793/6fb3cd86-2e3c-44bc-ab11-9fc2fc36cc59.png align="center")

Ordered List

```xml
<ol>
  <li>Install VS Code</li>
  <li>Learn HTML</li>
  <li>Build projects</li>
</ol>
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1769704756104/b0fb9290-9e08-4ca6-befc-f54f3b8239f2.png align="center")

### 8\. Buttons (`<button>`)

Used for actions like submit, click, open modal, etc.

```xml
<button>Click Me</button>
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1769704951001/17077948-ebaf-464d-855c-0084ff3f1b87.png align="center")

### 9\. Input (`<input>`)

Used to take user input.

```xml
<input type="text" placeholder="Enter your name" />
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1769704979254/292b13de-7bfd-49dc-a00c-3f7aa58a8523.png align="center")

Other common types:

```xml
Password<input type="password" />
Email<input type="email" />
CheckBox<input type="checkbox" />
Radio<input type="radio" />
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1769705156042/02627c5e-5dca-4689-8df3-ca01d50b5888.png align="center")

### 10\. Forms (`<form>`)

Used to collect and submit user data.

```xml
<form>
  <input type="text" placeholder="Username" />
  <button>Submit</button>
</form>
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1769705208285/1a54194e-cc55-49e0-bbfa-6d5b111cfc04.png align="center")

## Semantic Layout Tags

These help browsers, SEO, and screen readers understand your layout.

```xml
<header>Top section of page</header>
<nav>Navigation links</nav>
<main>Main content</main>
<section>Page section</section>
<article>Blog post or card</article>
<aside>Side content (tips, ads, related links)</aside>
<footer>Bottom of page</footer>
<mark>Highlighted important text</mark>
```

Example:

```xml
<header>
  <h1>My Blog</h1>
</header>

<main>
  <article>
    <h2>First Post</h2>
    <p>Hello <mark>world</mark>!</p>
  </article>

  <aside>
    <p>Tip: Use semantic tags for better SEO and accessibility.</p>
  </aside>
</main>

<footer>
  © 2026
</footer>
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1769708084239/87defdcb-0c42-4e04-b6ed-89f34a124655.png align="center")

### ☕ Tea & Advice

The best way to learn HTML is to look at how others do it.

On almost any website (including this one!), you can right-click on any part of the page and select **"Inspect"** or **"Inspect Element." or** `ctrl + shift + I`

A panel will open at the bottom or side of your browser showing you the actual HTML skeleton of that page. Don't worry if it looks complicated right now, just try to spot the tags you just learned, like `<div>`, `<p>`, or `<h1>`.  
  
Welcome to the world of web development!  

To uncover more secrets about the invisible infrastructure powering your daily life, be sure to read my full series on **The Internet**.

**Check out the full series:** [**The Internet by Satpalsinh Rana**](https://blogs.satpal.cloud/series/internet)
