We develop efficient and robust numerical methods in the finite element framework for numerical solutions of the singularly perturbed convection-diffusion equation and of a degenerate elliptic equation. The standard methods for purely elliptic or hyperbolic problems perform poorly when there are sharp boundary and internal layers in the solution caused by the dominant convective effect. We offer a new approach in which we design the finite element basis functions that capture the local behavior correctly. When the structure of the layers can be determined locally, we apply the multiscale finite element method in which we solve the corresponding homogeneous equation on each element to capture the small scale features of the differential operator. We demonstrate the effectiveness of this method by computing the enhanced diffusivity scaling for a passive scalar in the cellular flow. We carry out the asymptotic error analysis for its convergence rate and perform numerical experiments for verification. When the layer structure is nonlocal, we use a variational principle to gain additional information. For a random velocity field, this variational principle provides correct scaling results. This allows us to design asymptotic basis functions that can capture the global layers correctly. The same approach is also extended to elliptic problems with high contrast coefficients. When an asymptotic result is available, it is incorporated naturally into the finite element setting developed earlier. When there is a strong singularity due to a discontinuous coefficient, we construct the basis functions using the infinite element method. Our methods can handle singularities efficiently and are not sensitive to the large contrast.