Internet trolls who create derogatory hashtags or post doctored images to humiliate others could face prosecution in England and Wales, BBC reports.
Inciting people to harass others online, known as virtual mobbing, could also result in court action, under new Crown Prosecution Service guidance.
The director of public prosecutions said it means they will prosecute "in the same way" as if it were offline.
But she stressed this did not mean prosecutors could "stifle free speech".
The new rules aim to help police identify online crimes more easily.
It also highlights those who post people's personal information, such as bank details - known as doxxing.
'Think about conduct'
Speaking to BBC Radio 4's Today programme, Director of Public Prosecutions Alison Saunders said: "The internet's not an anonymous place where people can post without any consequences. People should think about their own conduct.
"If you are grossly abusive to people, if you are bullying or harassing people online, then we will prosecute in the same way as if you did it offline."
However, Ms Saunders said context will be an important factor in decisions - for example "if you're offensive, the legislation would say you have to be grossly offensive, and that's quite a high test".
The CPS says it will use "considerable caution" before charging those posting "grossly offensive" material.
The changes come after a report found that one in four teenagers is abused online over their sexual orientation, race, religion, gender or disability.
The new guidelines will be subject to public consultation for 13 weeks.