Coding Now – Best AI & Full Stack Courses in Delhi NCR | 100% Placement
Limited Offer: Get 50% OFF on AI & Full Stack Courses
📞 Call Now: +91 9667708830
Back to HTML Notes
Topic #113

HTML Inline Elements

An inline element only takes up as much width as its content needs, and doesn't force a line break — it flows within surrounding text.

Common Inline Elements

<span>, <a>, <strong>, <em>, <img>, <code>, <label>, <br>

Example

<p>
    Learn <strong>Python</strong>, <strong>SQL</strong>, and
    <a href="/cources/data-science.php">Data Science</a> at CodingNow.
</p>

Browser output: everything flows on the same lines as regular text — "Python," "SQL," and the link don't force line breaks; they're just emphasized or clickable words within the sentence.

Block vs Inline — Side by Side

BlockInline
Starts on a new lineYesNo
Default widthFull width of parentOnly as wide as its content
Can contain block elementsUsually yesNo — only text/other inline elements
Examples<div>, <p>, <section><span>, <a>, <strong>

Generic Wrappers: div vs span

When no semantic tag fits, <div> is the generic block-level wrapper and <span> is the generic inline wrapper:

<p>Status: <span class="status-active">Active</span></p>

Common Mistakes

  • Putting a block element (like <div> or <p>) inside an inline element (like <span> or <a>) — invalid content model in most cases
  • Trying to set a fixed width/height on an inline element and being confused when it doesn't apply the way it would on a block element (without changing its CSS display property first)

Interview Relevance

Practical version of this question: "Why doesn't setting width on a <span> work?" — because inline elements don't respect width/height by default; you'd need display: inline-block or display: block in CSS.

Practice Question

Identify which of these are block vs inline: <h2>, <em>, <ul>, <img>, <section>, <a>.

Related HTML Notes

Want to go beyond the notes?

Join CodingNow's HTML course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available
💬 Talk to Advisor
1
WhatsApp

Latest from Our Blog

Insights on AI, Data Science, Full Stack & Career

View All Articles →