Lang was born in Selkirk. He was the eldest of the eight children born to John Lang, the town clerk of Selkirk, and his wife Jane Plenderleath Sellar, who was the daughter of Patrick Sellar, factor to the first duke of Sutherland. On 17 April 1875, he married Leonora Blanche Alleyne, youngest daughter of C. T. Alleyne of Clifton and Barbados. She was (or should have been) variously credited as author, collaborator, or translator of Lang's Color/Rainbow Fairy Books which he edited. He was educated at Selkirk Grammar School, Loretto, and at the Edinburgh Academy, St Andrews University and at Balliol College, Oxford, where he took a first class in the final classical schools in 1868, becoming a fellow and subsequently honorary fellow of Merton College. He soon made a reputation as one of the most able and versatile writers of the day as a journalist, poet, critic, and historian.