Reputation: 351
Can someone please explain the below CSS code:
html:not([dir="rtl"]){
//some CSS property
}
Upvotes: 0
Views: 43
Reputation: 718
It will select all html
tags that don't have the attribute dir
with value rtl
.
Select html tag: html
Select the inverse: :not()
Select an attribute with specific value: [attribute="value"]
Upvotes: 1
Reputation: 1515
html:not([dir="rtl"])
Let's break it down!
html
Selects all html
elements (there's most likely only one)...
:not( ... )
... that do not...
[dir="rtl"]
... have the attribute dir
set to "rtl"
.
So, to sum it up, it selects all html
elements that do not have dir
set to "rtl"
. Example:
<html> <!-- Would match! -->
<html lang="en"> <!-- Would match! -->
<html dir> <!-- Would match! -->
<html dir="ltr"> <!-- Would match! -->
<html dir="rtl"> <!-- Would NOT match! -->
Upvotes: 3
Reputation: 122027
That is :not()
pseudo-class and inside is attribute selector, so it will select html
if it doesn't have dir="rtl"
attribute which is text-direction set right to left.
Upvotes: 1