Answers for "css selector for text in div"

CSS
1

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

Browse Popular Code Answers by Language