A fog is a cloud in contact with the ground. There is no basic difference between a fog and a cloud floating high in the atmosphere. When a cloud is near or on the surface of the earth or sea, it is simply called fog.
The commonest fogs are those seen at night and in the early morning over the lowlands and small bodies of water. They usually are caused by a cold current of air from above striking down upon the warmer surface of the land or water.
In the autumn they are very common because the air is cooling faster day by day than the land or the water. On still nights after dark, thin layers of fog often form close to the ground in low places. As the earth cools at night, the lower air gets cooler. Where this cooler air meets the moist warmer air just above, fog forms.
As a general rule, city fogs are much thicker than country fogs. City air is full of dust and soot that mingle with tiny particles of water to form a thicker blanket.
Off the coast of Newfoundland, which is one of the foggiest parts of the world, fogs are formed by the passage of damp, warm air over the cold water flowing south from the Arctic Circle. The chill of the water condenses the moisture of the air into tiny drops of water. These drops are not big enough to fall as rain. They remain in the air as fog.
San Francisco fogs are formed in the opposite way. There a cool morning breeze blows over warm sand dunes, and if rain has moistened the sand the night before, a thick fog bank of evaporated moisture forms.
The reason fogs often seem denser than clouds is that the droplets are smaller in a fog. A large number of small drops absorb more light than a smaller number of large drops (as found in clouds), and thus it seems denser to us.
Read: Why Does Iron Get Rusty?