The ancestors of giraffes had short necks, and there was great competition for plant food near the ground. Some giraffes kept trying to stretch their necks to reach leaves higher in the trees. As they stretched and stretched, their necks became longer. As their necks became longer, they were able to reach more food. Those ancestral giraffes survived to reproduce, while the giraffes that had not stretched their necks died. The offspring of giraffes with stretched necks inherited the longer necks. This process continued generation after generation. In this way, giraffes evolved with longer and longer necks.