A numerical solution for the time harmonic electromagnetic fields in a unit cell of an infinite, planar periodic structure has been developed and validated. It uses a variation of the hybrid finite element method that includes periodic radiation conditions at the exterior surfaces and periodicity conditions at the unit cell walls inside the structure. This technique allows the method to deal with structures that include inhomogeneous dielectrics and conductors with arbitrary shape and orientation. This paper presents the formulation of the finite element problem and shows the results of test cases involving an inductive screen, an artificial dielectric, and a layered-dielectric bandgap medium. The results show that the new method is accurate and versatile.