Home > Software engineering >  why my div broke into two parts after I added an another div inside it?
why my div broke into two parts after I added an another div inside it?

Time:08-01

    <div id="container">
<div >< img height="500px"src="./images/image-product-desktop.jpg" alt="">
<p>PERFUMES</p>
</div>

when I add a paragraph the div breaks into two parts, please help.enter image description here

CodePudding user response:

You have to properly write the html markup by opening and closing the tags. The markup you shared has 2 <div> but you only closed one of them, when that happens the html parser of the browser will automatically try to close it for you which may end up doing unexpected results.

I suggest you to use an IDE like vscode and install extensions that will help you properly format your code and identify markup errors.

  • Related