Yes. For formal events that allow shorts for men, opt for a slightly longer length. A 7-inch or 9-inch length is best unless you're fairly tall. An 11-inch works well for formal occasions, as long as they still sit above your knee.
For casual summer outings, a 5-inch or 7-inch is perfectly fine. A looser fit is also okay, especially for walking along the beach or taking part in any summer sports.