+ 16
Can you nest divs (ANSWERED)
Like this: <div id=“example”> I have <div id=“example_2”> a question </div> </div> [ANSWERED] I had tried it before I posted this Q and A. In the code that I was trying out, which is not the code above, I had said “div if=“ instead of “div id=“ (Typo)
14 Answers
+ 10
Just make sure you close them all properly. Browsers are really forgiving and actually interpret what you mean when it comes to closing order of tags... but best to get in good practices early. That said... nest away good man. Nest away. :)
+ 12
Coming In Second
Sorry, in my code (not above) I had said “div if=“...”” 😂🤣😂🤣
+ 10
Have you tried it yet? The truth is that you can nest as many as youd like within another as long as you keep the correct syntax!😉
+ 6
Yep, you can. It is a very common practice.
+ 5
yes very possibly
+ 4
Everyone
I had tried it before I posted this Q and A. As I said to Coming In Second, in the code that I was trying out, which is not the code above, I had said “div if=“ instead of “div id=“
+ 3
🐺Michael🐺 Haha no problem youll have tons of goof ups like that when programming thats why teams are so efficient
+ 2
Yes u can. Just try it out!
+ 1
As the other people said, sure you can, but it would be better to read if you indent the code.
+ 1
yes it is possible and it is required in some circumstances depending on your application...
+ 1
yes you can try it out anything is possible
+ 1
yes you can
+ 1
I find it easier to keep track of my coding and layout with nested divs, especially when I have a block that contains other elements. It gets easier to manage my CSS sheets, too as I can just have the children inherit a stylized theme instead of hunting for each div...but that's just my novice experience.
+ 1
yes you can , and it is often uses to nested div