An improved finite-element method for the analysis of dielectric waveguides is formulated in terms of all three components of the magnetic field H. In this approach, the spurious, nonphysical solutions do not appear anywhere above the "air-line," and therefore the present formulation is very useful for the analysis of the surface-wave modes of dielectric waveguides. The application of this improved finite-element method to the dielectric waveguides with perfect electric and magnetic conductors is also discussed. In particular, the discussion is how to use the conditions on a boundary surface of a perfect electric or magnetic conductor whose normal direction is not coincident with the direction of a coordinate axis. Application of these boundary conditions for perfect conductors to the dielectric waveguides with planes of symmetry reduces the matrix size. The strength of this approach to boundary conditions is not just the economical use of computer memory but the elimination of spurious solutions through rigorous enforcement of boundary conditions as well.