A class selector is a name preceded by a full stop “.” and an ID selector is a name preceded by a hash character “#”. The difference between an ID and a class is that an ID can be used to identify one element, whereas a class can be used to identify more than one.
Basically they are used to target an element. to target an element using id you need to give id to your element which you want to target id can be any name and in css to target it write "#" character before the name of id like this "#demo". Id must be Unique. class is often used to target element you can give class to your element which you want to target class can be any name. and in css to target it write this "." character followed by the name of the class like this ".demo".