Differences between css selectors

[attribute ~ = value] is used to select the element that contains the specified vocabulary in the attribute value.
[attribute * = value] matches each element that contains the specified value in the attribute value.

p [class ~ = "lone"]
p [class * = "lone"]

there seems to be no difference between the two, huh?

Apr.18,2021

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Test</title>
  <style type="text/css">
    p[class ~= "lone"]{
      color: red;
    }
    p[class *= "abc"]{
      color: blue;
    }
  </style>
</head>
<body>
  <p class="lone">lone: 

<p class="abc">abc:

<p class="lone1">lone1:

<p class="abc1">abc1:

</body> </html>

one contains a word , and the other contains a string that is different

.

[attribute~=value] matches any entry in a space-delimited list. It matches attribute= "a valueb", but not attribute= "a valueb".

[attribute*=value] matches any substring. It matches attribute= "a valueb" and attribute= "a valueb", but not attribute= "x".


specify vocabulary ! = specify value

Menu