What are the rules for an onside kick?

The main rule is that the ball has to travel 10 yards downfield before it can be recovered by the kicking team prior to the opponents touching it.

A kickoff is a free kick. Whoever recovers a kickoff gains possession of the ball. The ball must travel 10 yards downfield before the kicking team can touch it unless the receiving team touches it first within 10 yards. If the kickoff doesn't travel 10 yards downfield the receiving team is not obligated to attempt a return.

The kick must hit the ground, in addition to travel 10 yards to give the kicking team possession of the ball if they can recover the kick. That is why onside kicks are kicked straight into the ground.