emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Apply custom CSS class to headings in HTML export?
@ 2011-03-31 22:46 Uriel Avalos
  0 siblings, 0 replies; 2+ messages in thread
From: Uriel Avalos @ 2011-03-31 22:46 UTC (permalink / raw)
  To: emacs-orgmode

Suppose that you export the following document to HTML:

  * Heading 1
  ** Heading 2

The HTML structure is pretty much the following:

  div class=outline-2
    h2 Heading 1
    div class=outline-text-2
    div class=outline-3
      h3 Heading 2

Is there a way to apply a custom CSS class to the:

 1. containing div (outline-2)?
 2. heading itself (h2)?
 3. text inside of the heading (outline-3)?

Why? Suppose you have the following document

 * Heading 1
 ** Resources
 ** Answers
 * Heading 2
 ** Quiz 
 ** Resources
 ** Answers

You need to apply a different style to the Resources and
Quizzes. Unfortunately, these don't always appear in an
outline and they don't always appear in the same order. It
is infinitely easier to use a custom CSS class with each
heading.

--Thanks

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Apply custom CSS class to headings in HTML export?
       [not found] <20110331184645.1ad5ae43amscopub-mail@yahoo.com@dove.localdomain>
@ 2011-03-31 23:27 ` Juan Pechiar
  0 siblings, 0 replies; 2+ messages in thread
From: Juan Pechiar @ 2011-03-31 23:27 UTC (permalink / raw)
  To: Uriel Avalos; +Cc: emacs-orgmode

You can add custom styles via properties:

  In order to add styles to a subtree, use the :HTML_CONTAINER_CLASS:
  property to assign a class to the tree. In order to specify CSS styles
  for a particular headline, you can use the id specified in a
  :CUSTOM_ID: property.

http://orgmode.org/manual/CSS-support.html#CSS-support

So you should do something like:

#+begin_example org
* Top heading
** Resource
   :PROPERTIES:
   :HTML_CONTAINER_CLASS: resource
   :END:
#+end_example

This exports as

#+begin_example html
<div ... class="outline-2 resource">
<h2>Resource</h2>
...
#+end_example

So you can define styles thus:

#+begin_example css

div.resource h2 { font: comic_sans_forever; }

#+end_example

regards,
.j.

On Thu, Mar 31, 2011 at 06:46:45PM -0400, Uriel Avalos wrote:
> Suppose that you export the following document to HTML:
>
>   * Heading 1
>   ** Heading 2
>
> The HTML structure is pretty much the following:
>
>   div class=outline-2
>     h2 Heading 1
>     div class=outline-text-2
>     div class=outline-3
>       h3 Heading 2
>
> Is there a way to apply a custom CSS class to the:
>
>  1. containing div (outline-2)?
>  2. heading itself (h2)?
>  3. text inside of the heading (outline-3)?
>
> Why? Suppose you have the following document
>
>  * Heading 1
>  ** Resources
>  ** Answers
>  * Heading 2
>  ** Quiz
>  ** Resources
>  ** Answers
>
> You need to apply a different style to the Resources and
> Quizzes. Unfortunately, these don't always appear in an
> outline and they don't always appear in the same order. It
> is infinitely easier to use a custom CSS class with each
> heading.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-03-31 23:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20110331184645.1ad5ae43amscopub-mail@yahoo.com@dove.localdomain>
2011-03-31 23:27 ` Apply custom CSS class to headings in HTML export? Juan Pechiar
2011-03-31 22:46 Uriel Avalos

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).