The horizon line is usually the dividing line between heaven and earth. Usually this line can be seen clearly when photographing on the beach or sea. You can determine which portion is bigger, the important thing is that the line is straight in the photo. Some tips to help you:
1. Use the help lines on the screen (grid)
Usually cameras and smartphones are equipped with a grid view display option. You can use it to see whether the horizon line is straight.
Source : www.helopedia.com
2. Use a tripod with a bubble level
Alternatively, you can use a tripod equipped with a bubble level which functions like a water pass which is usually used by builders. You can see whether the position of your camera and tripod is really straight. Usually when the camera and tripod are straight, the horizon line will also be straight.
Source : http://www.saveseva.com/
3. Adjust the bottom/top edge of the viewfinder
Sometimes not every photo shoot can use a tripod. You can use the top and bottom lines of your camera's viewfinder, especially if you prefer shooting with the viewfinder.
4. Take a benchmark of the building lines around you
When building a house, a water pass is usually used so that the building is straight. When taking photos you can also take advantage of this. Try to pay attention and adjust to the horizontal lines on the buildings so that your horizon line remains straight. Don't forget to also pay attention to the position where you are standing.
Source : http://www.saveseva.com/
5. Edit with software
You have done all the steps above but it turns out it's still not straight. You can edit with software, for example in Adobe Lightroom you can use the lens correction feature which is designed to overcome lens weaknesses such as distortion. But you can also use it to correct a misaligned horizon line.
Source : http://www.saveseva.com/
Apart from that, you can also use the rotate feature in several other software to help your horizon line look straight.