Getting everything in a photograph in focus is not always possible, and not always desirable.This distance from the front to the back of the sharp area is the depth of field, indicating how much of your photograph is in focus.
A shallow depth of field highlights part of the scene by giving two distinct areas of the image. This isolates the sharply-focused subject from the blurry indistinct background, leaving no doubt what the photographer considers important in the image. Common examples are portraits where irrelevant background clutter may detract from the image. The classic cases are trees and poles seemingly growing out of people’s heads.
Another use is to pick people out of a group or crowd, by careful focusing and using a shallow depth of field. For example, in a photograph of a President, assign minor officials and Secret Service agents lesser status by showing them out of focus.
There are two main avenues for producing this shallow depth of field; the main method is to select a wide aperture (or smaller f number). The other is using longer focal length, or telephoto, lens that appear effective in reducing depth of field in most situations. However, when taking extreme close ups or macro shots even very short focal length or wide angle lenses have a shallow depth of field.
Conversely, in landscape photography the intention is to get as much of the scene in focus as possible. To do this, reverse the basic settings used for a shallow depth of field. Use a shorter focal length lens and set the aperture to a small size (or high f number). As a rule of thumb, try to focus at a point in the middle distance to make maximum use of the available depth of field.
This is an advanced technique used by serious landscape photographers to use all of the depth of field available. The traditional technique uses markings put on the lens by the manufacturer. First focus at the furthest point in the scene, then look at the distance indicated by the focusing ring that lines up with the selected aperture value on the hyperfocal scale on the lens barrel. Re-focusing at this closer (hyperfocal) distance moves the whole depth of field closer to the camera. Now more of the foreground is sharper and allows the farthest point in the scene to line up with the back edge of the depth of field.
Although modern lenses have done away with hyperfocal scales, the method does highlight making the most of the area of sharpness. In the twenty first century there is a wealth of help on the internet for calculating all you ever wanted to know about depth of field distances for a wide combination of cameras, lenses, apertures and distances to the main subject.