+ 2

Div color

Van anybody tell me how to add two different background color in two different div tag . And how to add margin between two div tag <div style="border:3px solid black;width:98%;height:95px"> <body> <nav class="navbar"> <a href="home">home </a> <h1> First website </h1> </div> <div style="border:2px solid white;width:98%;height:350px">

2nd Mar 2023, 1:31 PM
Azlan Wasi
Azlan Wasi - avatar
2 Respostas
+ 2
You acn use <style> tag to add different color in your 2 different div this like ---- <style type="text/css"> #div1{ width:100%; height:50px; background-color:green; color:white; } #div2{ width:100%; height:70px; background-color:gray; color:black; } </style> <div id="div1"> <h2>Div 1</h2> </div> <div id="div2"> <h2>Div 2</h2> </div>
3rd Mar 2023, 11:42 AM
Abdun Nur Porag
Abdun Nur Porag - avatar
+ 4
You can use background-color attribute. Have a look at the sololearn CSS course.
2nd Mar 2023, 2:18 PM
Lisa
Lisa - avatar