A nine-year-old girl became trapped in the sand at West Wittering beach on Saturday after a hole she had been digging gave way, a Coastguard spokesman said.
The Selsey Coastguard team was called after the girl became covered in sand when the hole collapsed.
Fortunately, members of the public managed to dig her out, the spokesman said.
She was then checked over by lifeguards and a coastguard rescue officer.
The spokesman said: “The parents of the child, lifeguards and the team would like to thank the quick thinking of the members of the public that were on the beach for helping the child and digging her out with their hands.
“Thankfully the child was OK, although a little sandy and shocked.”
The Coastguard spokesman issued a warning about digging deep holes in the sand following the incident.
The spokesman said: “Sand hole collapses are rare but can be lethal if you become trapped in one.
“There’s nothing wrong with digging holes at the beach and filling them with water for your kids to play in.
“But if you dig a hole so deep that your head is barely poking out or burrow into a sand dune then you could be putting your life at risk.
“If it’s taken you three hours to dig your hole – that’s how long it might take someone to dig you out.
“These deeper types of holes are highly unstable.
“The wet harder sand that you dig out will dry out in the sun making it loose and the deeper you dig the more danger there is of the hole collapsing inwards and potentially trapping you inside.
“The best way to rescue someone is to create a circle of people digging with their hands, then another outer circle will do the same while also removing the sand from the first circle, more circles of people digging will be added as they become available.
“This will then create a wider shallow hole with no risk of any further sand hole collapse.
“We want you to enjoy yourselves at the beach – that’s what it’s there for – just take extra care when digging large holes that could trap you if they collapse.”
Earlier the same day, the Selsey Coastguard team was called to three reports of missing children at West Wittering beach.
The spokesman said: “Thankfully all children were found shortly after arriving on scene.”
Free ‘child safe’ wristbands are available at the Lifeguard Tower at West Wittering Beach, the spokesman said, adding: “Please make sure you use them and keep an eye on your children at all times when visiting the beach.”