0

margin in background color or image

hi all in follow file i have two div. second div has background-image. why when set margin-top to <p> tag background-image get margin? *** <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <style> .sec1 { height: 100px; background-color: brown; } .sec2 { height: 100vh; /* background-image: url(./images/showcase.jpg); */ background-color: aqua; background-size: cover; } p { margin-top: 100px; } </style> </head> <body> <div class="sec1"></div> <div class="sec2"> <p>Hello</p> </div> </body> </html>

26th Feb 2022, 4:38 PM
Hadi
Hadi - avatar
3 Answers
+ 3
Pls post the code on Sololearn I can't download
26th Feb 2022, 9:47 PM
Chigozie Anyaeji šŸ‡³šŸ‡¬
Chigozie Anyaeji šŸ‡³šŸ‡¬ - avatar
+ 1
So what's the problem Be more explicit
27th Feb 2022, 5:41 PM
Chigozie Anyaeji šŸ‡³šŸ‡¬
Chigozie Anyaeji šŸ‡³šŸ‡¬ - avatar
0
ok edited
27th Feb 2022, 3:58 PM
Hadi
Hadi - avatar