Skip to main content

What parts make up an HTML tag?

An HTML tag consists of three main parts: the tag name, attributes, and content (if the tag is paired).


1. The tag name

This is a keyword enclosed in angle brackets < > that defines which element to create.

Examples:

html
<p> - a paragraph <h1> - a heading <a> - a link <img> - an image

The tag name tells the browser how to interpret the content: as text, a link, an image, and so on.


2. Attributes (optional)

Attributes specify the behavior or appearance of an element. They are written inside the opening tag and consist of a pair: name="value"

Example:

html
<a href="https://example.com" target="_blank">Link</a>

Here:

  • href is the link address,
  • target="_blank" opens it in a new tab.

Attributes give a tag "settings", like function parameters in programming.


3. Content

This is what is located between the opening and closing tag: text, other tags, or elements.

Example:

html
<p>This is the paragraph's content.</p>
  • <p> is the opening tag,
  • </p> is the closing tag,
  • This is the paragraph's content. is the content.

The structure of a paired tag:

javascript
<name attribute="value">content</name>

Example:

html
<a href="https://example.com">Go</a>

The structure of a single (self-closing) tag:

javascript
<name attribute="value">

Example:

html
<img src="photo.jpg" alt="Photo">

Single tags contain no text and do not require closing.


Summary:

PartPurpose
Tag nameDefines the type of the element
AttributesSpecify behavior or properties
ContentWhat is shown to the user (if the tag is paired)

In simple terms: An HTML tag is like a container with a label (name), settings (attributes), and content. The browser reads these parts to understand exactly what to show and how it should work.

Short Answer

Interview ready
Premium

A concise answer to help you respond confidently on this topic during an interview.

What parts make up an HTML tag?: HTML Interview Question