0

I have to select particular word in div tag.

HTML

  <div>This is my text</div> 

Here i need a select the word my.

Is it possible to achieve with CSS alone?

Madheswaran M
  • 168
  • 1
  • 7
  • 3
    I think the answer will be "Nope" via CSS – Praveen Oct 21 '13 at 07:38
  • 7
    Short answer: no. Longer answer: No, unless that text is enclosed in a specific element, like a `span`. – GolezTrol Oct 21 '13 at 07:38
  • It cannot be done with CSS, it can be done with Jquery or simple vanila Javascript. – V31 Oct 21 '13 at 07:43
  • Are you trying to achieve text highlighting or something ? In that case you will gave to use javascript to search for the word and wrap it around a span and then give css to the span. – Mevin Babu Oct 21 '13 at 07:50

2 Answers2

3

HTML:

<div> This is <span id="myspan"> my </span> text </div>

CSS:

#myspan {
 ENTER CSS HERE 
}

there's no other chance (unless you change the span to any other tag)

John Smith
  • 615
  • 4
  • 15
0

No, you can't select inner text via css... You should use some javascript code or add a class to the specific text container.

Check jquery :contains selector, for example: http://api.jquery.com/contains-selector/

ProGM
  • 6,949
  • 4
  • 33
  • 52