Rebecca Aydin/Business Insider
Appositives act as synonyms for a juxtaposed word or phrase. In the above example — "While running, I saw a mallard, a kind of duck" — "A kind of duck" is the appositive, which gives more information about "a mallard."
If the appositive occurs in the middle of the sentence, both sides of the phrase need a comma. As in: "A mallard, a kind of duck, attacked me."
Don't let the length of an appositive scare you. As long as the phrase somehow gives more information about its predecessor, you usually need a comma.
"A mallard, the kind of duck I saw when I went running, attacked me."
There's one exception to this rule. Don't offset a phrase that gives necessary information to the sentence. Usually, commas surround a non-essential clause or phrase. For example, "The duck that attacked me scared my friend" doesn't require any commas. Even though the phrase "that attacked me" describes "the duck," it provides essential information to the sentence. Otherwise, no one would know why the duck scared your friend. Clauses that begin with "that" are usually essential to the sentence and do not require commas.