0

What is the deal with div and id? Please I need in depth explanation

19th Jun 2019, 4:50 AM
Joan Waithera Njuguna
Joan Waithera Njuguna - avatar
3 Answers
+ 2
Div is a tag in HTML, and it stands for "divider." It is mainly used to organize and contain other elements. Without using the dividers, HTML can get very messy. As I stated, a divider can contain other elements inside of it. This allows keeping certain parts of a webpage in a specific area. Adding IDs (and classes) to elements is very useful, especially when working with CSS and JavaScript. Giving an ID to an element allows it to be accessed when necessary. In CSS, an element is selected by ID using a '#', so if you were trying to set something with the ID of 'ab' to the color red, you would use #ab {color: red;} in CSS. In JavaScript, you can select an element with the ID of 'ab' using document.getElementById("ab"); From here, you can get or set its attributes.
20th Jun 2019, 1:50 AM
Daniel C
Daniel C - avatar
+ 1
Div is a block-level HTML element, and id is used to access a specific element in CSS or JS
19th Jun 2019, 5:02 AM
Airree
Airree - avatar
0
lets see: like... Div is you. id is your name. like if you were speeding up (driving), if the police said You, it includes you, but not specificly you. but if he said bob (id), then you know he's talking to you - and you will stop. if you called a div and _set the color to red, it will apply to all the divs. but if you pick an id inside a div #id{ color:red} that will only make the id you chose _ color red.
19th Jun 2019, 5:37 AM
Ginfio
Ginfio - avatar