Skip to main content

How to Get Both Subject and Background in Focus

When you need everything sharp from foreground to background, the techniques for maximizing depth of field and what to do when basic settings aren't enough.

Sometimes you need everything sharp, and the creamy background blur of a portrait or artistic selective focus is the last thing you want.

  • You need the rocks at your feet and the mountains on the horizon both tack sharp.
  • You need the couple in the foreground and the cathedral behind them equally crisp.
  • You need every corner of that real estate interior detailed enough for buyers to zoom in.

This is maximizing depth of field, and it takes a different approach from most photography. Instead of isolating your subject, you're including everything and inviting the viewer to explore the whole frame.

Just using a small aperture sounds simple enough, but there's more to it. Stop down too far and diffraction softens your image. Focus in the wrong spot and either the foreground or the background goes soft despite your aperture choice. And sometimes no single aperture can get everything sharp, no matter how narrow you go.

This guide covers the techniques for getting everything in focus, including when you need it, the factors that control it, and what to do when basic techniques aren't enough. It's one of the more advanced topics in the sharp photos guide.

When You Want Everything Sharp

Maximizing depth of field isn't always the goal, since shallow focus has its place. Certain situations genuinely call for front-to-back sharpness, though.

Landscape photography is the classic case. You've found a composition with interesting foreground elements like rocks, wildflowers, and a leading line, along with a compelling background, and the whole scene tells the story. If the foreground goes soft, the image loses its anchor. If the background goes soft, you lose the payoff.

Environmental portraits balance subject and setting. Think of a craftsperson in their workshop, a chef in their kitchen, or a musician surrounded by instruments. The environment matters as much as the person, and shallow focus would wipe out half the story.

Real estate and architecture demand sharpness throughout. Buyers want to see every detail, and soft corners or blurry backgrounds suggest something's being hidden. Technical quality signals professionalism.

Product photography with context often needs everything sharp, like the shoe on the trail, the tent at the campsite, or the watch on the wrist with the city behind it. Shallow focus works for isolated product shots, but contextual shots need depth.

Travel photography needs it too when you're documenting a place instead of isolating a subject. Street scenes, markets, and plazas are photos meant to show what it felt like to be there.

If your image has important elements at several distances and you want them all sharp, read on.

The Aperture Factor and Stopping Down

Aperture is your main control for depth of field, and making it smaller (higher f-numbers) is the most direct way to get more of your scene in focus.

At f/2.8, you might have a few inches of acceptable sharpness. At f/8, that might expand to several feet. At f/11, you're getting into territory where foreground and background can both be sharp if you focus correctly.

The practical range for maximum sharpness is f/8 to f/11. This is where most lenses deliver their best optical performance while still giving you significant depth of field, so these apertures balance sharpness across the frame with enough depth to cover most scenes.

Narrower than f/11, you start fighting diffraction, which comes up shortly.

Here's what to expect at common apertures.

Aperture What you get
f/5.6 Moderate depth. Good for scenes where elements aren't at drastically different distances.
f/8 The classic sharpness sweet spot. Deep enough for many landscape situations.
f/11 Maximum practical depth for most cameras. Your go-to for foreground-to-background sharpness.
f/16 More depth than f/11, but diffraction starts affecting overall sharpness on most cameras.

The right aperture depends on how much depth you actually need. Don't default to f/16 when f/8 would cover your scene, because you'll give up peak sharpness for depth you didn't need.

The Distance Factor (Farther Equals More)

Your distance from the nearest subject dramatically affects depth of field. Get close to something and depth of field shrinks, and step back and it expands, even at the same aperture.

This is why macro photography is so challenging. From inches away, even f/16 might give you millimeters of sharp depth. Photograph a landscape where nothing is closer than 20 feet, on the other hand, and f/8 might render everything to infinity sharp.

A close macro view of a flower with only a thin slice in focus
From a few inches away, even small apertures leave only a sliver of the flower sharp.

In practice, check whether you can step back if you're struggling to get both foreground and background sharp. Sometimes moving two feet farther from your foreground element solves the problem without changing any settings.

The tradeoff is that stepping back changes your composition, because your foreground element becomes smaller in the frame. You'll have to decide whether the current composition is worth the sharpness compromise, or whether you can find one that works from farther away.

The Focal Length Factor (Wider Equals More)

Wider focal lengths give more depth of field at the same aperture and subject distance. A 24mm lens at f/8 provides significantly more depth than an 85mm lens at f/8.

That's one reason landscape photographers favor wide angles. Beyond the compositional appeal of including more of the scene, wide lenses make front-to-back sharpness easier to achieve.

Here's an approximate depth of field comparison at f/8, focused at 10 feet.

Focal length Approximate sharp zone
24mm Roughly 5 feet to infinity
50mm Roughly 7 feet to 18 feet
85mm Roughly 9 feet to 12 feet

These are approximations, and actual depth depends on your sensor size and your standard for acceptable sharpness, but the pattern is clear. Wider lenses dramatically increase your working depth.

In practice, a wider lens makes your job easier if you need maximum depth of field and can use one without ruining your composition. You don't need to cram a 16mm lens into every situation, but you should treat focal length as part of your depth of field strategy.

Hyperfocal Distance Simplified

This concept sounds complicated, but it solves a real problem, which is knowing where to focus to maximize sharpness from foreground to background.

Your intuition might say "focus on the horizon" or "focus on infinity." That wastes half your depth of field. When you focus at infinity, all the sharpness behind your focus point is wasted because there's nothing there, and it could have been covering the area in front of your focus point instead.

Hyperfocal distance is the closest focus distance where infinity is still acceptably sharp. Focus at this point, and everything from half that distance to infinity falls within your depth of field.

For example, at 24mm and f/11 on a full-frame camera, the hyperfocal distance is roughly 7 feet. Focus there, and everything from about 3.5 feet to infinity is sharp. That covers the foreground rocks at your feet and the mountains on the horizon.

How to Find Hyperfocal Distance

The easy way. Plug your lens, aperture, and distance into a depth of field tool, and it tells you exactly where to focus and how much will be sharp.

The field estimate. For wide-angle landscape work, focus roughly one-third of the way into your scene. It isn't precisely hyperfocal, but it distributes depth of field reasonably well in most situations.

The practical approach. If you're not sure exactly where hyperfocal is, focus on something in the middle distance (neither infinity nor the closest element) and check your results. Most situations are more forgiving than the math suggests.

Don't focus on the horizon when you have foreground elements. You're leaving sharpness on the table that should be covering your foreground.

Focus Stacking When Aperture Isn't Enough

Sometimes no single aperture can get everything sharp. The foreground element is too close and the background too far, and even f/16 can't bridge the gap.

That's where focus stacking comes in.

The idea is to take several photos of the same scene, each focused at a different distance, then combine them in post-processing. The software uses the sharp portions of each frame to build a final image that's sharp throughout.

Basic Workflow

  1. Mount your camera on a tripod. The frames must align precisely.
  2. Set your aperture. Usually that's f/8 to f/11, since you want good sharpness per frame more than maximum depth per frame.
  3. Take your first shot focused on the nearest element.
  4. Refocus slightly farther and take another shot.
  5. Continue until you've covered the entire depth of your scene.
  6. Combine the frames in software. Photoshop, Helicon Focus, Zerene Stacker, and other programs can blend focus-stacked images automatically.

The number of frames depends on the depth gap. For landscapes with moderate foreground-to-background distance, 3-5 frames often do the job. For macro work where you're inches from your subject, you might need 20-30 frames to cover a few inches of depth.

When to Use Focus Stacking

  • Macro photography where depth of field is inherently razor-thin
  • Landscapes with very close foreground elements (inches away) and distant backgrounds
  • Any situation where even f/16 leaves important elements soft
  • When you want maximum sharpness (f/8) throughout a deep scene instead of diffraction-limited f/16 sharpness

Focus stacking takes practice and adds post-processing time, but it solves problems that no in-camera technique can.

The Diffraction Limit and When Too Narrow Hurts

Stopping down for more depth of field comes with a catch, and that catch is diffraction.

When light passes through a very small aperture, it bends around the edges of the aperture blades. That bending spreads the light slightly and softens the image, and the smaller the aperture, the stronger the effect.

On most cameras, diffraction becomes visible around f/16. By f/22, the softening is strong enough that you're losing more sharpness to diffraction than you're gaining from the extra depth of field.

That creates a practical ceiling. You can't just crank the aperture to f/32 and expect everything to be razor sharp, because past a certain point you're making everything softer.

The diffraction-limited aperture varies by sensor.

Sensor Diffraction visible Diffraction significant
Full-frame Around f/16 By f/22
APS-C Around f/11 By f/16
Micro Four Thirds Around f/8 By f/11

This is why f/8 to f/11 is the practical sweet spot for most cameras. You get substantial depth of field while staying below the diffraction threshold.

If f/11 doesn't give you enough depth and you can't step back or use a wider lens, use focus stacking instead of jumping to f/22.

Practical Workflows for Different Scenarios

Let me walk you through specific situations and the approaches that work.

Standard Landscape with Foreground Interest

You're photographing a mountain scene with interesting rocks in the foreground, maybe 6-8 feet away, and the mountains are miles distant.

  1. Set the aperture to f/11.
  2. Calculate or estimate the hyperfocal distance (or use a smartphone app).
  3. Focus at that distance, which will fall somewhere between the rocks and the mountains.
  4. Use a tripod, since f/11 may require slower shutter speeds.
  5. Check your shot by zooming in on both the foreground and the background.

For most wide-angle landscape situations, this single-shot approach at hyperfocal distance works perfectly. The landscape focus guide adds field methods for when you have no chart or app, and a step-by-step workflow for landscape shoots.

Rocks in the foreground of a mountain lake with peaks rising behind
Focusing at the hyperfocal distance keeps both the near rocks and distant peaks sharp.

Close Foreground Element

Your foreground subject is very close, say wildflowers 2-3 feet away with a mountain backdrop.

  1. Try f/11 first, focused between the flowers and infinity.
  2. Check the result to see whether both are sharp enough.
  3. If they aren't, consider focus stacking, with one frame focused on the flowers, one on the middle distance, and one on the mountains.
  4. Blend the frames in post-processing.

Very close foreground elements often push beyond what a single shot can achieve, so be ready to stack.

Environmental Portrait

Your subject is a person in a meaningful location, like their workshop, their kitchen, or another significant setting. You want them sharp and the environment sharp too.

  1. Position your subject at a distance where a moderate aperture provides enough depth.
  2. Use f/8 to f/11.
  3. Focus on your subject's eyes, since they're the priority.
  4. Verify the background is acceptably sharp.

If your subject is too close for the background to stay sharp at f/11, ask them to step back. The depth of field math favors distance, and moving your subject a few feet can solve the problem.

A craftsman standing in a busy woodworking workshop
Moving your subject a few feet back helps the workshop behind them stay sharp too.

Real Estate Interior

Every corner of the room needs to be sharp, because buyers will examine the details.

  1. Use a wide-angle lens (the 16-24mm range is common).
  2. Set the aperture to f/8 or f/11.
  3. Focus roughly one-third of the way into the room.
  4. Use a tripod, since interior lighting often requires slower shutter speeds.
  5. Verify that the corners and far walls are sharp.

Wide angles combined with moderate apertures make real estate interiors straightforward, because the focal length does most of the heavy lifting.

Key Takeaways

  • Use f/8 to f/11 for best lens sharpness with deep depth of field, and avoid f/16+ where diffraction softens the image more than the extra depth helps.
  • Focus one-third into the scene (not on the foreground, not on infinity) to distribute depth of field across the entire composition.
  • Use focus stacking (multiple shots at different focus distances, blended in software) when close foreground and distant background exceed single-shot depth of field.
  • A wider-angle lens provides more depth of field at the same aperture, so switch to a shorter focal length if you are struggling to get everything sharp.
Jon C. Phillips
Jon C. Phillips

Founder of Contrastly and co-founder of DailyPhotoTips

Jon has spent 14 years in the photography community as the founder of Contrastly and co-founder of DailyPhotoTips. His tutorials, articles, and resources have helped millions of photographers sharpen their skills and find their creative voice. You're in good hands.

Get Better Photos, Every Day

Five days a week, you get a quick photography tip in your inbox. The kind of stuff you can actually use on your next shoot.

    Join tens of thousands of photographers. It's free. Unsubscribe anytime.

    Ready to level up your photography?

    Get actionable and practical photography tips in your inbox every morning. Short reads, real results.