Home >Web Front-end >CSS Tutorial >How Can I Add Page Numbers to My Website\'s Printed Output Using CSS?

How Can I Add Page Numbers to My Website\'s Printed Output Using CSS?

Mary-Kate Olsen
Mary-Kate OlsenOriginal
2024-12-03 01:50:09288browse

How Can I Add Page Numbers to My Website's Printed Output Using CSS?

Achieving Page Numbering with CSS/HTML

In a unique scenario, you require the printed version of a website to display a header, footer, and page number in the footer. With advanced capabilities, how can this be accomplished using CSS and HTML?

Solution:

Depending on the desired browser support, the CSS property "@page" can be employed. The following example provides a practical implementation:

@page {
  @bottom-right {
    content: counter(page) " of " counter(pages);
  }
}

This code instructs the browser to add the page number and total number of pages to the bottom-right corner of each printed page.

Further Enhancements:

  • For more comprehensive information, refer to the following resources:

    • [CSS3 Page Module](http://www.w3.org/TR/css3-page/)
    • [Adding Page Numbers with CSS Page Property](http://www.intelligrape.com/blog/2010/08/20/add-page-number-using-page-property-of-css/)
    • [Page Numbers in PrinceXML](http://www.princexml.com/doc/6.0/page-numbers/)

By leveraging the power of CSS, you can effortlessly implement page numbering in your printed web content, ensuring seamless document management and enhanced presentation.

The above is the detailed content of How Can I Add Page Numbers to My Website\'s Printed Output Using CSS?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn