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 likepoles facing each other, the lines of force arein opposite directions and hence like poles repel each other. When the unlike poles of a bar magnet face each other the magnetic lines of force are in the same direction and henceunlike poles attract each other.