The group were captured by security cameras at the West Grimstead crossing, just outside of Salisbury.
Network Rail said 80 trains passed the spot every day, adding how "incredibly easy" it would be to be caught out while distracted.
A spokesman said trespass was both "illegal and also dangerous".
He said: "The last thing we want is for a family to lose their loved one over a selfie, so I strongly urge everyone to use level crossings safely and to stay alert."
It happened as the railway operator was launching a safety campaign to coincide with the start of the school summer holiday season.
Three youngsters stopped to take selfies on a footpath crossing a railway line used by trains travelling at more than 80mph.