Adding to <body>

Is there any way to add to the body class? I assume it’s good practice to use as many settings as possible under ‘Project Settings’ for typography, etc. But how would I set other properties that might normally fit into ? Is there an option screen I’m not seeing? Thanks.

Aaron

Just add your code in page settings, Head Code.

For adding classes to body try this in the footer of the page settings.

_jQuery way_
<script>$(document.body).addClass('your-class-here');</script>

or 

_vanilla javascript way_
<script>
var element = document.querySelector('body');
element.classList.add('your-class-here');
</script>

Hi @Norm,

I hope to see the ability to add classes to the body of any page. Just a textfield and maybe support for multiple classes with a comma would suffice. The idea of styling the body doesn’t address the issue in any way.

The classes would be used for scoping and specificity I’m curious what you think, and if it’s low enough hanging fruit for you to tackle anytime soon. In my opinion this is a missing feature. If it’s cool to add a class to a bric or a bloc it’s equally beneficial to add a class to the body.

Cheers.

Great to see this is now added in Blocs 4.4 Blocs 4.4 - YouTube

3 Likes

Thanks for digging this up! I remembered asking @Norm for this waaay back then. This is actually a pretty big deal.

3 Likes

Yes. I use it a lot now. Very handy. No more JavaScript.

1 Like