Floating shelves are best secured into wall studs. If necessary, they can be attached to plaster or drywall; if you go this route, make sure you have the proper wall anchors (a.k.a. molly plugs) for the potential load of the shelf.