My last 2 cents in addition: ' and " are only recognized by the parser as functional characters inside a tag.
When the parser parses a tag itself, the composition of a tag has to follow special rules. Chars like = assign a value to a property, where the property must be known to the parser and the value has to be wrapped inside ' or ". So The only other two chars which may have to be masked are these two quotes - in case you wanna put such a character into your value (and of course inside a tag value you have to mask the other special chars as well). Since when you put such a quote inside your value, the parser would interpret " or ' as the end of the value and this is not what you want.
Usually in HTML it is best practice to use " to wrap your values, which means, you could even use ' inside the value without the requirement of masking this char. The parser takes the opening quote " and only looks for the same quote to close the value. It works the other way around as well, opening with ' and using " inside the values. But as mentioned before, you should avoid all these special character inside your values at all, at least as far as you can. There may be some cases like metadata for titles where you have to put them into your values, but most of the time there is no need for that.
|