Is there a CSS selector for elements containing certain text?
If I read the specification correctly, no.
You can match on an element, the name of an attribute in the element, and the value of a named attribute in an element. I don't see anything for matching content within an element, though.
I need CSS selector to select elements that contain a given text
CSS Selector doesn't support :contains()
anymore. You have to use XPath "//div[text()='Clear search']"
.
CSS selector based on element text?
Not with CSS directly, you could set CSS properties via JavaScript based on the internal contents but in the end you would still need to be operating in the definitions of CSS.
How to select a specific text using CSS selector
CSS
does not have any method like text
. So in HTMLDOM
, it is not possible at this point of time to locate the element based on text.
Moving further, You could do below in nightwatch.js
.useXpath().click('//span[contains(text(), "' + desiredText+ '")]')
and before calling this assign Auto-Publish
to the desiredText
variable.
Is there a CSS selector that checks if an input has any text in it?
you can try this code
input:not(:placeholder-shown) {
border-color: green;
}
Related Topics
How to Change Paper Size in Headless Chrome - Print-To-Pdf
Single Huge .Css File Vs. Multiple Smaller Specific .Css Files
Bootstrap Navbar With Left, Center or Right Aligned Items
How to Force Webkit to Redraw/Repaint to Propagate Style Changes
Change Bootstrap Navbar Collapse Breakpoint Without Using Less
How to Identify Unused CSS Definitions from Multiple CSS Files in a Project
How to Prevent CSS Inheritance
How to Hide Collapsible Bootstrap Navbar on Click
Creating Css3 Circles Connected by Lines
Font Awesome Not Working, Icons Showing as Squares
What Does the CSS Rule "Clear: Both" Do
What Is the Default Padding And/Or Margin For a P Element (Reset Css)
Customizing Bootstrap CSS Template
How to Style Child Components from Parent Component'S CSS File