Nanophotonic light trapping for solar cells is an exciting field that has seen exponential growth in the last few years. There has been a growing appreciation for solar energy as a major solution to the world's energy problems, and the need to reduce materials costs by the use of thinner solar cells. At the same time, we have the newly developed ability to fabricate controlled structures on the nanoscale quickly and cheaply, and the computational power to optimize the structures and extract physical insights. In this paper, we review the theory of nanophotonic light trapping, with experimental examples given where possible. We focus particularly on periodic structures, since this is where physical understanding is most developed, and where theory and experiment can be most directly compared. We also provide a discussion on the parasitic losses and electrical effects that need to be considered when designing nanophotonic solar cells.