span vs div tags


HTML div tag vs HTML span tag:

div tag is a paired tag
span tag is a paired tag

div tag is a block level tag
span tag is a inline level tag

Inline tags should exist in context with block level tags.

In modern html every html element should be meaningful.
h1 indicates heading, p indicates paragraph, b indicates bold etc.
we supposed to use right element for right purpose.

When there is no meaningful tag present for what we want to achieve then we use div tag.
For example there is no tag used to create divisions in the page hence we use div tag.

span tag is used to enclose inline contents like text images etc.

Interview Questions: