Superiorly, the spinal cord is continuous with the medulla. It extends from the level of the upper border of the first cervical vertebra to the lower border of the first lumbar vertebra. A transverse section through the spinal cord reveals an H-shaped mass of gray matter in the center of the spinal segment. The ventral or anterior portion of this gray matter (ventral horns) is composed of nerve nuclei that mediate motor output (efferent neurons). The dorsal or posterior portion of the gray matter (dorsal horns) is composed of nerve nuclei that mediate sensory input coming from the peripheral nervous system (afferent neurons). From the top to the bottom of the cord there are a series of thin nerves coming out of the cord on both sides. These are the spinal nerves, and are part of the peripheral nervous system. The spinal cord has enlarged regions in the cervical and thoracic regions, due to the increased number of neurons in the gray matter that supply those regions.
Motor neurons that are part of the CNS are called upper motor neurons (UMN). Neurons that are part of the PNS are called lower motor neurons (LMN). For spinal nerves, which are LMN, the nuclei that contain the cell bodies for these nerves are located in the gray matter of the ventral horns of the spinal cord. Also in this gray matter are terminal nuclei of the upper motor neurons. So the information is passed in these ventral horns from UMN to LMN, and sent out to the periphery. This concept is the same for sensory neurons in the dorsal horns.