One can also directly deploy the linear transformation
$y(x) = \dfrac{\pi}{b - a} \left (x - \dfrac{a + b}{2} \right ), \tag 1$
which takes the interval
$(a, b) \to \left (-\dfrac{\pi}{2}, \dfrac{\pi}{2} \right); \tag 2$
then
$\tan \circ y:(a, b) \to \Bbb R, \; x \to \tan y(x) \tag 3$
is one-to-one and onto; and in fact, it is differentiable and possessed of a differentiable inverse; we know it is one-to-one since its derivative
$(\tan \circ y)'(x) = (\sec^2 y(x)) y'(x) = \dfrac{\pi}{b - a} \sec^2 y(x) > 0, \; x \in (a, b); \tag 4$
thus $\tan \circ y$ is montonically increasing and hence one-to-one; $\tan \circ y$ is seen to be onto since
$\tan \circ y(x) \to -\infty, \; x \to a^+, \tag 5$
$\tan \circ y(x) \to \infty, \; x \to b^-, \tag 6$
and thus for any $\rho \in \Bbb R$ we may choose $a_0, b_0 \in (a, b)$ with
$\rho \in (\tan \circ y (a_0), \tan \circ y(b_0)) \subset [\tan \circ y(a_0), \tan \circ y(b_0) ]; \tag 7$
since then
$\tan \circ y(a_0) \le \rho \le \tan \circ(b_0), \tag 8$
we have, by the intermediate value theorem,
$\exists z \in [a_0, b_0], \; \rho = \tan \circ y(z), \tag 9$
and we see that $\tan \circ y$ is onto $\Bbb R$.
Now since $\tan \circ y:(a, b) \to \Bbb R$ is both ono-to-one and onto, we conclude that $\vert (a, b) \vert = \vert \Bbb R \vert$ for any $a, b \in \Bbb R, \; a < b$.