I read very often and i highlight definitions in orange and theorems in purple, but sometimes I cant really distinguish a definition from a theorem, for example:
Let $A$ be a finite set and $B$ a nonempty set. $|A|≥|B|$ if and only if there exists a function that maps A onto B.
$|A|$ and $|B|$ represent the cardinality of $A$ and $B$ respectively.
I don't understand if this is a theorem (or a rule in general), or a definition, how do you distinguish definitions from theorems since both usually use the sentence "if and only if"?
To summarize the discussion in the comments:
It should not usually be ambiguous whether a given statement is a theorem or definition. If a definition is not explicitly labeled as such, if will usually be written in a form such as
or, if the definition is a word (rather than a notation) then a definition will be indicated by italicizing the new term:
Generally speaking, authors use "if" rather than "if and only if" for a definition because the "only if" part is implied.
If it is not indicated as a definition from the above clues, I would assume it is a theorem (or at any rate, a statement that is not a definition.) Other clues that a sentence is not a definition is if it starts with then, so, thus.
The example you give
is not standard mathematical writing because sentences should not begin with a symbol. This makes it somewhat harder to tell if it is a definition or not because of the lack of any word connecting it to the previous sentence, but in the absence of any of the aforementioned cues for a definition I would assume it is not.
Other clues:
One last possibility is that it is a definition that has been repeated for convenience. This will be indicated by words like "recall that":
A definition is rarely given inside a proof (unless it has been repeated, as above.)
Not all authors obey these rules - especially if the setting is more informal, such as blackboard work or class notes. In that case if you are unsure you can always ask the instructor.