arijit079 · 2022-09-13 19:49
I am building a website using org and want ro add some styles to a source code block. `#+ATTR_HTML` does not work and I can't assign a id or class to it. Org does add some generic classes to it but that causes ambiguity with other source blocks. Hence I cannot target it in ny stylesheet or add inline styles to it Someone please help
MitchellMarquez42 · 2022-09-13 21:43
#+begin_export html
May be your friend here.
TheGramm · 2022-09-13 23:47
#name
will give you the id and then you can do it in the stylesheet
[deleted] · 2022-09-14 04:58
[deleted]
arijit079 · 2022-09-14 04:59
Could you elaborate a little more... I am kinda new to org.
arijit079 · 2022-09-14 05:34
Even after adding the #+name, the source block doesn't seem to get a html id
organic-bookworm · 2022-09-14 13:22
I dug this a bit.
With `(setq org-html-prefer-user-labels t)` (or `#+bind: org-html-prefer-user-labels t` in org buffer) `#+name:` does produce `id` attribute for source blocks.
This user option also has additional effects -- see its docstring (`describe-variable` command), as it's not mentioned in the info manual.
arijit079 · 2022-09-14 19:58
Thanks, although I used some `#+HTML: <div id="...">` tags to solve the problem. Anyway I will keep your tip in mind if I later need that. Thanks.