I know CSS Selectors should be generally of the following format:
tagName[attributeName='attributeValue']
For example Ask Question button on stackoverflow.com main page is sitting inside a div element matching the following CSS selector div[class='d-flex']
However I see with my Chrome DevTools that div[class=d-flex] locator is matching this element as well and it is found to be a correct locator!
So, my question is why the CSS selector expressions without apostrophes around the attribute values are still found as correct by the DevTools?
>Solution :
From the specification:
Attribute values must be
<ident-token>s or<string-token>s
You never need to use apostrophes. There are useful only for values with spaces.
[data=ok] {
height:100px;
background:red;
}
[data="ok ok"] {
height:100px;
background:blue;
}
<div data=ok>
</div>
<div data="ok ok">
</div>