Proving a set is connected in $\mathbb{R}^2$

Let $B = \{(x,y) \in \mathbb{R}^2 : x\in \mathbb{Q} \text{ or } y\in \mathbb{Q}\}$. Prove that $B$ is either connected or disconnected.

I am not sure if this logic is correct but I believe its connected because if we let $x$ be a rational coordinate and $y$ be an irrational coordinate they'll be no "breaks" since this set would span all of $\mathbb{R}^2$ hence making the set connected.

It can be easily shown, using the definition of the product topology and the fact that $\mathbb R$ is connected, that both the horizontal and vertical lines in $\mathbb R^2$ are connected subspaces.

We also have the following result:

If the intersection of a family of connected subspaces is nonempty, then the union of those subspaces forms a connected subspace.

The above is all that is needed to wrap this up.

Let $A = \{ (x,y) \in \mathbb R^2 \; | \; x = 0 \text{ or } y = 0 \}$

So this is a connected space.

For $q \in \mathbb Q$, define

$\tag 1 S_q = A \, \bigcup \, (\{q\} \times \mathbb R)$

and

$\tag 2 T_q = A \, \bigcup \, (\mathbb R \times \{q\})$

Each $S_q$ and $T_q$ is connected.

The union $S$ of the family $S_q$ is connected and the union $T$ of the family $T_q$ is connected.

The union of $S$ with $T$ is connected. But that is the subspace that the OP is analyzing.

Yes, it is connected. Actually, it's path-connected. Take $x\in\mathbb Q$ and $y\in\mathbb R$. Then $(x,y)\in B$. Consider the path$$\begin{array}{rccc}\gamma\colon&[0,2]&\longrightarrow&B\\&t&\mapsto&\begin{cases}(tx,0)&\text{ if }t\in[0,1]\\\bigl(x,(t-1)y\bigr)&\text{ if }t\in[1,2].\end{cases}\end{array}$$Then $\gamma$ is a path going from $(0,0)$ to $(x,y)$. A similar argument applieas if $x\in\mathbb R$ and $y\in\mathbb Q$.