Igneous rock is formed when magma, molten rock from below the earth's surface, or lava, molten rock that has emerged from below the surface, hardens into a solid state. There are many different kinds of igneous rocks, depending upon where they harden and what materials are contained in them. Igneous rocks form Earth's crust.
Granite is a type of igneous rock. Granite is formed when magma is trapped and cooled within a crack or other opening in pre-existing rock below the surface. Because it cools and hardens slowly, granite has a coarse texture and individual pieces of material can be seen within the rock.
Cooling occurs much more quickly when lava reaches the Earth's surface. As a result, igneous rocks that form on the surface have smoother textures and much finer material. An example of an igneous rock that cooled on the surface is obsidian.
See the link below for more information about how types of igneous rocks are identified and classified.
Igneous Rocks are formed and crystallized from a molten state (magma). Igneous rocks comprise one of the three principal classes of rocks, the others being metamorphic and sedimentary. The rate of cooling and temperature changes determines the texture as well as the degree of crystallization, while the composition of the magma will determine the composition of the igneous rock. Igneous rocks are crystalline or glassy in nature.
There are two types of igneous rocks: intrusive rocks and extrusive rocks. Intrusive rocks (or plutonic rocks) are formed by cooling and solidification of magma inside the Earth’s crust. Intrusive rocks cool slowly and therefore the mineral crystals have the luxury of time to grow large. Examples are granite and gabbro.
While extrusive rocks (or volcanic rocks) are formed by cooling and solidification of lava on the Earth’s surface. Extrusive rocks cool quickly and therefore contain small mineral crystals. An example would be basalt.