The lungs are located in the thoracic cavity, within the rib cage, on either side of the heart. The base of each lung rests on the diaphragm, a muscular structure that separates the thoracic cavity from the abdominal cavity. The lungs extend from the collarbone to the diaphragm and are protected by the rib cage.