An HTML element is everything from the start tag to the end tag:
<p>My paragraph</p>
The start tag is <p>.
The content is the text in between.
The end tag is </p>; it has a forward slash.
Nested elements
Elements can contain other elements. In the example, <body> contains a heading and a paragraph, and the paragraph contains a <strong> element.
Empty elements
Some elements have no content and no end tag, such as <br> (line break) and <img>.
Never skip the end tag of a normal element. Browsers try to recover, but the result can be unpredictable.
💡 Key Takeaways: HTML Elements
Mastering HTML Elements helps you write clean and reliable HTML code. Follow standard conventions, test edge cases, and keep logic simple. Try running the code example below and complete the exercises to build confidence.
HTML Elements Code Example
HTML
<body>
<h1>Nested elements</h1>
<p>This paragraph has <strong>bold text</strong> inside it.<br>And this line comes after a line break.</p>
</body>
Free sign-in required · Google login available
HTML Elements Practice Exercises
Check what you learned in “HTML Elements”.
/ 3 solved
Fill in the blank
Close the paragraph element correctly.
<p>This is a paragraph.<>
✓ Correct!Not quite. Try again.
Multiple choice
Which element is an empty element (it has no end tag)?
✓ Correct!Not quite. Try again.
<br> inserts a line break and has no content, so it has no closing tag.
Code challenge
Make the word "important" bold by nesting a <strong> element inside the paragraph.
Write the code in the live editor. Your answer is checked automatically.