Electrostatics
Electric charges of different polarity attract each other. Charges of the same polarity repel each other. The charges do not have to touch for this. The force on these charges is transmitted by the electric field.
Electric field
Separated electric charges cause the electric field. The intensity of the field depends on how much charge Q is separated and how far apart the charges are. The field becomes weaker and weaker the further we move away from the source. Unbalanced charges are sources of electric fields.
The direction of action of the electric field is defined as the direction of the force on a positive test charge. So if we bring a positive charge close to another positive charge, the charges repel each other. If the charges had opposite polarity, they would attract each other.
Fields cannot be seen. But the effect of a field can be felt as a force. If this force is measured with a test charge, the intensity and direction of the force can be represented as vectors in space. The direction and intensity of this force are visualised with field lines. Field lines are arrows in space that represent the force on a positive test charge. The direction of the force corresponds to the direction of the arrow. The intensity corresponds to the density of the lines. The figure below shows the fields of a positive and a negative point charge in space.

We now bring a positive test charge close to a positive charge (left figure). The positive charge repels the positive test charge. After all, the arrows point away from the charge. The intensity of the repulsion is high all around the charge, because many field lines can be seen here. The further we move away from the charge, the less dense the field lines are – the intensity of the force decreases.
A negative charge attracts the positive test charge. That is why the arrows in the right figure point towards the centre, to the negative charge.
Next we look at two charges in space that are equal in magnitude but have opposite signs. The field between a positive and a negative charge in space looks like this:

The field lines point away from the positive charge and towards the negative charge. To understand the course of the field lines, we consider a third, positive test charge that is added at some point in space. The direction of the force on this test charge gives the direction of the field line at the point where the charge is located.

At the chosen point, the distance of the test charge from the positive charge is greater than from the negative charge. That is why the repulsive force (blue arrow) is shorter than the attractive force (red arrow). The resulting force (thick black arrow) is the tangent to the field line. It gives the direction of the field at the point where the blue test charge is located.
Field lines describe the direction of the force. Because the Earth attracts things, the field lines of the Earth’s gravitational field point towards the centre of the Earth. The Moon lies within the field. It is attracted by the Earth in the direction of the field lines. Earth and Moon therefore behave like a negative charge in space that attracts a positive test charge.