Content · Web Development · HTML

HTML Void Elements and Self-Closing Syntax

Some HTML elements do not wrap content and never have closing tags. Examples are img, br, hr, input, and meta. These are called void elements.

1 views Published Oct 19, 2026 Updated Oct 19, 2026 Admin

Some HTML elements do not wrap content and never have closing tags. Examples are img, br, hr, input, and meta. These are called void elements.

What You Need to Know


In HTML, the extra slash in <img /> does not make a different kind of element. Other elements, such as script or div, still need proper end tags even when empty.

Void elements such as img and br have no closing tag. An XML-style trailing slash does not make an ordinary HTML non-void element self-closing.

Example: See It in Action


Take a look at this small piece of HTML. You can use it in a practice document and change the text to make it your own.

This is a short HTML fragment. To try it as a webpage, put it inside the body element of a complete HTML document.

<section>
    <h2>Contact details</h2>
    <p>Write to us:<br>[email protected]</p>
    <img src="images/logo.png" alt="School logo">
</section>

Let’s Understand the Example


  • Section groups content around a shared topic and usually has a heading.
  • An h2 starts a major section beneath the page topic.
  • A p groups a paragraph of related text. Start another paragraph for a new thought.
  • Src tells the browser where to find an image or other embedded resource.
  • Alt supplies a text alternative for an image. Empty alt is appropriate for purely decorative images.

An image appears only if its file path is correct. If it is informative, its alt text should share the same useful meaning; if it is decoration, empty alt text is often right.

What Should You See?


The page should display “Contact details” as a heading, followed by its related content. Change the heading text and refresh the browser to see the result.

Read only the headings, from top to bottom. Do they tell a sensible story? If not, move sections or choose levels that match the content.

Try It Yourself


  1. Circle the void elements in the example and explain why the surrounding section still needs a closing tag.
  2. Save your changes, open or refresh the page, and compare the result with the original example.
  3. Tell a friend what your change did. If you are not sure, undo it, refresh the page, and compare.

Common Beginner Mistakes


  • Writing </img> or using <div /> and expecting it to close a div in HTML.
  • Avoid picking tags just for their default bold, italic or spaced appearance. Use CSS for presentation.

Key Takeaways


  • Some HTML elements do not wrap content and never have closing tags.
  • Section groups content around a shared topic and usually has a heading.
  • Void elements such as img and br have no closing tag. An XML-style trailing slash does not make an ordinary HTML non-void element self-closing.
Share this resourceSend this page to someone who may find it useful.