-
Hajipur, Bihar, 844101
An HTML element is everything from the start tag to the end tag, including its content.
<tagname>Content goes here</tagname>
Example:
<p>This is a paragraph.</p>
Part | Description |
---|---|
Start Tag | <p> – Opens the element |
Content | This is a paragraph. |
End Tag | </p> – Closes the element |
Full Element | <p>This is a paragraph.</p> |
You can place one element inside another — this is called nesting.
<p>This is a <strong>bold</strong> word.</p>
📌 Always close nested tags in the reverse order they were opened.
Some elements do not have content or closing tags.
Examples:
<br> <!-- Line break -->
<hr> <!-- Horizontal rule -->
<img src="pic.jpg" alt="Photo"> <!-- Image -->
Type | Description | Examples |
---|---|---|
Block | Starts on a new line, takes full width | <div> , <p> , <h1> |
Inline | Stays in line with text, takes only necessary space | <span> , <a> , <img> |
Example:
<p>This is <span>inline</span> text.</p>
<!DOCTYPE html>
<html>
<head>
<title>HTML Elements Example</title>
</head>
<body>
<h1>Welcome!</h1>
<p>This is a paragraph with <a href="#">a link</a>.</p>
<hr>
<img src="example.jpg" alt="Example Image">
</body>
</html>
HTML elements can have attributes (like href
, src
, alt
, etc.)
Be careful with proper nesting
Indentation improves readability
Q1. Create a paragraph element using <p>
with any text.
Q2. Write a heading using <h2>
with the text "My Page".
Q3. Create a nested element with <strong>
inside a <p>
.
Q4. Insert a horizontal line using the <hr>
tag.
Q5. Add a line break using the <br>
tag between two sentences.
Q6. Create an anchor tag <a>
with link text "Click here".
Q7. Add an image element <img>
with a sample src
and alt
.
Q8. Identify 2 block elements and add them to an HTML file.
Q9. Write an inline element example using the <span>
tag.
Q10. Create a full HTML page with at least 5 different elements.
Q1: What is an HTML element?
Q2: Which tag is used for line breaks?
Q3: Which of the following is an empty element?
Q4: Which of the following is a block-level element?
Q5: What happens if you don't close a tag properly?
Q6: What is the correct syntax of an anchor tag?
Q7: Which tag is used to display an image?
Q8: What does <hr> do?
Q9: Which element is typically used inline?
Q10: Which tag represents a block of text?