0

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>
Molder
  • 121
  • 8
  • 1
    You are using the _attribute_ selector for _contents_. I dont think its possible to do what you want, and if it is, it is certainly not advised (what if someone corrects the wording only slightly? Or you want a slightly different message? Try to keep your CSS as separate from your content as possible so you don't need to change both when you want to change only one). – somethinghere Nov 27 '15 at 10:53
  • 2
    you cannot select using css please refer this for futher description http://stackoverflow.com/questions/5688712/is-there-a-css-selector-for-text-nodes – Hisham Nov 27 '15 at 10:55

2 Answers2

4

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 :)

KCarnaille
  • 1,027
  • 9
  • 18
1

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; }
rrd
  • 5,789
  • 3
  • 28
  • 36