Molder
Molder

Reputation: 121

Select text within a div using CSS Attribute

Trying to select a certain block of text within a div using CSS attribute.

Doesn't seem to be taking, any other options? I have tried variences of

 .welcome [text~="You are logged in as"]{
    display:none;
 }

The HTML text is

 <div id="welcome">
    You are logged in as <a href="example.com">Me</a> <b>(</b> <a   href="http://example.com/index.php?route=account/logout">Logout</a> <b>)</b>         </div>

Upvotes: 0

Views: 178

Answers (2)

rrd
rrd

Reputation: 5967

You could alter the html slightly, to target the whole text or parts of it:

<div id="welcome">
  <span class="target_one">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</span>
  <span class="target_two">Aenean quis augue gravida, ornare arcu quis, gravida arcu.</span>
</div>

Then the css becomes easy enough:

#welcome .target_one { color:red; }
#welcome .target_two { color:green; }

Upvotes: 1

KCarnaille
KCarnaille

Reputation: 1057

You can use [ ] only for html attributes (like id, class...), not for text. You have to use javascript or something else for this. Btw, it's #welcome, not .welcome :)

Upvotes: 4

Related Questions