Unlike normal tags, self-closing tags do not require a closing tag.
They are used for elements that do not enclose textual content.
These tags are often used to insert elements into the page, such as an image or a horizontal line, without needing to contain other elements or text.
The `<img>` tag to insert an image. It requires attributes like `src` (image source) and `alt` (alternative text for the image), but no closing tag.
Example code :
<img src="image.jpg" alt="Description of the image">
<img src="image.jpg" alt="Description of the image">
Another common example is the <br> tag for a line break.
Example code :
Here is a line.<br>
And here's a new line after the jump.
Here is a line.<br>
And here's a new line after the jump.
We use cookies to provide you with the best possible experience. They also allow us to analyze user behavior in order to constantly improve the website for you.