I keep them close - as in even at 12, my eldest will talk to me about anything he's concerned about (or, lets face it, anything that pops into his head at the time)
I've taught them (as has experience) that everyone on the internet is a jerk - and how to keep themselves safe (well, as I can) by never using their real name or revealing info about themselves. To only friend people they know in real life.
We have chats about this sort of thing (and other similarly contentious subjects) where we actually talk back and forth, rather than lecture.
From very young, I supported their likes and dislikes, gave them free choice of clothes etc rather than pushing them towards gendered items exclusively (of course if they chose cars/diggers/mummy's little monster t-shirt that was as fine as fairy wands and glitter)
I think the really important thing is the the first though - maintaining a good relationship with them. Whilst there's no doubt I'm the parent, and I set boundaries, I try to be reasonable, and expect them to be reasonable (as far as a child can) in return, and that seems to be working out OK.