Natural selection is an important mechanism of evolution. It states that the organisms that are able to survive and reproduce with the changing environmental conditions are selected by nature while the ones that cannot survive are eliminated. The genes responsible for the survival of an organism are passed on to the successive generations.
For eg., it is believed that the giraffes had shorter necks. Their feeding habits led to the elongation of their necks and the genes from such animals were transferred to the future generations. It took millions of years for the evolution of giraffe we see today.