---
# System prepended metadata

title: Self-Closing Tags

---

# Understanding Self-Closing Tags in HTML

In HTML, **self-closing tags** are tags that don’t need a closing tag. These tags are primarily used for elements that don’t require content between opening and closing tags, such as images, line breaks, and more.

## What Are Self-Closing Tags?

Self-closing tags are useful for:
- Simplifying code
- Representing elements that perform a single function

### Examples of Common Self-Closing Tags:
- `<img />` – Displays images
- `<br />` – Inserts a line break
- `<hr />` – Inserts a horizontal line
- `<input />` – Creates form elements

## How I Used Self-Closing Tags in My Recipe Page

In my recipe page, I used the `<img />` tag to display an image of Spaghetti Bolognese. Here's how the code looks:

```html
<img src="https://images.pexels.com/photos/28575312/pexels-photo-28575312.jpeg" alt="Spaghetti Bolognese" width="700" />
```

### Other Examples of Self-Closing Tags You Can Use:

You can also use other self-closing tags like:

* `<br />` – Inserts a line break -->
* `<hr />` – Inserts a horizontal line -->

For example:

```html
<p>Here is a step-by-step guide:<br />First, boil the spaghetti.<br />Then, cook the beef.</p>
```

And to separate sections, you can use the horizontal rule tag:

`<hr />`

## Conclusion

Self-closing tags are an essential part of HTML that helps simplify code and represent elements that don’t require content.

