The cranial nerves are composed of twelve pairs of nerves that emanate from the nervous tissue of the brain.  In order reach their targets they must ultimately exit/enter the cranium through openings in the skull.  Hence, their name is derived from their association with the cranium.  The function of the cranial nerves is for the most part similar to the spinal nerves, the nerves that are associated with the spinal cord.  The motor components of the cranial nerves are derived from cells that are located in the brain.  These cells send their axons (bundles of axons outside the brain = a nerve) out of the cranium where they will ultimately control muscle (e.g., eye movements) , glandular tissue (e.g., salivary glands) or specialized muscle (e.g., heart or stomach). The sensory components of cranial nerves originate from collections of cells that are located outside the brain. These collections of nerve cells bodies are called  sensory ganglia. They are essentially the same functionally and anatomically as the dorsal root ganglia which are associated with the spinal cord.  In general, sensory ganglia of the cranial nerves send out a branch that divides into two branches: a branch that enters the brain and one that is connected to a sensory organ. Examples of sensory organs are pressure or pain sensors in the skin and more specialized ones such as taste receptors of the tongue. Electrical impulses are transmitted from the sensory organ through the ganglia and into the brain via the sensory branch that enter the brain.  There are two exceptions to this rule that should be noted when the special senses of smell and vision are discussed.  In summary, the motor components  of cranial nerves transmit nerve impulses from the brain to target tissue outside of the brain.  Sensory components transmit nerve impulses from sensory organs to the brain.