The problem is this: why is the a tag larger than the picture? Shouldn't he occupy the height of the content? The screenshot shows that it is a couple more pixels, how to get rid of it without specifying max-height & height ?
Code:
.container { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); } a { display: block; } <div class="container"> <a href="#"> <img src="https://picsum.photos/200/300" alt="#"> </a> </div> 