0

I want to make the first word of a widget title a different color.

The widget code is this:

'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',

How can I had a span or a class in there so I can specify a different color in css?

Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
Ricardo Ribeiro
  • 87
  • 1
  • 2
  • 10

2 Answers2

1

I think you can't do this by just modifying widget code. If you really need first word highlighted, you may look for some javascript, jquery solution like here: First word selector

Community
  • 1
  • 1
Johny
  • 1,441
  • 10
  • 26
0

I think you can do this by just modifying widget code. Find in your theme the file functions.php. Next, find the lines:

'before_title'  => '<h3 class="widget-title">',
'after_title'   => '</h3>',

and change them to

'before_title'  => '<h3 class="widget-title"><span>',
'after_title'   => '</span></h3>',

Add lines your style.css

h3.widget-title span {
background-color: #27b56b;
padding: 2px 9px 2px 8px;
font-size: 14px;
color: #fff;
}
Stephen Kennedy
  • 20,585
  • 22
  • 95
  • 108