How does altimeter work?
As the name suggests the altimeter displays altitude above mean sea level to the pilot, the altimeter consists of a flexible aneroid capsule inside a case, the capsule expands or shrinks like a balloon when the static pressure changes as the aircraft's altitude changes.
The static pressure is fed only to the case by the static port which is exposed to the atmosphere around the aircraft, the capsule drives the pointer by a mechanical link to display the altitude in feet. In the atmosphere layer where training aircraft fly static pressure decreases at a constant rate as altitude increases.
For demonstration purposes let's assume that it means sea level static pressure has a value of 3 units, at 1,000 feet it has 2 units, and at 2,000 feet it has only one unit, in this example the ground level is the same as mean sea level, the capsule is sealed with a fixed amount of air inside, let's assume that the pressure inside the capsule matches the pressure inside the case, so both are three units and the altimeter is adjusted to display zero feet of altitude, when the aircraft climbs to 2,000 feet the static pressure decreases, inside the case the static pressure also drops from three to one, the capsule expands and drives the pointer to display 2,000 feet, conversely as the aircraft descends to 1,000 feet the static pressure increases from 1 to 2 and the capsule shrinks, driving the pointer to display 1000 feet, should the static port get blocked the static pressure will remain fixed inside the case and a constant altitude will be displayed whether the aircraft climbs or descends.