Totara Learn Open Discussions

Inline CSS into an HTML block

 
? ?
Inline CSS into an HTML block
by ? ? - Wednesday, 25 April 2018, 6:09 AM
 

Does HTML blocks allow just inline CSS?

Thank you

Alessio

Craig Eves
Re: Inline CSS into an HTML block
by Craig Eves (Totara Support) - Thursday, 26 April 2018, 8:38 PM
Group Totara

Hi Alessio

The way to do this in the block is to allow additional CSS classes in the HTML block (Site admin > Plugins > Blocks > HTML - Allow additional CSS classes

Then add the HTML block to the page and there should be a box where you can enter the CSS class you want to change eg background

Then go into the theme for you site and add Custom CSS for example .background{background-color:#768f40;}

I tried in 11 and seemed to work but don't know if there is a better/easier way to do this.

regards

? ?
Re: Inline CSS into an HTML block
by ? ? - Friday, 27 April 2018, 12:55 AM
 

Thank you for your reply Craig.

Can I add some CSS within <style></style>?

I tried to do it, but as soon as I click on save button, Totara delete all the code within those tags.

Craig Eves
Re: Inline CSS into an HTML block
by Craig Eves (Totara Support) - Sunday, 29 April 2018, 1:21 PM
Group Totara

Hi Alessio

This won't work as the code is stripped out by Totara to prevent malicious code being inserted.

regards

Craig

? ?
Re: Inline CSS into an HTML block
by ? ? - Saturday, 19 January 2019, 11:09 AM
 

This is great information, thank you. I like that this will work for my HTML Blocks, but is there also way to add CSS to the HTML Editor within the Label Activity? Or does it all get stripped out by Totara?

Thanks,
Jim