A defect inspecting apparatus of the invention solves a problem that in a
defect inspecting apparatus, because of improving detection sensitivity
of a microscopic defect by reducing a detection pixel size, a focal depth
becomes shallow, a height of imaging is varied due to environmental
change and the detection sensitivity of a defect becomes unstable. This
apparatus comprises an XY stage, which carries a substrate to be
inspected and scans in a predetermined direction, and a mechanism having
a system of irradiating a defect on the inspected substrate at a slant
and detecting the defect by a detection optical system disposed on the
upper side, which corrects a height of imaging in real time for change in
temperature and barometric pressure in order to keep the imaging in a
best condition.