Lesson 2: HTML Elements
What is an HTML Element?
An HTML element is defined by a start tag, some content, and an end tag. The element is everything from the start tag to the end tag.
<tagname>Content goes here...</tagname>
Examples of HTML Elements
<h1>This is a heading</h1>
<p>This is a paragraph</p>
<a href="page.html">This is a link</a>
Nested Elements
HTML elements can be nested (elements can contain other elements):
<body>
<h1>My Website</h1>
<p>This is a <strong>paragraph</strong> with bold text.</p>
</body>
Important: Never skip the end tag! Some elements might display correctly even if you forget the end tag, but this can produce unexpected results or errors.
Empty Elements
Some HTML elements have no content and are called empty elements. They don't have an end tag:
| Element |
Description |
| <br> |
Line break |
| <hr> |
Horizontal line |
| <img> |
Image |
| <input> |
Input field |
HTML is Not Case Sensitive
HTML tags are not case sensitive: <P> means the same as <p>. However, it's best practice to use lowercase tags.