0
Can someone teach me about <div> in html with example.....???!!!
3 Answers
+ 6
<div> element is like a box (or a block). You put other tags(ex: <h1> or <p>) inside it.
why will you put them inside <div>?
because:
a) this way you can put related element inside a box or block(inside<div>) so that when you read code you can understand it
b) you can apply styles to <div> and it's elements(tags inside <div>).
(i think this is the main reason, styling many elements at once that are inside <div>)
+ 4
https://www.w3schools.com/tags/tag_div.ASP
The best example in this site please check this
+ 4
<div> is like a box or container for other tags to be placed in.
Example 1:Your shopping bag is the <div> and <h1>You </h1> is the content.
You can place any tag in it(except the head,html and body tag).To link it to CSS:
Use:
id or class
id:
The id must be specific.Example 2:Like your personal id which has the specific location and age.
Code example:
<div id="personal_1â>
<h1>Funđđ</h1>
</div>
Class:
Class can be used for a group of id's.
Example:Bread đ which is the class and sausages which are the Ids.
Code example:
<div class="personalâ>
<div id="personal_1â></div>
<div id="personal_2â></div>
</div>
Note:The <div> tag(element)can be used to make shapes when there are no contents.
Example:
<div class="block"></div>
CSS:
.block{
height:300px;
width:50px;
background-color:red;
}
Note: Whenever you want to use ids in CSS,use the '#' sign before the id name and use a full stop when you want to use a class from Html.