-
Hajipur, Bihar, 844101
HTML elements are building blocks of a webpage. Based on their behavior, elements are broadly categorized into:
Block-level elements
Inline elements
Block elements start on a new line and take up the full width available.
They are used to structure content into sections, paragraphs, etc.
<div>
<p>
<h1>
to <h6>
<ul>
, <ol>
, <li>
<table>
<form>
<section>
, <article>
, <header>
, <footer>
<p>This is a paragraph.</p>
<div>This is a block-level element.</div>
Inline elements do not start on a new line. They take up only as much width as necessary and are usually used to style small parts of text.
<span>
<a>
<strong>
<em>
<img>
<label>
<input>
<p>This is <strong>bold</strong> and <em>italic</em> text.</p>
Feature | Block Element | Inline Element |
---|---|---|
Line Break | Starts on a new line | Does not break line |
Width | Full width (by default) | Only needed width |
Use Case | Layout and structure | Formatting content |
You can use inline elements inside block elements, but not always vice versa.
✅ Allowed:
<p>This is <span>inline text</span> inside a paragraph.</p>
🚫 Not Allowed:
<span><div>This is invalid HTML</div></span>
Q1. Create a <div>
containing a paragraph and a heading.
Q2. Use an <h2>
tag inside a <section>
block.
Q3. Add a <span>
to highlight a word inside a sentence.
Q4. Add a link (<a>
) inside a paragraph.
Q5. Create a form with input fields (<input>
) and labels (<label>
).
Q6. Place multiple inline elements inside a block-level <div>
.
Q7. Try placing a block element inside an inline element (and explain the result).
Q8. Use both <strong>
and <em>
to style a phrase.
Q9. Create a list of items inside a <section>
block.
Q10. Use CSS to make a block element behave like inline (display: inline;
).
Q1: Which of the following is a block-level element?
Q2: Which element is inline by default?
Q3: What does a block-level element do?
Q4: Which of the following is NOT an inline element?
Q5: Can an inline element contain a block-level element?
Q6: Which tag is commonly used to group inline text for styling?
Q7: Which tag is commonly used to group block elements for layout?
Q8: What is the default display type of <p>?
Q9: What HTML tag is suitable for adding bold styling in an inline manner?
Q10: Which CSS property can change a block element to behave like inline?