Last active
May 24, 2018 10:16
-
-
Save paperdigits/751ee4ecc69702265815020c9e438c79 to your computer and use it in GitHub Desktop.
Good(?) Typography for CSS Paged Media
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Good(?) typography */ | |
/* Widows and oraphans for paragraphs */ | |
p { | |
widows: 3; | |
orphans: 3; | |
} | |
/* Avoid page breaks directly after headers */ | |
h1, h2, h3, h4, h5, h6 { | |
page-break-after: avoid; | |
} | |
/* Nested unordered list styles */ | |
.ul { | |
list-style-type: disc; | |
} | |
.ul .ul { | |
list-style-type: circle; | |
} | |
.ul .ul .ul { | |
list-style-type: square; | |
} | |
/* Do not break the page if there is only one line item on the next page */ | |
li + li:last-of-type { | |
break-before: avoid; | |
break-after: avoid; | |
break-inside: avoid; | |
} | |
/* Do not break inside a figure environment */ | |
figure { | |
page-break-inside: avoid; | |
} | |
/* Basic PDF bookmarks */ | |
h1 { | |
bookmark-level: 1; | |
} | |
h2 { | |
bookmark-level: 2; | |
} | |
h3 { | |
bookmark-level: 3; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment