Ticker

6/recent/ticker-posts

why donot required closing tag empty element in html ?

Why donot required closing tag empty element in html ?

 The <br> tag is an example of a self-closing or empty element in HTML. These elements don't require a separate closing tag because they don't contain any content between an opening and closing tag pair.

In HTML, empty elements are typically used for elements that don't represent a container for other content but rather represent a standalone element or a simple line break, like the <br> tag. Other examples of empty elements in HTML include <img>, <input>, and <meta>.

The self-closing syntax <br> without a closing tag is sufficient to indicate the presence of a line break. Using a separate closing tag, like <br></br>, would be redundant and unnecessary.

There are certain elements in HTML that do not require a closing tag. These elements are referred to as "void elements" or "empty elements." They are designed this way because they don't contain any content within them and serve a specific purpose or provide a particular functionality.

➡️ The decision to make these elements self-closing without a separate closing tag was made to simplify the structure of HTML and maintain backward compatibility with older versions of HTML. Using a self-closing syntax for void elements helps ensure consistency and reduces redundancy in the markup.

➡️ Void elements, such as <br>, <img>, <input>, <hr>, and <meta>, are typically self-contained and do not require additional content or nesting. Their self-closing syntax, such as <br> or <img src="image.jpg">, clearly indicates their presence and purpose.

➡️ By not requiring a closing tag for void elements, the HTML syntax becomes more concise and easier to read. It also helps prevent errors that could occur if unnecessary closing tags were mistakenly included.

It's important to note that the decision to make certain elements void or self-closing is specific to the HTML language and its design principles. Other markup languages or programming languages may have different conventions regarding closing tags.

⬇️⬇️Video Tutorial⬇️⬇️


Post a Comment

0 Comments