CHAPTER 60
CSS Object-position
Learn how object-position controls which part of an image remains visible when object-fit is used.
01. What is CSS Object-position?
object-position controls the position of replaced content inside its box.
It is especially useful with object-fit: cover.
You can position an image toward the center, top, bottom, left or right.
02. Syntax
img {
object-fit: cover;
object-position: center top;
}
03. Example
CSS / HTML Example
AIFA Coding Lab
<!DOCTYPE html>
<html>
<head>
<style>
.image {
width: 300px;
height: 200px;
object-fit: cover;
object-position: center top;
}
</style>
</head>
<body>
<img
class="image"
src="https://via.placeholder.com/600x400"
alt="Example"
>
</body>
</html>
04. Important Points
✓
object-position changes the visible focal area.
✓
It works especially well with object-fit: cover.
✓
Positions can use keywords or numerical values.
05. Common Mistakes
⚠
Changing object-position without object-fit when cropping is expected.
⚠
Choosing a focal position that cuts important content.
⚠
Ignoring mobile cropping.
06. Real World Use
object-position is useful for profile photos, product images, banners and responsive image cards.
Ready to Practice? 🚀
Open the AIFA CSS Editor and practice this chapter live.
Try It Yourself →
Practice Exercise
Control Image Focus
Use object-fit: cover and object-position to keep the top part of an image visible.