<div>
Example
<div class="btn" onclick="save()">
Save
</div><button type="button" onclick="save()">
Save
</button><button> gets focus, Enter and Space key support and the button role for free.
Common mistakes
- Making a
<div>clickable, which is unreachable by keyboard and silent for screen readers. - Wrapping everything in extra
<div>layers that add no styling.
Key points
<div>is used only for layout or styling groups when no semantic element fits.- Interactive controls are
<button>or<a>, not a<div>with a click handler. - Page regions use
<header>,<nav>,<main>and<footer>instead of<div class="header">.
Interview questions
What is the difference between <div> and <span>?
<div> and <span>?<div> is a block-level container for grouping larger content, while <span> is an inline container for a part of text.
Is <div> bad for SEO?
<div> bad for SEO?No, but it carries no meaning, so semantic elements give search engines and assistive tech more context.