MyInternships.in

HTML Basics

HTML Elements

Everything you build in HTML is made of elements. This page explains exactly what an element is, how they nest, and which ones have no closing tag.


What is an HTML Element?

An HTML element is a complete piece of content marked up with tags. It normally consists of a start tag, the content, and an end tag. For example, in <h1>Hello</h1>, the whole thing — tags plus content — is the element.

Elements can contain other elements. This is called nesting, and it is how you build a page: a <body> contains paragraphs, a paragraph contains links, and so on. Correct nesting is essential.

Basic Usage

The anatomy of an element
Example
<p>This is a paragraph element.</p>

Example: Nested Elements

Elements inside elements
Example
<!DOCTYPE html>
<html>
<body>
  <div>
    <h2>A card title</h2>
    <p>Some text with a <a href="#">link</a> and <strong>bold words</strong>.</p>
  </div>
</body>
</html>

More Examples

Empty elements have no content
Example
<p>Line one<br>Line two on a new line.</p>
<hr>
<img src="https://picsum.photos/200" alt="Placeholder">
A list is a nested structure
Example
<ol>
  <li>First step</li>
  <li>Second step
    <ul>
      <li>A sub-point</li>
      <li>Another sub-point</li>
    </ul>
  </li>
</ol>

Common Elements at a Glance

ElementMeaningClosing tag?
<h1>-<h6>HeadingsYes
<p>ParagraphYes
<a>LinkYes
<img>ImageNo (empty)
<br>Line breakNo (empty)
<div>Generic containerYes
💡

Indent nested elements with two spaces per level. It makes the parent-child structure obvious and helps you spot missing closing tags.

⚠️

Never overlap elements. <b><i>text</b></i> is invalid — the inner <i> must close before the outer <b>.

Key Takeaways

  • An element is a start tag, content, and an end tag.
  • Elements nest inside one another to build a page.
  • Empty elements such as <img> and <br> have no closing tag.
  • Always close inner elements before outer ones.

Related HTML Topics

Keep learning with these closely related tutorials.

Ready to use your HTML skills?

Find web development internships and fresher jobs across India.

Browse Web Dev Internships