Introduction
Opening and closing tags tell the browser where an element starts and ends. They help organize content on a webpage.
Opening and closing tags tell the browser where an element starts and ends. They help organize content on a webpage.
<tagname>Content goes here</tagname>
<p>This is a paragraph.</p>
<h1>Welcome to my site</h1>
<div>Some content inside a container</div>
This example shows a heading, paragraphs, and a div container all using opening and closing tags to organize content.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Opening and Closing Tags Example</title> </head> <body> <h1>My First Heading</h1> <p>This is a paragraph inside opening and closing tags.</p> <div> <p>Another paragraph inside a div container.</p> </div> </body> </html>
Always match the opening and closing tag names exactly.
Some tags like <br> or <img> do not need closing tags; these are called self-closing tags.
Opening tags start an element, closing tags end it.
Tags must match to keep the webpage structure clear.
Using tags correctly helps browsers show your content properly.
<p> for a paragraph.</ followed by the tag name, then >. For paragraph, it is </p>.<p> is an opening tag. Self-closing syntax like <p/> is not valid for paragraphs. <endp> is not a valid HTML tag.<h1>Welcome</h1><p>Hello World</p>
<h1> creates a large heading, and <p> creates a paragraph below it.<div>Hello<p>World</div></p>
<div> opens first, then <p>. So </p> must close before </div>.</div> before </p>, which breaks proper nesting.<ul> contains list items <li>. Each <li> must have a matching closing tag </li>.<ul><li>Item 1</li><li>Item 2</li><li>Item 3</li></ul> closes every <li> with a matching </li>. Some options miss closing </li> tags, while another closes tags in the wrong order.Pass the test and this pattern moves unknown