HTML Elements

Start tags, end tags, content and nesting.

✍️ 3 exercises + code challenge in this lesson

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.

Free sign-in required · Google login available

to save your exercise progress.
Finished this lesson?
Mark it complete to track your progress.

Stuck on something?

Ask the community in the CodesInTech forum.

Need a developer?

Learning on your own is great — and when you need professional help, our team builds custom software, websites and mobile apps for clients worldwide.

Explore Our Services