I have my babies in Reptile Basics racks, so- dark inside. The babies all have toilet paper tubes or toothpaste boxes, flattened, and all either use those or burrow under the substrate.
It isn't the darkness that is the most attractive feature for the snake, it's the close fit. You can see this demonstrated when reptile exhibits offer clear glass plates as hides. You'll see coral snakes curled up cozily beneath the glass, right in broad daylight. The snake feels the enclosed space, and thinks it is in a safe place.