Hi
I have below headings on Page Header. In details section list of Items
Sr. Item Code Item Name Quantity Price
I want if there is no detail of item on second page then the above heading should not get displayed though Footer details appear on second page
Thanks
Mohammad HussainPosted Aug 28, 2023, 7:22 AM
It sounds like you want to conditionally hide the page header on the second page of a printed document when there are no details in the detail section. Unfortunately, HTML and CSS alone don't provide a direct way to achieve this level of dynamic control over printed content. However, you can achieve a similar effect using CSS and HTML by using the `@page` rule and CSS counters.
Here's a general approach:
You can use CSS counters to track the number of detail items. Define a counter in your CSS and increment it for each detail item.
2. Hide Page Header on Second Page if No Detail Items:
You can utilize the `@page` rule to control the layout of printed pages. In your print-specific CSS, you can target the second page and use the `counter()` function to check the value of the counter. If the counter is 0 (no detail items), you can hide the page header.
3. **Markup for Detail Items:**
Ensure that your HTML markup includes the appropriate class for detail items.
Remember that browser support for CSS paged media features can be inconsistent and may not work as expected in all scenarios. It's recommended to thoroughly test your solution in different browsers and consider that not all users may use modern browsers or have their printing settings configured optimally.
Keep in mind that this approach may not provide the exact result you're looking for, but it's one way to conditionally control the visibility of the page header based on the presence of detail items on the second page of a printed document.