List all CSS classes used in an HTML page

There are times when you just want to know what CSS classes are referenced in an HTML page. Fortunately it is easy to find out.

Assuming you have jQuery loaded on the page, here is neat little function that will print the list of CSS classes to the console:

(function() {
  var cls = {};
  $('body').find('*').each(function() {
    var c = $(this).attr('class');
    if(c) $.each(c.split(' '), function() {
      cls[this] = null;

Just copy and paste the script into the console of your web browser.