It is actually extremely simple: Don't act online how you would not act in person.
In-person communication is rife with unspoken, yet understood, shared knowledge: body language, facial expressions, tone of voice, information about social standing between two individuals, etc.
Whereas we're still sorting out how to properly interact online, having only been doing it (at scale) for ~20 years.