Why did the sauropods have such a long neck and tail?

 

                  The long neck of the sauropods is thought to be an adaptation to help the animals feed on tall trees, like the modern giraffe. The whole structure of these dinosaurs is a very clever piece of engineering, because their long neck, which was usually held out horizontally, was balanced by the weight of the tail. The vertebrae were shaped to allow the attachment of powerful muscles and rope-like tendons and ligaments, which held the whole structure together like a suspension bridge. Despite the great length of the neck and tail, they were not as flexible as we might think. They were usually stretched out almost in a straight line.

Picture credit: google