Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
I'm replacing a light fixture, but upon removing the old light I discovered the wires are not in a box. Can I just anchor the mounting plate to the drywall or is a box mandatory?
There are instance where this is possible and legal, such as bathroom vanity bar type lights with an integral and complete back plate. Other than that a box is absolutely mandatory.
Here is a good example. Imagine these fixtures flush against the wall.
The simple answer is: yes, a box is required. Any electrical splices and connections must be enclosed appropriately and grounded if metal.
Required, but never shown