Answers for "how to select text content in div for css"

CSS
1

css selector with text content

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.
Posted by: Guest on May-07-2021
0

css select text inside div

CSS doesn't work this way. As biziclop says in the comments, text nodes can't be selected with CSS. You'll either have to wrap your text in a <span> and use

.test span {
    cursor: pointer;
}
With

<div class="test">
    <span>Text</span>
</div>
Or set .test to display: inline, but that won't let you give it a width, which is not the behaviour you want. <span>s are fine, in this case.
Posted by: Guest on March-11-2021

Code answers related to "how to select text content in div for css"

Browse Popular Code Answers by Language