<!doctype html>
<style>
#avatar {
  width: 100px;
  display: block;
}
#container {
  width: max-content;
  border: 10px solid green;
}
#ancestor {
  padding: 10px;
}
</style>
<div id="ancestor">
  <div id="container">
    <svg viewBox="0 0 128 128" xmlns="http://www.w3.org/2000/svg" id="avatar">
      <rect height="100%" width="100%" fill="blue"></rect>
    </svg>
  </div>
</div>
