The evolution of the long necks of giraffes has been the subject of much debate.
The standard story is that they were evolved to allow the giraffes to browse vegetation that was out of the reach of other herbivores in the vicinity, giving them a competitive advantage.
However, an alternative theory proposes that the long necks evolved as a secondary sexual characteristic, giving males an advantage in "necking" contests to establish dominance and obtain access to sexually receptive females.
This theory notes that giraffes frequently feed from relatively low-lying shrubs, and that the necks of males are significantly longer than those of females.
However, this theory is not universally accepted, and some of the data supporting it has recently been challenged, lending support to the original proposal that neck length is related to browsing habits. Wikipedia