A superiorplanet is in opposition to the Sun if the difference between the geocentric ecliptical longitude of the planet and of the Sun is closest to 180 degrees, so it is less just before and just after that moment.
The elongation is roughly equal to the distance, in the sky, of the planet from the Sun, measured in degrees.
The greatest possible elongation of a superiorplanet is always 180 degrees, when the planet is in opposition and therefore as far as possible from the Sun in the sky.