Most building codes require ceiling fans to be mounted on special fan-rated boxes, which are made of metal or strong plastic and have deep-threaded holes for the mounting screws. The box must be mounted firmly, either by attaching it directly to a framing member or by using a fan-rated brace.