In more detail
A device compares each destination with its own Subnet mask. Local destinations are reached directly; anything else goes to the gateway, which is usually the first address in the subnet, such as 192.168.1.1. A wrong or missing gateway means a device can talk to its neighbours but not reach the internet.