Reputation: 18855
In CSS3, what is the difference between:
body[data-page~='hello'] {
}
and
body[data-page='hello'] {
}
I have seen that the ~ is known as the general sibling combinator, http://css-tricks.com/child-and-sibling-selectors/ but I don't understand it in the context above.
Thanks.
Upvotes: 3
Views: 1187
Reputation: 55499
From the CSS3 specification:
[att=val]
: Represents an element with theatt
attribute whose value is exactly "val".
[att~=val]
: Represents an element with theatt
attribute whose value is a whitespace-separated list of words, one of which is exactly "val". If "val" contains whitespace, it will never represent anything (since the words are separated by spaces). Also if "val" is the empty string, it will never represent anything.
Thus <body data-page="hello world">
will be matched by the first rule but not the second.
Upvotes: 14