# \pageref gives wrong page number in TeX4HT

When i used \pageref in the document, i am getting wrong page number in the TeX4HT output (ie., Html file)

MWE

\documentclass{article}

\title{Sample TeX4HT}

\begin{document}
\maketitle

Macro language has evolved gradually: as the need arose for actions beyond a predefined set of commands. As a consequence, it is a pretty non-standard language that implements loops and conditional statements with macro functions rather than keywords.
\pageref{sec1}
\end{document}


like below, i am getting "x" instead of 1 in the output,

<span class="pageref"><a href="#x1-10001"><span class="cmsy-10">x</span></a></span>


I compiled the file with the argument

htlatex filename "xhtml"


Please suggest how to get the correct page no

• The HTML output does not really have a concept of numbered separate pages, because the whole document is rendered in one long vertical 'page'. So wouldn't it be strange to, for example, refer to page 2 when there is no page 2? Jul 23, 2019 at 14:04

There is no concept of page in HTML, so the section (\S) symbol is used by tex4ht by default. But internally, the pages are still used, so it is in fact possible to use them. They just don't have any presence in the HTML file, so it may be a bit confusing.

The pageref configuration takes three arguments, the first two insert tags before and after the reference, the third argument contains text that should be used in the reference. When the third argument is empty, the default text is used, which is the page of the referenced object in the DVI file:

\Preamble{xhtml}
\Configure{pageref}{\HCode{<span class="pageref">}}{\HCode{</span>}}{}
\begin{document}
\EndPreamble


The following example:

%https://tex.stackexchange.com/q/501041/2891
\documentclass{article}

\usepackage{lipsum}
\title{Sample TeX4HT}

\begin{document}
\maketitle


Note that the page numbers don't correspond to the PDF version produced by the same document at all, as tex4ht inserts page breaks for it's own purposes!