Depth of field (DOF) is the distance between the nearest and farthest objects in a scene that appear acceptably sharp in an image. Although a lens can precisely focus at only one distance at a time, the decrease in sharpness is gradual on each side of the focused distance, so that within the DOF, the unsharpness is imperceptible under normal viewing conditions.
The factors which affect depth of field are: aperture, focal length and distance to subject.
A short depth of field can be very useful when you want to isolate your subject from the background (portraits, macro), while a large depth of field is great when you want every detail to be in focus (landscape photography).
A large aperture (small f-number) such as f/1.4 or f/2 will produce a short or shallow depth of field, while a small aperture (large f-number) such as f/11 or f/16 will give you focus over a longer distance.
When it comes to lens, the shorter the focal length (10mm, 20mm, 35mm, etc.), the more depth of field is present. Extreme wide-angle lenses don’t even have to focus because they are sharp on every aperture. So if you have a wide angle lens and want a shallow depth of field, you need to move in closer to the subject. When the focal length grows longer (70mm, 100mm, 200mm, etc.) depth of field shrinks.
The distance between you and the subject is also important. If you are close to the subject, you will have a shallow depth of field, and if you go further away, depth of field will be longer. If you’re photographing a person but need to have a high f-number, you can still get a short depth of field by keeping the distance between you and the person you are photographing to a minimum.
“It’s important to know that the depth of field is greater behind the object than in front of it. If you want to photograph, let’s say 20 kids standing in a line, and you want as many of them as possible to be in focus, but you’re unable to have a small aperture, you should focus on the 6th-7th kid in line, which would balance the field of focus about right (depending on your distance to the kids). If you would focus on the 10th kid, that is the one in the middle, the first few kids would be more out of focus than the kids at the back of the line”
So to sum it up:
If you want a shallow (short) DOF, you need to open the aperture (small number) / move closer to the subject / zoom in to your longest focal length, or all of the above combined.
For a wider (longer) DOF you need to close down the aperture (large number) / use a wide angle lens / move further away from your subject, or all of the above.
Check out this video for a great DoF guide:
When the lens is focused at this distance, all objects at distances from half of the hyperfocal distance out to infinity will be acceptably sharp. It’s the focus distance giving the maximum depth of field at any aperture setting. If you focus closer than this, even by the slightest amount, then a distant background will appear soft.
In the above image HF is the hyperfocal distance. If you focus your lens to that distance, everything from half of that distance (HF/2) to infinity will appear in focus. Example: HS is 10m, so everything from 5m to infinity will appear sharp.
Hyperfocal distance is a function of the circle of confusion. You will find hundreds of explanations for the circle of confusion; and the debate over the "proper" circle of confusion has been raging for more than 70 years and will probably be raging forever…
Precise focus is possible at only one distance; at that distance, a point object will produce a point image. At any other distance, a point object is defocused, and will produce a blur spot shaped like the aperture (usually assumed to be circular). When this circular spot is sufficiently small, it is indistinguishable from a point, and appears to be in focus; this is what we call acceptably sharp. As the point you are photographing moves closer or further from the “focus point”, it’s diameter will increase. The largest circle that is indistinguishable from a point is known as the circle of confusion. The increase of the circle diameter with defocus is gradual, so the limits of depth of field are not hard boundaries between sharp and unsharp.
Since the hyperfocal distance is different on every lens and camera, you need to calculate it first, using a Depth of Field Calculator. Once you get that, set the lens to manual focus, and input the obtained distance. If you look through the camera and see that everything is NOT in focus, don’t panic. That’s because when you look in the camera, the aperture is wide open, so you need to press the DoF preview button to close down the aperture blades.
The hyperfocal distance is best implemented when the subject matter extends far into the distance, and if no particular region requires more sharpness than others.