Grass grows spontaneously only during map generation. Afterward, it can only spread from a nearby block. Grass can spread to any immediately adjacent dirt blocks at the same height, including diagonally. It can also spread one level above and as much as three levels below. The grass jumps directly from one block to the other and is not affected by gaps or other blocks being "in the way". In order for a grass block to spread, it must have a light level of 9 or brighter directly above it. Additionally, the dirt block receiving grass must have a light level of at least 4 above it and must not be covered by a block that reduces light by 2 levels or more. This includes any opaque block, as well as lava, water, ice, and some non-opaque blocks that light can't pass through, like slabs and stairs. Grass blocks can grow under all other transparent blocks, like glass, fences, torches, or pistons. If you need to transport grass out of any reason (e.g. to bring grass into a cave) you can "harvest" a grass block with a tool enchanted with silk touch.