[imath]A[/imath]The book I'm currently reading gives the following definition.
A function is surjective (a surjection or onto) if every element of the codomain is the output for at most one element from the domain.
The other book I'm referring to is more formal.
[imath]F[/imath] is a relation from [imath]A[/imath] to [imath]B[/imath]. Then [imath]F[/imath] is called a function from [imath]A[/imath] to [imath]B[/imath] if for every [imath]a\in A[/imath] there is exactly one [imath]b \in B[/imath] such that [imath](a,b)\in F.[/imath] In other words
[math]\forall a \in A \exist !b\in B((a,b)\in F)[/math]
Suppose [imath]f:A\rightarrow B[/imath]. We say that [imath]f[/imath] is onto if
[math]\forall b\in B \exists a\in A (f(a)=b)[/math]
The range of [imath]f[/imath] is the set
[math]Ran(f)=\lbrace b\in B:\exist a\in A (a,b)\in f\rbrace[/math]
We can relate the definition of onto to the definition of range.
[math]\begin{aligned} f \,\text{is onto iff} \quad & \forall b\in B \exist a\in A (f(a)=b) \end{aligned}[/math][math]\begin{aligned} f \,\text{is onto iff} \quad & \forall b\in B \exist a\in A ((a,b)\in f) \end{aligned}[/math][math]\begin{aligned} f \,\text{is onto iff} \quad & \forall b\in B (b\in Ran(f))\end{aligned}[/math][math]B \subseteq Ran(f)[/math]
Suppose [imath]f[/imath] is onto. By equivalence just derived we have [imath]B\subseteq Ran(f)[/imath], and by the definition of range we have [imath]Ran(f) \subseteq B[/imath]. Thus it follows that [imath]Ran(f)=B[/imath].