Headlight flashing is the act of quickly triggering the high beam feature of car headlights in rapid succession. The meaning of headlight flashing is ambiguous as it changes depending on the circumstances. It's often used in an act of road-rage, but you equally see its use in friendly, courteous scenarios. Problem is, it's the ambiguity that causes accidental collisions, which is why you aren't supposed to rely on headlight flashing as a proper means of communication between motorists.
The highway code states that you should "only flash your headlights to let other road users know that you are there. Do not flash your headlights to convey any other message or intimidate other road users".
That's the official line on flashing your headlights, however with that being said, below are some of the other real-life scenarios where you will encounter drivers flashing headlights.
Ironically, you may not be able to see the headlights of the Audi behind you if you're being tailgated, however tailgating typically comes in a package of hand gestures, headlight flashing and driving dangerously close to your car. In this scenario, the person behind will simply want you to move out of their way.
There's no limit to the lengths people experiencing road rage will go to make you aware of the fact that you've annoyed them. If you pull out on to a main road at night time when you probably shouldn't have, you'll be met with a barrage of flashing lights as they're not supposed to blow the horn during the darker hours of 11:30pm to 07:00am. That being said, you're also not supposed to be flashing your headlights in anger, but they're only going to get caught doing it by yourself and oncoming traffic.
This is the most common reason that drivers flash their headlights; to let other road users or pedestrians go. Equally, you may see the oncoming driver flashing their headlights back at you in thanks.
A prime example of this is if you've got a flat tyre. Usually, UK motorists tend to take offence when somebody blows their horn at them, so headlight flashing can be perceived as more of a harmless way of getting somebody's attention to warn them that something is wrong. This will usually be followed up by the motorist making a gesture at you to safely pull over.
Country lanes are notoriously thin, both in the way that they're built and the environmental hazards that can form, such as excess mud or standing water. Corners can be very dangerous as the often high hedges leave drivers with reduced vision of any oncoming traffic. A quick flash of your lights is usually enough of a signal to make yourself aware to other people driving on the oncoming lane.
A little bit rarer, but sometimes when spotting a friend or family member while out on the road, you'll see people exchange a brief flash of their high beams to greet each other as they pass by.
It's more appropriate to flash your hazard lights - that is what they're there for after all - but as your hands are so much closer to the indicator stalk on which the high beam functionality resides, it's often quicker to flash your headlights instead.
Many see mobile speed cameras as a cash grab exercise by the government and seek to show their protest by alerting other motorists, who shouldn't actually be worried about the camera unless they themselves are speeding. You should never be flashing your headlights to warn other road users of a speed trap ahead.
This usually means speed up, move over or the driver is trying to get your attention. You'll mostly encounter this on motorways or by impatient motorists encouraging others to break the speed limit. If someone is flashing headlights at you, it's best to deescalate the situation rather than let the other driver get a rise out of you.
A common habit of lorry drivers is flashing overtaking vehicles to let them know that they have safely passed the lorry. This is because they spend a lot of time in the left hand lane of the motorways due to speed restrictions, which further means they're spending a lot of time amongst other lorries in the same scenario. As lorries are so long in length, it's hard to gauge where the end of the load ends from the perspective of the driver, hence the courtesy flash.
Headlight flashing is (typically) performed by quickly and repeatedly pulling your indicator stalk towards you, which activates your high beams.
Yes, it can be illegal in some circumstances to flash your headlights. One of the occasions where flashing headlights would be illegal is to warn other motorists of an upcoming speed trap, as mentioned previously. It is illegal and can incur a fine of up to £1,000 for breaching section 89 of the Police act 1996 as it's an offence to "wilfully obstruct a constable in the execution of his/her duty".