2

I wish to change the code block background color in org mode but below example doesn't work.

#+ATTR_HTML: :background-color #eff0f1;
#+BEGIN_EXAMPLE
hello world!
#+END_EXAMPLE

Can I insert inline css code with #+ATT_HTML

6

Yes, you can do what you want with #+ATTR_HTML. However, your HTML is incorrect. If you look at the output you will see <pre class="example" background-color="#eff0f1;"> but there is no background-color attribute in HTML. Instead, use this:

#+ATTR_HTML: :style background-color:#eff0f1;
#+BEGIN_EXAMPLE
hello world!
#+END_EXAMPLE

This will generate <pre class="example" style="background-color:#eff0f1;">, which will apply color to that block only.

3

You can try this:

#+HTML_HEAD: <style type="text/css">.example {background-color: #eff0f1; color: #ff0000;}</style>
  • Thanks, this solution works for everything block. Is it possible to add a attribute only apply to current code block? then I can apply different color for different block. – lucky1928 Mar 18 '17 at 20:54
  • How could the same be achieved for a pdf document using LaTeX? – tokami Mar 10 at 9:18

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.