A subnet mask is used to determine what the network address of an IP address will be. The subnet mask follows the same format as an IP address, four numbers (0-255) separated by decimal points. A very common one is:
255.255.255.0
The numbers in the subnet mask determine the length of the network address.
For example, the subnet mask above is saying that on this network all devices/IP addresses must have a common first three numbers.
It is important to note that the use of 255 is very common. The numbers are actually representative of 8-bit numbers which determine bits to look at, and by having the value 255 you are accounting for each bit. Since very bit is looked at, that means all the numbers in the subnet must be identical.
Let's say that the subnet is set to be 252.0.0.0, the first 6 bits then define the subnet.
11111100.00000000.00000000.00000000
This means you can have two devices on the same network even if the first numbers of the IP addresses are different. Let's look at the following IP addresses:
192.168.1.10
195.168.1.20
These can be on the same network because the first 6 bits are equivalent:
192 = 11000000
195 = 11000011