2
<div>
<p style="font-size=40px;">
<b>Hello there, welcome</b>
<br/>
To this website
</p>
<p>Some other text</p>

How do I only grab the text inside the first p tag ("To This Website")? I can't give it an class or ID, because it's done with visual composer in wordpress and I can also not style it in wordpress, but I only need to style that part.

pu4cu
  • 155
  • 5
  • 19
  • do you have live website? so we can inspect, you can use `:first-child` selector. – mmativ Sep 21 '16 at 08:52
  • only first p tag color change ?? or all p tag color chage – Sumit patel Sep 21 '16 at 08:54
  • A bit of JavaScript to put the text node in a span is not an option? Then you can style the whole `p` and reverse the style for `p b`. For instance `p {text-decoration: underline} p b {text-decoration: none}` – Mr Lister Sep 21 '16 at 08:55
  • you can edit the visual composer in wordpress and add a `style` on it. – mmativ Sep 21 '16 at 08:56
  • I tried :first-child, and I can not edit it in visual composer for some reason I do not understand. – pu4cu Sep 21 '16 at 08:57
  • better if you give us the link of your wordpress, so we can check it, – mmativ Sep 21 '16 at 09:09

1 Answers1

4

Maybe something like this?

https://codepen.io/anon/pen/YGpvxE

Snippet Example:

    p:first-child {
      color: red !important; /** Use important only in very rare situations **/
    }
    
    p b {
      color: initial;
    }
 <div>
    <p>
    <b>Hello there, welcome</b>
    <br/>
    To this website
    </p>
    <p>Some other text</p>
    </div>

Edit:

To override the inline styling, you can use !important in your CSS.

Robert Bradley
  • 548
  • 2
  • 21
mtch9
  • 298
  • 2
  • 11
  • Something like this would normally work. I tried this but I do not understand why it won't work. I edited my question though. Wordpress puts a style element in the p that iI cannot edit. – pu4cu Sep 21 '16 at 09:04
  • You can override the style attributes with the !important flag behind the rule. (font-size:20px !important;) – Andy Tschiersch Sep 21 '16 at 09:15