From CS2800 wiki
Definition: Surjective
A function [math]f : A \href{/cs2800/wiki/index.php/%5Cto}{\to} B [/math] is surjective if for every output [math]y \href{/cs2800/wiki/index.php/%5Cin}{\in} B [/math], there exists an input [math]x \href{/cs2800/wiki/index.php/%5Cin}{\in} A [/math] such that [math]f(x)=y [/math].
Onto is a synonym for surjective.

In short, every element of the codomain gets "hit". (Mnemonic device: the prefix sur- means "over" or "above", as in "surcharge" or "surname", etc. So each element of the codomain has at least one preimage (and maybe more)).

The following function is not surjective:


because there is no [math]x \href{/cs2800/wiki/index.php/%5Cin}{\in} \href{/cs2800/wiki/index.php/Enumerated_set}{\{a,b\}} [/math] with [math]f(x) = 3 [/math].