They can. They work like a box within the context of space. It just is that they are found in places where there might be too little space or because you have limited furniture to fill it up with etc.
However floating shelves make no compromise on safety either common sense tells us, for example if we put jars containing liquid products & flowers then make sure those things will not come falling down from their place everly time someone comes near them!