Hair has two distinct structures - first, the follicle itself, which resides in the skin, and second, the shaft, which is what is visible above the scalp.
The hair follicle is a tunnel-like segment of the epidermis that extends down into the dermis. The structure contains several layers that all have separate functions. At the base of the follicle is the papilla, which contains capillaries, or tiny blood vessels that nourish the cells. The living part of the hair is the very bottom part surrounding the papilla, called the bulb. The cells of the bulb divide every 23 to 72 hours, remarkably faster than any other cell in the body.
Two sheaths, an inner and outer sheath, surround the follicle. These structures protect and form the growing hair shaft. The inner sheath follows the hair shaft and ends below the opening of a sebaceous (oil) gland, and sometimes an apocrine (scent) gland. The outer sheath continues all the way up to the gland. A muscle called an erector pili muscle attaches below the gland to a fibrous layer around the outer sheath. When this muscle contracts, it causes the hair to stand up which also causes the sebaceous gland to secrete oil.