Handle elements with no classes correctly