Closet shelves made of flimsy materials are annoying to look at when they sag beneath the weight of their contents and in extreme cases may even collapse, causing breakage and inconvenience. The extra expense is worth acquiring shelving material to hold whatever you want to put on the shelf. The expense will soon be forgotten, but the strong shelves will endure.
Unless you're putting extremely heavy things on your closet shelves, solid wood should be adequate for the task. Spruce is a softwood that is one of the less expensive woods available on the market, and, although it is not as strong as some hardwoods, will probably support anything you want to place on it. You can build a shelf out of 1-inch thick pine boards or be extra safe and just buy spruce 2x4s and line them up to create a shelf. Two inches of solid wood, no matter what the species, will hold a lot of weight. Alternatively, you can make attractive hardwood shelves out of oak that will be strong enough to hold anything that you care to set on them.
Video of the Day
Plywood is a very strong material that is resistant to both sagging and warping. The main reason for this is its construction; plywood is made out of five layers of wood, with the direction of the grain alternating, which helps to eliminate weaknesses caused by grain direction by creating a crisscross structure of strength. Plywood shelves can be further strengthened by doubling up the layers of plywood or by cutting 2-inch wide strips and attaching them in a stand-up position to the bottom of the shelves. With these strips glued and nailed to the bottom of the plywood, it is far more resistant to sagging under weight.
MDF stands for medium density fiberboard, which is a sheet product, usually sold in sheets that are 4x8 feet in size, that is made up of reprocessed paper waste. MDF isn't as strong as solid wood or plywood but works fine for closet shelves. One way to make MDF more resistant to sagging is to avoid using it to span more than 3 feet. If you are putting it into a closet that is 2-feet wide, this isn't a problem. In a wide closet with folding doors, you can build a partition or other divider in the center of the closet, which allows you to put an MDF shelf on each side of the partition that only needs to span half the width of the closet. You can also add strengthening strips to the bottoms of the MDF shelves in the same manner as the plywood shelves.