An empty tag in HTML is an element that does not have any content between an opening tag and a closing tag. Instead, it is self-contained and typically does not require a closing tag. These tags are often used to insert elements that do not have any inner content, such as images or line breaks.
Examples of empty tags include:
-
<img>: Used to embed images.<img src="image.jpg" alt="Description of image" /> -
<br>: Inserts a line break.<p>This is a paragraph.<br>This is a new line.</p> -
<hr>: Creates a horizontal rule (line).<hr /> -
<input>: Used for form inputs.<input type="text" placeholder="Enter text here" />
In HTML5, it is common to use a self-closing syntax (e.g., <img />), but the closing slash is optional, so <img> is also valid.
