Remark
I am absolutely sure that these questions have been asked before, but I just cannot seem to find it. Whether I am searching with the wrong keywords or just not understanding what is going on I do not know. Honestly, I am quite embarrassed to even be asking this question since it seems absolutely trivial. It has been quite some time that I worked with CSS, so I am quite sure that this is something really basic.
Questions
- Why does a child div that is smaller (e.g. with a fixed with) have a right margin that extends up until the border of the parent element?
- Why am I not able to restrict said margin with specifying
right-margin? - What is the best way to resolve this?
Example
<div>
<div style="height: 50px; width: 50px; background-color: black" />
</div>
As you can see in the inspector, the most nested div actually has a margin that extends all the way to the parents border.
Setting the right-margin does not affect this.
Any help would be deeply appreciated, please do feel free to redirect me to other questions if this has already been asked!
