Image Styling in CSS - Make Images Professional and Responsive

Images are a core part of any interface. Styling images correctly in CSS makes the design more professional and prevents display issues on mobile.

If you are searching for image styling in CSS or how to make a circular image in CSS or responsive image CSS max-width 100%, this lesson is practical and direct.

Image Styling Basics in CSS

The most common properties you will need are:

  • border to add a frame around the image.
  • border-radius to round corners or create a circular image.
  • box-shadow to add visual depth.
  • max-width: 100% + height: auto for responsive images.
Simple definition: Image styling in CSS improves the look of an image and its behavior across different screens.

1) Add a Border to an Image in CSS

img.product {
    border: 4px solid #d1d5db;
}

What does this code do? Adds a clear border around the image.

Expected result: better visual separation between the image and the background.

Common mistake: a border that is too thick and steals attention.

Result in the browser:

Image with border

2) border-radius for Images (Rounded Corners and Circles)

border-radius controls the edge shape. A value of 50% creates a circle (if width and height are equal).

img.rounded {
    border-radius: 12px;
}

img.circle {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    object-fit: cover;
}

What does this code do? The first rounds corners, the second turns the image into a balanced circle.

Expected result: a modern look for avatars or card images.

Common mistake: using border-radius: 50% on a non-square image without fixing the dimensions.

Rounded Corners

Image with rounded corners

Circle Image

Circular image

3) box-shadow for Images in CSS

Shadow adds depth and helps images stand out, especially on light backgrounds.

img.card-image {
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
}

What does this code do? Adds a soft shadow below the image.

Expected result: a more professional, less flat look.

Common mistake: a shadow that is too strong and feels noisy.

Result in the browser:

Image with shadow

4) Responsive Images in CSS

The golden rule for images on the web:

img {
    max-width: 100%;
    height: auto;
}

What does this code do? Prevents the image from overflowing its container and adjusts height automatically.

Expected result: no broken layouts on mobile.

Common mistake: using a large fixed width without max-width.

Result in the browser (mock):

Responsive image

Complete Example: Card Image Styling in CSS

.card-img {
    width: 100%;
    max-width: 320px;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.12);
}

What does this example do? Creates a responsive card image with soft corners and balanced shadow.

Expected result: an image ready for product cards or articles.

Result in the browser:

Card image

SEO + Performance Best Practices for Images

  • Use descriptive alt text for every image.
  • Compress images to reduce loading size.
  • Choose appropriate dimensions instead of huge files.
  • Keep max-width for flexibility on mobile.
Important SEO tip: alt text helps search engines understand the image and improves accessibility.

Common Mistakes in Image Styling in CSS

1) Non-responsive images: overflow the screen width.

2) Rounded corners with distorted images: caused by missing size or fit control.

3) Shadows that are too strong: unprofessional look.

FAQ - Common Search Questions

How do I make an image responsive in CSS?

Use max-width: 100%; and height: auto;.

How do I make a circular image in CSS?

Set width = height, then use border-radius: 50%;.

How do I add a shadow to an image in CSS?

Use box-shadow with balanced values.

What is the difference between border-radius and object-fit for images?

border-radius changes the edge shape, and object-fit controls how the image fills its box.

Why is my image distorted after setting width and height in CSS?

The aspect ratio changed. Use height: auto or object-fit: cover.

Try it now: apply border, border-radius, box-shadow, and max-width to one image, then test it on a small screen.
Great job! You have mastered basic image styling in CSS. In the next lesson we will learn object-fit to control how an image fits inside its box.
Smart Editor

Write code and see the result instantly

Try it free