Can someone teach me about <div> in html with example.....???!!! | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
0

Can someone teach me about <div> in html with example.....???!!!

10th Nov 2022, 5:08 PM
iONE
iONE - avatar
3 ответов
+ 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>)
10th Nov 2022, 5:22 PM
Sandeep
Sandeep - avatar
+ 4
https://www.w3schools.com/tags/tag_div.ASP The best example in this site please check this
10th Nov 2022, 5:20 PM
Sakshi
Sakshi - avatar
+ 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.
10th Nov 2022, 6:26 PM
JŌẞlÔX™
JŌẞlÔX™ - avatar