I have some images that I want to use using negative margins. However, since stacking images without clearly defined borders can be visually confusing, I decided that I should add a border around them. Oddly enough, even if the stack images are correct, their boundaries fall under the previous element.
Why am I getting this behavior, and is there a way for the borders to be displayed at their intuitive level?
#second {
margin-top: -50px;
margin-left: 20px;
}
img {
border: 5px ridge green;
display: block;
}
<div><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/1/1b/RCA_Indian_Head_test_pattern.JPG/312px-RCA_Indian_Head_test_pattern.JPG" height="100" width="auto"><img id="second" src="https://upload.wikimedia.org/wikipedia/commons/thumb/1/1b/RCA_Indian_Head_test_pattern.JPG/312px-RCA_Indian_Head_test_pattern.JPG" height="100" width="auto"></div>
Run codeHide resultEDIT: In Firefox, it looks like this:

source
share