0

I've been googling how to add custom classes to the HTML tag of a Wordpress theme, but it's a tricky issue to research because all results are about HTML tags in general, not the specific HTML tag that opens a document. I want something like this:

<html class="custom-class">

I know the body_class filter can be used to customize the body's classes, but there seems to be no such thing for the html tag, yet Wordpress does output some classes for <html>, so they must be coming from somewhere...

Any ideas?

  • You just have to edit the theme file that has the tag. Probably header.php. There’s no filter or anything. – Jacob Peattie Oct 13 '17 at 10:00
  • @JacobPeattie I figured so, but I wanted to know if there was a cleaner way to do it. – grazianodev Oct 13 '17 at 10:01
0

There is no designated template tag for classes on html container.

For example in latest core Twenty Seventeen theme they are hardcoded:

<html <?php language_attributes(); ?> class="no-js no-svg">

For proper customization you would likely need to create a child theme and override repsective template (likely header.php) or settle on manipulating classes with JavaScript.

  • Okay, I will find another solution then. – grazianodev Oct 13 '17 at 11:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.