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.
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.
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 fieldElements 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.
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.
<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>
<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.<P> — HTML allows it, but small letters are the standard and every professional uses them.<b><i>text</b></i> — always close the inner tag first.<p> twice instead of <p>...</p>.<br></br> — <br> never takes one.<!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.<!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>
Change the code below and press Run to see the result instantly. No file to save, no login needed.
The questions learners ask most about this lesson — read the question, then open it to see the answer.
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.
A tag is just the bracketed name, like h1. An element is the whole thing: start tag, content, and end tag together.
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.
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?
2. Which of these is an empty element?
3. What is nesting?
4. Which nesting is correct?
5. What is the difference between a tag and an element?
Read the question first, try to answer it in your own words, then open it to check. These are the questions interviewers actually ask.
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.
An element with no content and no end tag. Examples: <br> (line break) and <img> (image). They never take an end tag.
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.
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.
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.
<!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>
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.
Finish all 35 lessons, pass the test (80%), pay ₹10 and get your certificate.
Take the testPrefer watching? Video courses teach the same topics step by step.
Free tutorials teach you the basics. Our paid courses add live projects, mentorship and a certificate.
Browse all coursesAsk about courses, website & more
Request human callback:
Please log in to download. You will stay on this page after logging in!
New here? Register now →