HTML Elements

HTML elements are the building blocks of a webpage.
Every piece of content you see in a browser is part of an HTML element.


What Is an HTML Element?

An HTML element usually consists of:

<tagname>Content</tagname>

Example:

<p>This is a paragraph.</p>
  • <p> → opening tag
  • </p> → closing tag
  • Content → element content

Together, they form one HTML element.


Parts of an HTML Element

<a href="https://example.com" title="Example link" target="_blank">
  Visit Example
</a>

Element Breakdown

  • Tag namea
  • Attributeshref, title, target
  • ContentVisit Example

Empty HTML Elements

Some elements do not have closing tags.

Example:

<img 
  src="logo.png"
  alt="Website logo"
  width="150"
  height="80"
  loading="lazy">

Common empty elements:

  • <img>
  • <br>
  • <hr>
  • <meta>

Nested Elements

HTML elements can be placed inside other elements.

<p>
  This is <strong>important</strong> text.
</p>
  • <strong> is nested inside <p>
  • Proper closing order is required

Common HTML Elements Example

<section>
  <h2>About Us</h2>
  <p>We create simple and useful web content.</p>
  <a 
    href="/about.html"
    title="Read more about us"
    target="_self"
    rel="nofollow">
    Read More
  </a>
</section>

Attributes Used

  • href → link destination
  • title → tooltip text
  • target → link behavior
  • rel → relationship info

Important Notes

  • Most elements have opening and closing tags
  • Attribute values must be in quotes
  • Tags are written in lowercase
  • Elements must be properly nested

Why HTML Elements Matter

  • Define page structure
  • Improve accessibility
  • Help browsers understand content
  • Form the base for CSS and JavaScript