In costal inhalation, the lungs are expanded and inflated with air because of upward movement of the rib cage. The expansion of the rib cage is sufficient to allow the needed volume of air to enter the lungs. There are two different types of movements of the ribs that produce this expansion of the rib cage.
One type of movement involves the so-called "bucket handle" effect. As each rib swings upon its ends, like a bucket handle swinging up from the sides of the bucket, the rib moves upward and outward laterally. As this type of movement occurs on both sides of the rib cage, the transverse diameter of the rib cage increases from side to side.
The second type of movement is described as follows: The lowest points of the ribs are their front ends at the sternum. During inhalation, these front ends move upward and forward along with the sternum. This increases the diameter of the thoracic cavity from front to back.
The increases in the transverse and anterior - posterior diameters enlarge the volume of the thoracic cavity and thus decrease the pressure of the air inside (Boyle's law). Thus, there is a relatively higher atmospheric pressure outside.
This pushes air into the respiratory passageways and into the alveoli of the lungs. The alveoli are inflated by this inflowing air.
The lungs empty during costal exhalation, a process that is essentially the reverse of costal inhalation. The rib cage moves downward as a whole. In small-volume exchanges, the costal cartilages are sufficiently resilient (elastic or springy) to pull the rib cage downward.
With greater-volume exchanges, musculature can be recruited to aid in lowering the rib cage. Gravity may also play a role. As the transverse and A-P diameters decrease, the volume of the thoracic cavity also decreases. This increases the pressure of the air inside (Boyle's law). Thus, there is a relatively lower atmospheric pressure outside, and air is forced out of the lungs.