What is an HTML tag?
An HTML tag is an element of the HTML language that tells the browser exactly what to display on a web page and what role that element plays.
A tag indicates where a certain type of content begins and ends: for example, a paragraph, a heading, an image, or a link.
The structure of a tag
Most tags consist of an opening and a closing element:
<p>This is a paragraph of text.</p><p>is the opening tag, marking the start of the paragraph.</p>is the closing tag, marking the end.- Between them is the content of the element.
Single tags
Some tags do not require closing because they contain no text inside:
<img src="photo.jpg" alt="Photo">
<br>
<hr>Such tags are called self-closing: they perform an action (insert a picture, a line break, a line), but do not wrap content.
Tag attributes
Tags can have attributes that specify their behavior or appearance.
Attributes are written inside the opening tag in the format name="value".
Example:
<a href="https://example.com" target="_blank">Go</a>hrefis the link,target="_blank"opens it in a new tab.
Examples of tags and their purposes
| Tag | Purpose |
|---|---|
<h1>-<h6> | Headings of different levels |
<p> | A paragraph of text |
<a> | A link |
<img> | An image |
<div> | A container for blocks |
<span> | An inline container for text |
<ul> / <li> | Lists |
<table> | A table |
Summary:
| Concept | Meaning |
|---|---|
| Tag | A command for the browser describing the type of an element |
| Paired tag | Has an opening and a closing form |
| Single tag | Does not require closing |
| Attribute | An additional property of a tag |
In simple terms: HTML tags are the "labels" a page is made of. The browser reads them and understands: where the text is, where the image is, where the button is, and where the link is.
Short Answer
Interview readyA concise answer to help you respond confidently on this topic during an interview.