Add a specific css to a widget

If you register your sidebar this way, your all dynamic widgets gets a unique class automatically e.g. – class="widget-container widget_archive"

register_sidebar( array(
    'name' => __( 'Primary Widget Area', 'twentyten' ),
    'id' => 'primary-widget-area',
    'description' => __( 'The primary widget area', 'twentyten' ),
    'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
    'after_widget' => '</li>',
    'before_title' => '<h3 class="widget-title">',
    'after_title' => '</h3>',
) );

Note –

'before_widget' => '<div id="%1$s" class="widget %2$s">',

  • " %1$s " – Will print the unique widget id.
  • " %2$s " – will print the unique class for each widget.

Then we can apply custom styling as necessary to that unique class.

Reference – Codex – Register Sidebar