question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Custom style in first page

See original GitHub issue

Its possible to have a different style for the first page of a document?

<!DOCTYPE html>
<html>
    <head>
        <style>
            /* Something like this is possible? */
            @page :first header  {
                background-color: red;
            }

            /* Or this? */
            @page :first {
                header  {
                    background-color: red;
                }
            }

            @page {
                size: letter portrait;

                @top-left {
                    content: element(header-content);
                }

            }

            header {
                position: running(header-content);
            }

            .page-break {
                page-break-after: always;
            }

        </style>
    </head>
    <body>
        <header>
            <h1>Header text</h1>
        </header>

        Some text
        <div class="page-break"></div>
        More text

    </body>
</html>

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
liZecommented, Jan 11, 2021

Hi @pbregener thanks for you response, what I am trying to do is to apply the style to an element (header) only in the first page.

Hello!

I think that there’s no way to change the style of the elements drawn on the first page. @page rules can only contain page properties, and properties defined there only apply to the page and the page margins, not to the page content.

In real cases, you often know what’s on your first page, and you can add classes accordingly (even if it’s not a “clean” solution, I agree). But there are some cases when you really want to change the style of the content only on the first page, and … currently you can’t.

Reporting an issue to the CSSWG may be the best solution to get a way to solve this issue.

0reactions
ktowencommented, Jan 11, 2021

Thanks @liZe. I will try to report it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Customize or create new styles - Microsoft Support
If you want formatting choices that are not available from the built-in styles and themes available in Word, you can modify an existing...
Read more >
How to Create a Custom Heading Style in ... - Erin Wright Writing
... heading style in Microsoft Word. Plus, save a custom heading style and delete a custom heading style. ... How to Create a...
Read more >
Word 2016: Applying and Modifying Styles - GCF Global
To apply a style set: Style sets include a combination of title, heading, and paragraph styles. Style sets allow you to format all...
Read more >
Setting up a Heading 1 Example - Microsoft Word for ...
For example, your chapter titles and front matter titles (e. g., Dedication, ... On the Home Ribbon, in the Styles Group, right-click on...
Read more >
How to Create a Custom Heading Style in Microsoft Word
Learn how to create your own custom heading style in Microsoft Word. In addition, learn how to save a custom heading style for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found