css keep ratio image code example
Example 1: css keep image ratio
img {
object-fit: cover;
width: 100px;
height:100px;
}
Example 2: html image keep aspect ratio
Don't set height AND width. Use one or the other and the correct aspect ratio will be maintained.