Exclamation Mark Block
From the Super Mario Wiki
Exclamation Mark Blocks (also often shortened in text form to ! Blocks) are floating blocks found in Super Mario World. At first all the player can see is Dotted Line Blocks, which is their outline, but after Mario or Luigi hits one of the ! Switches at the Switch Palaces, they become solid. Additionally, some Exclamation Mark Blocks contain various power-ups. Yellow blocks contain Super Mushrooms, and green blocks contain Cape Feathers. The red and blue blocks contain nothing and are used as platforms.
In Super Mario World 2: Yoshi's Island, Yoshi's Island: Super Mario Advance 3 and Yoshi's Island DS, the Dotted Line Blocks would temporarily become solid Exclamation Mark Blocks after a nearby ! Switch is pressed, allowing Yoshi and the baby riding him to use them as platforms.
In Super Mario 64, Exclamation Mark Blocks come in four different colors. Yellow ones contain Coins, Power Stars, 1-Up Mushrooms, or Koopa shells. Red ones contain the Wing Cap, the blue ones contain the Vanish Cap, and the green ones contain the Metal Cap. All ! Blocks (except the yellow variety) must be activated by hitting the corresponding ! Switch. If the switch isn't hit yet, the red, blue and green Exclamation Mark Blocks will be transparent and therefore cannot be hit. In Super Mario 64 DS, all Exclamation Mark Blocks, except for the yellow variety, were replaced by red ? Blocks. Special powers were based on the character that struck the block and not block colors. If Mario hits one, he'll get either the Wing Cap or will become inflated, if Luigi hits one he'll become invisible, if Wario hits it, he'll become metal, and if Yoshi hits one, he'll get fiery breath.
A few Exclamation Mark Blocks also appear in Mario & Luigi: Superstar Saga and Mario & Luigi: Partners in Time. They have various functions and can activate events. Purple colored Exclamation Mark Blocks are introduced in these games, which have varying effects. Three special Exclamation Mark Blocks in Mario & Luigi: Partners in Time are used to create three giant Exclamation Mark Blocks on Yoshi's Island and destroy giant Exclamation Mark Blocks of the same color in Thwomp Volcano, allowing the Mario quartet to traverse further down the volcano. The blue variety later appears in the Star Shrine, where it would change color depending on whether Baby Mario or Baby Luigi hit it.
Exclamation Mark Blocks can also be seen as part of the treasure hoard inside the safe in the Mario Party minigame Key-pa-Way. One of the Exclamation Mark Blocks is purple. Also, in the Mushroom Bank, the safe that keeps the items bought from the Mushroom Shop resembles a red Exclamation Mark Block.