According to specifications :
[att~=val] : represents an element with the attribute att, the value of which is a list of words separated by spaces, one of which is exactly "val". If "val" contains spaces, it will never represent anything (since words are separated by spaces). Also, if "val" is an empty string, it will never represent anything.
[att*=val] : represents an element with the attribute att whose value contains at least one instance of the substring "val". If "val" is an empty string, the selector does not represent anything.
So, the main difference is that * means that val can be anywhere in the attribute value, but in the case of ~ val I need the exact part of the value that can be separated by spaces (for example, the class attribute).
You can see it in action here: http://jsfiddle.net/kizu/bPX9n/
both divs use the class [class * = val], but [class ~ = val] applies to where val is separated by spaces from other parts of the attribute.
kizu
source share