An HTML element includes a starting tag, some content, and an ending tag.
<tagname>Content here...</tagname>
<h1>Welcome Title</h1>
<p>This is a paragraph example.</p>
Start Tag | Content | End Tag |
---|---|---|
<h1> | Welcome Title | </h1> |
<p> | Paragraph text | </p> |
<br> | (no content) | (no end tag) |
Elements can be placed inside each other. This is called nesting.
<html>
<body>
<h1>Nested Title</h1>
<p>Nested paragraph.</p>
</body>
</html>
While some browsers still show content correctly if you forget the end tag, it’s always best to close your tags to avoid issues.
<p>Missing end tag
Some elements like <br>
don’t hold content and don’t need a closing tag.
This line breaks
right here using a <br>
tag.
These two tags are treated the same:
<P>Hello</P>
<p>Hello</p>