What is the use id div tag?give its attribute with value. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

What is the use id div tag?give its attribute with value.

1st Aug 2017, 2:32 PM
Darshan
Darshan - avatar
3 Answers
+ 5
The "div" element is used as a container of other elements. The attribute id="" is used to add a unique identity to the div (in order to work easier with CSS and JavaScript). Example of a div that contains a paragraph and an image: <div id="mydiv"> <p> Some text </p> <img src="" alt="" /> </div>
1st Aug 2017, 2:39 PM
Ledio Deda
Ledio Deda - avatar
+ 2
The <div> tag is a block element used to define a division or section of the contents of a web page. It is useful for grouping block-level elements together so they can be styled using CSS. So, you can use whatever CSS attribute applicable to the contents.
1st Aug 2017, 2:36 PM
Saka Oluwadamilola
Saka Oluwadamilola - avatar
+ 2
we use div to modify it using Css and Javascript.
1st Aug 2017, 3:56 PM
Irwin Lopez
Irwin Lopez - avatar