Different species of foxes will have different habitat preferences. However, all will live in some sort of a den environment crafted either underground, in a cave or in dense brush.
The grey fox specifically creates its den using the inside of a hollow log or rock pile, with some habitats even reaching as high as the top of a tree due to the animal's ability to climb. Basically, a fox will live anywhere it feels safe and is able to hunt nearby. Many fox species, including the red fox, have adapted to human environments, such as cities and suburbs, where the hunting of small rodents is plentiful.