r/HTML • • 4d ago

div messing with DOM?

Why is the div messing with the DOM so much and creating a copy of its parent tag? Is this expected behaviour?

Hello all, trying to build a dropdown menu, the button to open it only appears when the screen is narrow. But I am not asking for help with that specifically, I am trying to put a div in a anchor that is a flex element, and weird things are happening in the DOM. I have checked, double checked, and ran the code through multiple tools. as far as I can tell the html is correct, but the DOM is all weird.

As you can see in the code div.dropdown-content is a element inside of a#ham_menu, but when chrome has loaded it div.dropdown-content is outside of a#ham_menu and a copy of a#ham_menu is inside of div.dropdown-content. Is this expected for some reason? if this is some weird flex behavior, I would appreciate some suggestions of how to get around or avoid it.

Here is a link to my github. https://github.com/wisnoskij/sglondon_website
Here is my github page: https://wisnoskij.github.io/sglondon_website/

5 Upvotes

4 comments sorted by

6

u/Top_Bumblebee_7762 4d ago edited 3d ago

You can't have links nested inside links. Either move the drop-down out of the parent link and use anchor positioning to position it. Alternatively make the link and the drop-down sibling elements inside a wrapper. 

2

u/wisnoskij 4d ago

Thank you, that explains it.

1

u/Proper_Sun9019 11h ago

te recomiendo usar la etiqueta <ul> <li> con esto crearas una lista ordenada

<ul>

<li><a></a></li>

</ul>

0

u/[deleted] 4d ago

[deleted] — view deleted comment

1

u/wisnoskij 4d ago

Changed link to my github.