Question: I want to replace my kitchen cabinets (shoddy DIY stuff, very rough) with some nice floating shelves. 

I tried to find information on how to mount heavy stuff to wooden studs but all I found were information for what fasteners to use when mounting heavy stuff into drywall. 

What kind of fasteners do I need to use if I want to mount something that will be bearing heavy loads into a wooden stud?

Answer: 
The hardware needed will likely be dictated to some degree by the manner in which the shelves are supported and how much weight the shelves are being asked to support. A true floating shelf will often use a french cleat as Keshlam suggested, often in this situation an aluminum version called called a Z-clip. ![Z-clip ](https://i.stack.imgur.com/EsK2a.jpg)
This shows the short, clip style but it's available in 8' lengths too that you would cut to the length you need. 

These are easy to install and can hold some pretty extreme weights (the exact load maximums will be listed on the package or the website tech sheet) but the shelf has to be thick enough to encapsulate the thickness of the brackets plus the distance required to engage the two halves, plus some room for a lip top and bottom. Like so:
![z clip](https://i.stack.imgur.com/QABKa.jpg)

The good news is these are available in many sizes and can be found in most home centers or online for a reasonable price. The (possibly) bad news is you'll almost certainly have to make or at least modify a shelf to suit your needs. As far as hardware is concerned in general: use a good quality wood screw that gets at least 2" of bite into the shelf and on every stud that you can catch (you may have to enlarge the countersink to accept a larger screw head or drill some new holes to suit the spacing of your walls substructure) into both the shelf and the stud side. Unless your trying to support an unreasonable amount of weight you should be okay. 

Of course you can always just pick up a store bought floating shelf. Most come with a lightweight keyhole style hanger (seen here)
![keyhole](https://i.stack.imgur.com/Sbzwf.jpg)
but will still hold a fair amount (not much though). As for screws, they're often included with the kit but the same rules apply as previously discussed so if you buy a shelf package from Ikea or wherever and it comes with inch long screws or those plastic drywall anchors, do yourself a favor and go buy some real screws to mount it.
Your existing cabinets are probably mounded with screws long enough to reach through the cabinet back and the drywall, then go deep enough into the studs to support the weight.

The *right* way to mount cabinets is probably with a [French Cleat](https://en.wikipedia.org/wiki/French_cleat). Those can be as simple as a pair of bevel-cut boards, or can be metal brackets manufactured for the purpose.