The register_sidebar
function has 'before_widget'
and 'after_widget'
arguments that, by default, add <li>
tags with a class of widget
around each widget. You can change that in your theme to add an additional <div>
around each widget if li.widget
is not a good enough CSS Selector or if your theme removes it.
I don't know what options are in the register_sidebar()
function for your theme. You would have to change this code to fit your theme.
register_sidebar( array(
'name' => __( 'Sidebar name', 'theme_text_domain' ),
'id' => 'unique-sidebar-id',
'description' => __( 'Sidebar name description', 'theme_text_domain' ),
'class' => '',
'before_widget' => '<li id="%1$s" class="widget %2$s"><div class="widget-content">',
'after_widget' => '</div></li>',
'before_title' => '<h2 class="widgettitle">',
'after_title' => '</h2>'
) );
Edit:
To isolate just the content, you could style everything in the widget and then style the title. For example, in the style sheet, do something like this:
.widget .widgettitle {
/** Style the widget title. */
}
.widget {
/** Style the whole widget. */
}
The .widget .wigettitle
selector has greater specificity and will override the matching styles in .widget
. The net effect is that only the widget content will be affected by the styles that are overridden.