I'm doing a simple exercise with margin and padding, it should look something like this:
I tried to do it by setting the padding of the outer div to a fix value and setting the margin of the inner div to 0. But my result looks like this:
Inspector in google shows a margin to the right of the inner div, I have no idea where it comes from.
Here are the html and css codes
#box1,
#box2,
#box3,
#box4 {
width: 200px;
height: 200px;
border-width: 4px;
border-style: solid;
margin: 8px;
/* Aufgabe 2 */
display: inline-block;
/* Aufgabe 3 */
padding: 50px;
}
#box1 {
border-color: red;
}
#box2 {
border-color: green;
}
#box3 {
border-color: violet;
}
#box4 {
border-color: yellow;
}
#inbox1,
#inbox2,
#inbox3,
#inbox4 {
width: 100px;
height: 100px;
/* Aufgabe 3 */
margin: 0px;
}
#inbox1 {
background-color: royalblue;
}
#inbox2 {
background-color: pink;
}
#inbox3 {
background-color: black;
}
#inbox4 {
background-color: turquoise;
}
<div id="box1">
<div id="inbox1"></div>
</div>
<div id="box2">
<div id="inbox2"></div>
</div>
<div id="box3">
<div id="inbox3"></div>
</div>
<div id="box4">
<div id="inbox4"></div>
</div>
Can someone explain where that margin comes from and how I can get rid of it?