WordPress Body Class 101: Tips and Tricks for Theme Designers

What is WordPress Body Class?

Body Class (body_class) is a WordPress function that gives the body element different classes, so theme authors can style their sites effectively with CSS. HTML body tag is present in mostly your header.php file which loads on every page. When coding a theme, you can attach the body_class function to your body element like so:

<body <?php body_class($class); ?>>

By adding this little element, you give yourself the flexibility of easily modifying the look of each page by using CSS. Depending on the type of page being loaded, WordPress automatically adds the appropriate class. For example, if you are on an archive page, WordPress will automatically add archive class to the body element if you choose to use it. It does that for just about every page…

via WordPress Body Class 101: Tips and Tricks for Theme Designers.