The dorsal horns are the regions where many somatic and autonomic (= visceral) sensory neurons terminate after entering the spinal cord. Here, they synapse with interneurons, which carry the sensory information to other parts of the CNS. Many of the interneurons use the gray commissure to cross to the other side of the spinal cord.
The ventral horns are the regions where many motor pathway interneurons terminate. Here, they synapse with somatic motor neurons, which then exit the spinal cord.
The lateral horns are the regions where many autonomic motor neurons (sympathetic division) originate.