The ability to have some parts of a picture in focus while others parts are blurred was probably one of my main reasons for buying an SLR camera. One way to determine how much of a picture is sharp (known as ‘depth of field’) is by altering the aperture.
The narrower the aperture (large f/number eg. f/22), the greater the depth of field (ie. most of the shot in focus).
The wider the aperture (smaller f/number eg. f/4), equals a shallow depth of field.
Two other factors effect depth of field. Firstly, focal length. As you zoom into a subject, the amount of depth of field reduces. Think of how wide-angles lenses (used for landscapes) keep everything in focus while telephoto ones (sports events, close-up wildlife) tend to blur the background.
Secondly, the distance between you to your subject. The closer your lens is focused, the less depth of field you’ll capture.
So to summarize, if you want to maximise the amount of depth of field, use a wide focal length, narrow aperture & don’t focus on anything too close to the camera.