CSS Print: Difference between revisions
Jump to navigation
Jump to search
(→Links) |
(→Links) |
||
Line 149: | Line 149: | ||
* https://pagedjs.org/documentation/ | * https://pagedjs.org/documentation/ | ||
Other links: | |||
* [https://www.w3.org/community/cssprint/ W3C CSS Print Community Group] (launched in 2020, closed in December 2023) | * [https://www.w3.org/community/cssprint/ W3C CSS Print Community Group] (launched in 2020, closed in December 2023) | ||
* https://www.pagedmedia.org/library/ list of Javascript tools for pagination, hyphenation, baselines, kerning, font resizing, post-production, etc | * https://www.pagedmedia.org/library/ list of Javascript tools for pagination, hyphenation, baselines, kerning, font resizing, post-production, etc | ||
* [https://gitlab.com/nicolastaf/pagedjs-reload-in-place/ reload-in-place.js] made by Nicolas Taffin, you're fingers will be so thankful for using this!! | * [https://gitlab.com/nicolastaf/pagedjs-reload-in-place/ reload-in-place.js] made by Nicolas Taffin, you're fingers will be so thankful for using this!! |
Latest revision as of 13:13, 24 September 2025
@page
@page {
size: A5 portrait;
margin: 10mm;
}
@page:right @page:left
@page:right {
margin-left: 3cm; /*inner*/
margin-right: 1cm; /*outer*/
@bottom-right {
content: "Testing 123!!!";
}
@bottom-center {
content: "Testing margin notes";
}
}
@page:left {
margin-right: 10mm; /*inner*/
margin-left: 15mm; /*outer*/
@bottom-left {
content: "Testing margin notes";
}
@bottom-center {
content: "More margin notes";
}
}
@page custom sections
@page custom{
background-color: lightyellow;
@bottom-center {
content: "A custom note in the bottom-center margin :)";
}
}
section#custom{
page: custom;
}
@page:first
@page:first {
@bottom-center {
content: "";
}
@bottom-right {
content: "";
}
}
@page:nth()
@page:nth(3) {
background-color: pink;
}
pagenumbers
@page{
@bottom-left{
content: counter(page);
}
}
pagebreaks
Force page breaks before each h1:
h1 {
break-before: always;
}
Start a section on the right page:
section {
break-before: right;
}
hyphens
html{
hyphens: auto;
hyphenate-limit-chars: 8;
}
display links in print
a[href]:after {
content: ' (' attr(href) ')';
}
generated pagenumbers in a table of contents
See: https://pagedjs.org/documentation/-cross-references/#target-counter()
#toc a::after {
content: "page: " target-counter(attr(href url), page);
}
Links
Paged Media CSS references:
Using media queries: @media print, @media screen
- https://developer.mozilla.org/en-US/docs/Web/CSS/@media
- https://developer.mozilla.org/en-US/docs/Web/Guide/Printing
Paged.js documentation:
Other links:
- W3C CSS Print Community Group (launched in 2020, closed in December 2023)
- https://www.pagedmedia.org/library/ list of Javascript tools for pagination, hyphenation, baselines, kerning, font resizing, post-production, etc
- reload-in-place.js made by Nicolas Taffin, you're fingers will be so thankful for using this!!