Different rat species have preferences concerning the type of habitat is optimal for them. This will not limit them because they are able to adapt to availability. They will try to find a living and feeding situation that fits their preference, but they will live where it is most convenient and where there is a food source. The two most common types of rats that are encountered in North America are the Norway rat and the roof rat and one is a terrestrial rat and the other is arboreal.
Norway rats are a terrestrial rat that burrows into the ground. They build their nests in the ground in places like the base of the outside walls of a home, clumps of vegetation, under the edges of sidewalks and porches. They will find their way to attics and into trees if they have to.
Roof rats are, as their name suggests, arboreal rats that prefer elevated living arrangements. In a natural setting, they will build their nests in yucca, palm, and cypress trees. If they make their way into a home they will prefer attics, eaves, and rafters. Although this is their preference, they do not have to strictly abide by this preference.