It is mainly found by jumping into blue [!] Blocks and looks like a transparent version of Mario's regular cap.
Upon collection, Mario will put on the Vanish Cap and become partially invisible. With this cap, he is able to temporarily move through steel bars and special walls.
In Big Boo's Haunt, in the mission Eye to Eye In The Secret Room, Mario must collect a Vanish Cap in the main room on a ledge and make his way to the room next to it, Wall Jump to a balcony above the door, and enter into the attic and jump into the Boo portrait, and meet Mr.I. Mario must then circle around the enemy until it spins oit and gives Mario a Power Star.
If Mario discovers the moat underneath the castle, a hole will eventually appear and Mario can enter it. Down here, Mario must set across some obstacles to get to a Vanish Cap. Once collected, he must jump into a cage containing a Power Star.
If the Vanish Cap ends up falling onto a slope (which happens in one of the slide levels), it will sometimes slide around and slide down the slope, making Mario unable to collect it, as it slides and falls faster than Mario, and thus unable to complete the level, collect all coins or fullfill the current mission objectives.
Trying to collect the sliding Vanish Cap with a well timed Forward Charge, he will put the cap on in mid-air and will become uncontrollable, possibly ending him in a bottomless pit.