How do you keep the important part of an image visible when it is cropped?

Keep the important part of a cropped image visible by defining a focal point and aligning the crop toward it. With object-fit: cover, the browser removes whichever edges do not fit the container. object-position changes which part remains in view. Centering is only correct when the subject is actually centered.
Start with a stable image box, then set the focal position as percentages or position keywords. The first value controls the horizontal position and the second controls the vertical position:
.profile-card img {
width: 100%;
aspect-ratio: 4 / 3;
object-fit: cover;
object-position: 68% 30%;
}
Preview the crop across the component’s full size range. Percentages describe alignment between the image content and its box, so the visible area changes as the box becomes wider or taller. A coordinate that protects a face in a square card may fail in a shallow banner. Store a focal point with each media item if editors upload varied photographs, then expose those values as CSS custom properties.
.media {
–focal-x: 50%;
–focal-y: 50%;
}
.media img {
width: 100%;
height: 100%;
object-fit: cover;
object-position: var(–focal-x) var(–focal-y);
}
Focal positioning has limits. A very wide group photo cannot become a narrow portrait without losing people, and a product near one edge may leave no useful crop at the opposite ratio. Create a separate mobile crop in a picture element when one source cannot preserve the intended subject. Keep the same meaning and alternative text across both versions.
Text embedded in an image needs extra care because even a technically correct crop can cut off words or make them too small. Place headings and buttons in HTML where the layout can reflow them. If the image itself contains necessary labels, use contain or redesign the asset so all information stays visible.
Test with representative content, including faces near edges, products with shadows and images uploaded in unexpected ratios. Check phone portrait, phone horizontal orientation and wide desktop layouts. The best production rule combines a sensible default focal point, per-image overrides and an art-directed fallback for compositions that cannot survive automatic cropping.