DEV Community

S Sarumathi
S Sarumathi

Posted on

Tags in HTML

A tag is a keyword enclosed in angle brackets < > that tells the browser how to display the content.

  • Opening tag → <tag name>

  • Closing tag → </tag name>

Example

<p>This is a paragraph.</p>

Enter fullscreen mode Exit fullscreen mode

Types of HTML Tags

1.Paired Tags (Container Tags)

2.Unpaired Tags (Empty / Self-Closing Tags)

  • Paired Tags (Container Tags)

These tags always come in pairs — an opening tag and a closing tag.

Syntax:
<tagname>Content</tagname>

Example:

<h1>Welcome to HTML</h1>
<p>This is a paragraph.</p>

Enter fullscreen mode Exit fullscreen mode
  • Unpaired Tags (Empty / Self-Closing Tags)

    • These tags do not need a closing tag.
    • They are used to insert elements that don’t wrap around any content.

Syntax:
<tagname />

Example:

<br>     <!-- Line Break -->
<hr>     <!-- Horizontal Line -->
<img src="image.jpg" alt="My Image">  <!-- Image Tag -->

Enter fullscreen mode Exit fullscreen mode

Top comments (0)