A 17-year-old sex offender caused a 12-year-old schoolgirl "grave harm" when he had sex with her at a squalid flat, a leading judge has said.

The teenager, who cannot be identified, met the schoolgirl through Instagram and they exchanged messages over the course of a number of months last year.

But he took the relationship further when he called her and got her to sneak out of her home in Hertfordshire and travel to Wembley to meet him, the Court of Appeal was told during a hearing on Tuesday (July 3).

The girl had never travelled alone before and was shocked to be taken to a dirty flat when she arrived, the court heard.

Other people were there, talking in a language she did not understand, and drinking and taking drugs.

She was given cocaine by older members of the party and, when they left, the 17-year-old climbed on top of her and had sex with her in a bedroom, the court was told.

She later told police he had not asked her for sex and she had felt unable to look at him as it was happening.

Afterwards, he barely spoke to her and she called her mother and left.

The youth was arrested and later admitted a charge of sexual activity with a child on the basis that he thought she was 14.

He was sentenced to an 18-month detention and training order at Harrow Crown Court in March.

He appealed over the sentence on Tuesday, but senior judges at the Court of Appeal said the sentence was what he deserved.

"The consequences of her first sexual experience happening in this way are, and will be, profound," said Mr Justice Edis.

"That's why children require the protection of the criminal law in the way they do."

The boy was vulnerable himself because he had no real relationship with his family, but he had used the girl for his own gratification, Judge Edis continued.

"This was a grave offence of its kind," continued the judge, who was sitting with Lady Justice Hallett and Sir Andrew Smith.

"We consider that a sentence of detention and training for 18 months is not manifestly excessive."

The appeal was accordingly dismissed.