Whenever I try to align the green and orange boxes side by side, it doesn't seem to work properly. Even though 1000 divided by 2 equals 500 (by the way, I am new to HTML). I am struggling with understanding positions and sizes in HTML.
Here is the HTML code:
h1{
position:relative;
color:#89CFF0;
font-family:arial;
width:1000px;
margin:0 auto;
text-align:center;
}
.boxes{
width:1000px;
margin:0 auto;
position:relative;
text-align:center;
}
#box1{
font-family:arial;
border:1px solid red;
position:relative;
margin:0 auto;
width:1000px;
top:40px;
background-color:red;
}
#box2{
font-family:arial;
border:1px solid blue;
position:relative;
margin:0 auto;
width:1000px;
height:150px;
top:40px;
background-color:blue;
}
#box3{
position:relative;
font-family:arial;
border:1px solid green;
position:relative;
margin:0 auto;
width:500px;
height:100px;
top:40px;
float:left;
background-color:green;
}
#box4{
font-family:arial;
border:1px solid orange;
margin:0 auto;
position:relative;
width:500px;
height:100px;
top:40px;
float:left;
background-color:orange;
}
#box5{
font-family:arial;
border:1px solid yellow;
position:relative;
margin:0 auto;
width:1000px;
top:140px;
background-color:yellow;
}
<h1> The Box </h1>
<div class="boxes">
<div id="box1">
<p>RED</p>
</div>
<div id="box2">
<p>BLUE</p>
</div>
<div id="box3">
<p>GREEN</p>
</div>
<div id="box4">
<p>ORANGE</p>
</div>
<div id="box5">
<p>YELLOW</p>
</div>
</div>
Output:
I believe the issue lies with the pixel value of .box3
, while I am confident that box5
is correctly set up