An elegy is a mournful, melancholic poem, usually written as a lament for someone who has died.
In ancient Greek poetry, the term elegy referred to a very specific form of poetry. Although Greek elegies could be about a wide variety of topics, they had to be written in elegaic couplets, meaning in pairs of lines that had a very specific pattern of stressed and unstressed syllables.
In later times, the word elegy came to mean that the topic of the poem was mournful, even the form of the poem might be completely unlike the ancient Greek elegaic couplets.
One of the most famous elegies in the English language is Thomas Gray's "Elegy Written in a Country Churchyard," in which the poet reflects on the lives of the simple people who are buried in a rural churchyard. Although the poem clearly is elegaic in content, it does not use any of the technical forms of the ancient Greek elegies.