SA-21/06, C-11, Asapur, Varanasi, UP support@kamaldnp.com +91 8318013442
HTML
1. HTML Introduction: What is HTML? Learn with Examples 2. Best Free HTML Editors: Notepad to VS Code for Beginners 3. HTML Basic Structure: Doctype, Head, Body Explained 4. HTML Elements Explained: Tags, Content & Empty Elements 5. HTML Attributes List: href, src, alt, width, title & More 6. HTML Headings h1 to h6: Which Heading Tag to Use When 7. HTML Paragraphs: p Tag, br Line Breaks & pre Text 8. HTML Style Attribute: Colour, Font Size & Alignment 9. HTML Text Formatting Tags: bold, italic, mark & More 10. HTML Comments: How to Add Notes & Hide Code in HTML 11. HTML Colors: Names, HEX, RGB & HSL Colour Codes 12. HTML CSS: Inline, Internal & External Stylesheets 13. HTML Links: a Tag, href, New Tab & Email Links 14. HTML Images: img Tag, src, alt, Width & Formats 15. HTML Favicon: Create & Add a Browser Tab Icon 16. HTML Title Tag: How to Write a Good Page Title 17. HTML Tables: table, tr, th, td, colspan & rowspan 18. HTML Lists: ul, ol, dl & Nested Lists Explained 19. HTML Block vs Inline Elements: div, p, span Explained 20. HTML Div Tag: Group Content & Build Page Layouts 21. HTML Class Attribute: Style Many Elements at Once 22. HTML id Attribute: Unique IDs, Links, CSS & JavaScript 23. HTML Iframes: Embed YouTube, Maps & Pages in HTML 24. HTML JavaScript: script Tag, Clicks & First Example 25. HTML File Paths: Relative vs Absolute Paths Explained 26. HTML Head Element: title, meta, charset & viewport 27. HTML Layout: header, nav, main, footer Page Structure 28. HTML Responsive Design: Viewport, Images & Media Queries 29. Semantic HTML Tags: header, nav, main, article & footer 30. HTML Forms: input, label, select, checkbox & Submit 31. HTML Entities: & < > © with Examples 32. HTML Audio & Video Tags: controls, source & Fallback 33. HTML Accessibility: alt Text, Labels, Landmarks & ARIA 34. HTML Meta Tags & SEO: charset, viewport, OG Tags 35. HTML Quotations: blockquote, q, cite, abbr & address
Final Test — Certificate ₹10
Try this code live
Lesson 4 of 35

HTML Elements Explained: Tags, Content & Empty Elements

3 min read · Free · No login needed

An HTML element is everything from the start tag to the end tag, including the content in between. For example, <p>Hello</p> is one complete element: <p> is the start tag, Hello is the content, and </p> is the end tag.

Diagram — see how it fits together
Diagram: parts of an HTML element

Tags are not elements

People often mix up the two words. A tag is just the bracketed name, like <h1>. An element is the whole thing — start tag, content, and end tag together. So <h1>Welcome</h1> is an element; <h1> alone is only a tag.

Empty elements

Some elements have no content and no end tag. They are called empty elements. The most common ones are:

  • <br> — a line break
  • <hr> — a horizontal line
  • <img> — an image
  • <input> — a form field

Nesting

Elements can sit inside other elements. This is called nesting. The inner element must close before the outer one does. Correct: <p>This is <strong>important</strong> text.</p>. Wrong: <p>This is <strong>important</p></strong> — the tags cross over, and browsers may show the page wrongly.

Tip: Browsers are forgiving — they will still show a page with broken nesting. But forgiving does not mean correct. Clean nesting keeps your pages predictable.

What an element is, in one line

An element is a complete unit: a start tag, the content between the tags, and an end tag. The tag is only the bracket part — <p> is a tag, but <p>Hello</p> is an element. Tags mark the start and the end; the element is the whole thing, content included.

Syntax

<tagname>Content goes here</tagname>

Here are two elements side by side. The first is a paragraph element with text inside. The second is an empty element — it has no content and no end tag.

<p>This is a paragraph element.</p>
<br>
Note: Empty elements like <br>, <hr>, and <img> never have an end tag. You will sometimes see them written as <br /> with a slash — that is allowed, but the slash is optional in HTML5.
Tip: When you nest elements, close them in the opposite order you opened them — the last tag opened is the first one closed. Think of boxes inside boxes: you close the inner box before the outer one.

Common mistakes

  • Writing tags in capital letters, like <P> — HTML allows it, but small letters are the standard and every professional uses them.
  • Overlapping tags, like <b><i>text</b></i> — always close the inner tag first.
  • Forgetting the slash in the end tag, like writing <p> twice instead of <p>...</p>.
  • Adding an end tag to an empty element, like <br></br> — <br> never takes one.

Example explained

  • <!DOCTYPE html>, <html>, <head> and <title>Elements</title> — the usual page skeleton. The title appears on the browser tab; the head stays invisible.
  • <p>This is a <strong>paragraph</strong> element.</p> — nesting in action. The <strong> element sits inside the paragraph element, and it closes before the paragraph closes.
  • <p>Line one<br>Line two</p> — the <br> is an empty element with no end tag. It breaks the line without starting a new paragraph.
  • <hr> — another empty element. It draws a horizontal line across the page and separates one topic from the next.
  • <p>Text after a horizontal line.</p> — a normal paragraph element: start tag, text, end tag.

Example

Example
<!DOCTYPE html>
<html>
<head>
<title>Elements</title>
</head>
<body>

<p>This is a <strong>paragraph</strong> element.</p>
<p>Line one<br>Line two</p>
<hr>
<p>Text after a horizontal line.</p>

</body>
</html>

Output

Output — how it looks in the browser
Output of HTML Elements Explained: Tags, Content & Empty Elements

Try it yourself — live editor

Change the code below and press Run to see the result instantly. No file to save, no login needed.

Result

Frequently asked questions

The questions learners ask most about this lesson — read the question, then open it to see the answer.

1. What is an HTML element?

An element is everything from the start tag to the end tag, including the content in between, for example a paragraph element with the text Hello inside.

2. What is the difference between a tag and an element?

A tag is just the bracketed name, like h1. An element is the whole thing: start tag, content, and end tag together.

3. What is an empty element?

An element with no content and no end tag. Common examples are br for a line break, hr for a horizontal line, and img for an image.

Check yourself — did you get it?

Finished the lesson? Test yourself with 5 quick questions — you get the answer instantly, with the reason for each one.

1. What is an HTML element?

An element is the whole thing — start tag, content and end tag together. <p>Hello</p> is one complete element.

2. Which of these is an empty element?

<br> has no content and no end tag — it is an empty element. <p>, <h1> and <strong> all need end tags.

3. What is nesting?

Elements can sit inside other elements — that is nesting. The inner element must close before the outer one does.

4. Which nesting is correct?

Close tags in the opposite order you opened them — the last tag opened is the first one closed.

5. What is the difference between a tag and an element?

<h1> alone is only a tag. <h1>Welcome</h1> — start tag, content and end tag — is an element.

Interview questions — can you answer these?

Read the question first, try to answer it in your own words, then open it to check. These are the questions interviewers actually ask.

1. What is the difference between a tag and an element?

A tag is just the bracketed name, like <h1>. An element is the whole thing — start tag, content and end tag together. <h1>Welcome</h1> is an element; <h1> alone is only a tag.

2. What is an empty element? Give two examples.

An element with no content and no end tag. Examples: <br> (line break) and <img> (image). They never take an end tag.

3. What is nesting, and what is the rule for closing nested tags?

Nesting is putting one element inside another. The rule: close tags in the opposite order you opened them — the last tag opened is the first one closed. <p>This is <strong>important</strong> text.</p> is correct; overlapping tags are wrong.

Try it yourself — build this

Reading is not enough — now build it yourself. Write the code in the live editor, run it, check the hint if you get stuck, and open the solution only after you have tried.

1. Nest it right

Create a paragraph that says "My favourite subject is HTML." — with the word HTML inside a <strong> tag, correctly nested inside the <p>. Then add a <br> and a second paragraph.

Hint: Close the inner tag before the outer one — the last tag opened is the first one closed. <br> needs no end tag at all.
Open the live editor
Show solution
<!DOCTYPE html>
<html>
<head>
<title>My Favourite Subject</title>
</head>
<body>
<p>My favourite subject is <strong>HTML</strong>.</p>
<br>
<p>I am learning it one lesson at a time.</p>
</body>
</html>

Why learn this yourself — and not just ask AI?

AI can write code for you, but it cannot think for you. When you learn HTML yourself, your brain builds the real skill: you understand why a page looks the way it does, you can fix it when it breaks, and you can answer it in an exam or an interview without help. That is the skill that gets you a job — not a copied answer.

Get certified — just ₹10

Finish all 35 lessons, pass the test (80%), pay ₹10 and get your certificate.

Take the test

Prefer watching? Video courses teach the same topics step by step.

Go further with a full course

Free tutorials teach you the basics. Our paid courses add live projects, mentorship and a certificate.

Website Design Using WordPress 3 Days (Basic to Advanced)
₹199
View
Website Design & Development Workshop 2026
₹299
View
AI Prompt Engineering Webinar 2026
View
Browse all courses
HTML — Lessons
1. HTML Introduction: What is HTML? Learn with Examples 2. Best Free HTML Editors: Notepad to VS Code for Beginners 3. HTML Basic Structure: Doctype, Head, Body Explained 4. HTML Elements Explained: Tags, Content & Empty Elements 5. HTML Attributes List: href, src, alt, width, title & More 6. HTML Headings h1 to h6: Which Heading Tag to Use When 7. HTML Paragraphs: p Tag, br Line Breaks & pre Text 8. HTML Style Attribute: Colour, Font Size & Alignment 9. HTML Text Formatting Tags: bold, italic, mark & More 10. HTML Comments: How to Add Notes & Hide Code in HTML 11. HTML Colors: Names, HEX, RGB & HSL Colour Codes 12. HTML CSS: Inline, Internal & External Stylesheets 13. HTML Links: a Tag, href, New Tab & Email Links 14. HTML Images: img Tag, src, alt, Width & Formats 15. HTML Favicon: Create & Add a Browser Tab Icon 16. HTML Title Tag: How to Write a Good Page Title 17. HTML Tables: table, tr, th, td, colspan & rowspan 18. HTML Lists: ul, ol, dl & Nested Lists Explained 19. HTML Block vs Inline Elements: div, p, span Explained 20. HTML Div Tag: Group Content & Build Page Layouts 21. HTML Class Attribute: Style Many Elements at Once 22. HTML id Attribute: Unique IDs, Links, CSS & JavaScript 23. HTML Iframes: Embed YouTube, Maps & Pages in HTML 24. HTML JavaScript: script Tag, Clicks & First Example 25. HTML File Paths: Relative vs Absolute Paths Explained 26. HTML Head Element: title, meta, charset & viewport 27. HTML Layout: header, nav, main, footer Page Structure 28. HTML Responsive Design: Viewport, Images & Media Queries 29. Semantic HTML Tags: header, nav, main, article & footer 30. HTML Forms: input, label, select, checkbox & Submit 31. HTML Entities: & < > © with Examples 32. HTML Audio & Video Tags: controls, source & Fallback 33. HTML Accessibility: alt Text, Labels, Landmarks & ARIA 34. HTML Meta Tags & SEO: charset, viewport, OG Tags 35. HTML Quotations: blockquote, q, cite, abbr & address
Final Test — Certificate ₹10

🤖 KAMALDNP AI Assistant

Ask about courses, website & more

Hi! I'm KAMALDNP AI Assistant. Ask me about our courses, website features, or anything else! 😊
Please wait 5s...
🤖 KAMALDNP Assistant ✕

Request human callback:

🔐 Login Required
✕

Please log in to download. You will stay on this page after logging in!

New here? Register now →