Skip to content

CSS Recipes

Zulko edited this page May 31, 2018 · 5 revisions

Page breaks

To break a page anywhere, use a div with page-break-before:always:

p Some paragraph

div(style="page-break-before:always")

p Some other paragraph

Numbered headings

In the following example (from this blog post), h2 and h3 headers will be automatically numbered (1, 1.1, 1.2, etc.), unless they have the class .no-count.

body {counter-reset: h2}
h2 {counter-reset: h3}

h2:before {
  counter-increment: h2;
  content: counter(h2) ". "
}

h3:before {
  counter-increment: h3;
  content: counter(h2) "." counter(h3) ". "
}

h2.no-count:before, h3.no-count:before {
  content: "";
  counter-increment: none;
}
Clone this wiki locally