def add_css_class(element, cls):
    """Add a given class to the given BeautifulSoup HTML element."""
    attrs = element.attrs
    new_class = (attrs['class'] + ' ' if 'class' in attrs else '') + cls
    element.attrs['class'] = new_class
