πŸŽ‰ New: Top 75 PHP Interview Questions for 2026 β€” Free for all learners

HTML Tags

P
php Guru
Β· February 18, 2023 Β· 3 min read Β· Updated February 18, 2023

πŸ“Œ Key Takeaways

  • HTML Tags
  • What Are HTML Tags
  • Syntax of HTML Tags
  • Simple HTML Tag Example
  • Types of HTML Tags
  • Paired Tags (Container Tags)
Advertisement

HTML Tags are the basic units used to create HTML elements.
They define how content is displayed in a web browser.

In this tutorial, you will learn what HTML tags are, types of tags, and see examples with output.

HTML tags, HTML tag examples, HTML basics, learn HTML tags, HTML syntax

What Are HTML Tags

HTML tags are keywords enclosed in angle brackets used to define elements.

They tell the browser:

  • How to display content
  • What type of content it is

Syntax of HTML Tags

Example

<tagname>Content</tagname>

Explanation

PartDescription
<tagname>Opening tag
</tagname>Closing tag
ContentText inside the tag

Simple HTML Tag Example

Example Code

<h1>This is a heading</h1>
<p>This is a paragraph</p>

Output

This is a heading
This is a paragraph


Types of HTML Tags

HTML tags are mainly divided into two types.

Types of Tags

TypeDescription
Paired TagsHave opening and closing tags
Unpaired TagsDo not have closing tags

Paired Tags (Container Tags)

These tags have both opening and closing parts.

Example

<p>This is a paragraph</p>

Output

This is a paragraph


Unpaired Tags (Empty Tags)

These tags do not have a closing tag.

Example

<br>
<hr>

Explanation

  • <br> creates a line break
  • <hr> creates a horizontal line

Output

Line 1
Line 2



Nested HTML Tags

Tags can be placed inside other tags.

Example Code

<p>This is <b>bold</b> text.</p>

Explanation

  • <b> is inside <p>
  • This is called nesting

Output

This is bold text.


Common HTML Tags

Frequently Used Tags

TagPurpose
<h1> to <h6>Headings
<p>Paragraph
<a>Link
<img>Image
<br>Line break
<hr>Horizontal line

HTML Tags Are Not Case Sensitive

Example

<H1>Hello</H1>
<h1>Hello</h1>

Output

Hello
Hello

Both are correct, but lowercase is recommended.


HTML Tags vs HTML Elements

Comparison Table

FeatureTagElement
DefinitionKeywordComplete structure
Includes ContentNoYes
Example<p><p>Text</p>

Rules for Using HTML Tags

Important Rules

RuleDescription
Proper ClosingClose tags correctly
Correct NestingAvoid overlapping tags
Use LowercaseBest practice
Use QuotesFor attributes

Common Mistakes with HTML Tags

MistakeResult
Missing closing tagBroken layout
Incorrect nestingErrors in display
Typing errorsTag not recognized
Using wrong tagsUnexpected output

HTML Tags Example with Multiple Elements

Example Code

<h1>HTML Tags Example</h1>
<p>This is a <i>simple</i> paragraph.</p>
<hr>

Output

HTML Tags Example
This is a simple paragraph.



Frequently Asked Questions (FAQ)

1. What are HTML tags?

HTML tags are keywords used to define elements.

2. What is a paired tag?

A tag with both opening and closing parts.

3. What is an unpaired tag?

A tag without a closing part.

4. Are HTML tags case-sensitive?

No, but lowercase is recommended.

5. What is the difference between tag and element?

A tag is part of an element, while an element is the complete structure.

P
php Guru
← Previous Post
HTML text Editors
Next Post β†’
HTML Elements

Leave a Reply

Your email address will not be published. Required fields are marked *

Prove your humanity: 8   +   10   =