Grouping with div and span
div groups block-level content and span groups a run of inline text, and neither adds any meaning, so they are the tools to reach for only when no meaningful element fits.
Use a neutral container only when a more meaningful element does not fit.
Sometimes you need to wrap a few elements together so CSS can lay them out, or wrap a few words so they can be coloured. No element with a real meaning fits the job. That is exactly when HTML's two generic containers come in.
The rule
div groups blocks, span groups words; both mean nothing, so use them last.
<div> is a generic block-level container. Block-level elements start on a new line and stretch across the available width, like paragraphs and headings. A div groups larger pieces:
<div class="card">
<h3>Clay Water Pot</h3>
<p>Keeps water cool without electricity.</p>
<p>₹350</p>
</div><span> is a generic inline container. Inline elements sit inside a line of text without breaking it, like a, strong and em. A span wraps a few words:
<p>Delivery: <span class="highlight-date">Thursday</span></p>Both are meaningless on purpose. A div does not say "section" and a span does not say "important". To a screen reader or a search engine they are invisible wrappers. That is why they are the last resort: first look for an element that says what the content is, such as p, h2, strong, button, or the structural elements like section, nav and article you will meet later.
A classic mistake is "div soup": a page built entirely from nested divs, some pretending to be buttons or headings. It may look right, but assistive technology gets no structure at all, and the fake buttons do not work with a keyboard.