In a firearm, headspace is the distance between the bolt face and some datum in the chamber. If it is chambered for a rimmed cartridge, then it is the distance to the face of the breech where the forward side of the rim will contact. For bottle-neck cartridges, it is the distance to a "datum ring", more or less the center of the shoulder. For belted magnums, it was originally to the face where the forward side of the belt would contact, but manufacturers got sloppy enough that they just headspace on the shoulder nowdays. Rimless straight cartridges, like .45 ACP, headspace on the mouth of the case.
Another way of saying it is that headspace is the distance from the bolt face to whatever stops the cartridge from going further forward into the breech.
If headspace is too tight, then the cartridge won't go into the chamber.
If the headspace is too loose, which is the condition that we most often worry about, then when the cartridge is fired, the case head has room to stretch and can fail.
To check the headspace, use a set of GO/NOGO gauges from Brownell's or Midway or wherever. If the GO gauge doesn't go, then the headspace is below minimum and cartridges made to SAAMI dimensions will not chamber. If the NOGO gauge goes, then the headspace is over maximum and the gun is dangerous. You can also get a FIELD gauge, which is similar to NOGO, but if it goes, then the headspace is at or near maximum and the firearm should visit a gunsmith.