Div tag


HTML - div tag:

div tag is a paired tag.
div tag is a block level tag.
div tag is a generic container tag.
div tag is used to group various html tags, so that sections can be created and styles can be applied.
div tag is used to divide body in to various sections or divide body into various divisions.
div tag has no margin no padding hence use br tag to add break between div elements.

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:

1. HTML div tag is a block level tag ?
a. true
b. false
Answer: a