Every magnet has a magnetic field around it which are represented by magnetic lines of force. The magnetic lines of force start from north pole and end at the south pole outside the magnet and and go from the south pole to the north pole inside the magnet. The density of the magnetic field lines is higher near the poles where the magnetic force is stronger. When two magnets are placed with their like(same) poles facing each other, the lines of force are in opposite directions and hence like(same) poles repel each other.