When you focus on something at a particular distance there will be an area a bit closer than that distance which will also look sharp and an area beyond your focus point that will also look sharp. This area is called the Depth Of Field (DOF). The DOF varies depending upon a number of factors, and the online DOF calculator lets you play around with these factors to figure out how DOF works. As well as giving you some hard numbers it also generates a little diagram that shows you what is going on.
For any given camera body (sensor size) the DOF varies as follows....
- The greater the distance to your focus point (normally your subject) the greater your DOF;
- The smaller your aperture (larger f/ number) the greater your DOF;
- The shorter your focal length, the greater your DOF.
The hyperfocal distance is the focus distance that keeps things in focus as close as possible while also keeping the farthest points (horizon, sun, moon, stars etc) also sharp. If you want something very close to be in focus as well as the horizon then you will need a small aperture and also a wideish angle for your focal length.
Here's an example showing a large DOF. The lens was at 17mm, so pretty wide angle, and the aperture was f/8. I can't remember exactly where I set the focus but it was probably somewhere around the edge of the paving leading onto the beach.
Plugging in those numbers into the DOF calculator I see the hyperfocal distance is 1.92m and I could actually have everything in focus from just 1m away all the way to the horizon. I probably focused a bit farther away than I needed to but it has not caused a problem.
Here's an even more extreme example, at 10mm and f/8. Hyperfocal distance with this combination is 67cm with a DOF extending from just 30cm to infinity. It is also worth noting that there is not a sudden drop off in sharpness beyond either end of the DOF, it's just that things gradually become increasingly soft. The only thing that is truly sharp is the bit you focus on, but the DOF is an area which is "acceptably sharp". There is no hard and fast rule on what is "acceptably sharp" and the smaller you display the image the larger your DOF will actually seem to be, because you are shrinking the image and concealing the softness.
One final point to consider is the effect of post processing and sharpening on the final appearance of your image. I have long known that you should make sharpening your very final step after resizing, but have only recently started to apply that knowledge to my images. It makes a big difference.