Hi,
In facts IP adress is a serial of 4 binary numbers, each one is coded on 8 digits. And so is the subnet mask.
So 255.255.255.0 is :
1111 1111.1111 1111.1111 1111.0000 0000
Well, the part of IP corresponding to '1's is the net number, and the part corresponding to '0's is the host number.
Now, how to define the subnet mask; you can refere to this rule : if you have got a great number of networks whit a small number of hosts in each one, you'll have to put lot of '1's right of the subnet mask.
With the sn mask sample above, you'll be able to adress thousands networks & 253 hosts in each one.
If you have a small number of networks with thousands hosts in each one, the number of '1's in your sn mask will be reduced :
with 255.0.0.0 as subnet mask, you'll be able to adress 253 subnets with thousands hosts in each one (without considering restrictions on networks classes)
Hope will help