How do you make a shelf bracket?

my theory, a shelf will bracket when it d**n well wants to...... :).......had to......