Forum How do I...?

Making Table of contents items text wrap to the next line before the page number

arjana
Hello,

I am trying to make a long text in the table of contents look well but there is one thing I am not able to do.

If a toc item text is very long and spans multiple lines (and this is quite a common scenario for us), the toc text wraps to the next line but it is displayed under the page number. I am attaching what I mean. Is there a way to make the text wrap to the next line with leaving a space on the right, before the page number is reached?

Relevant pieces of the css and html are as follows at the moment:

<style>
        #toc a[href]::after {
            content: leader(".") target-counter(attr(href), page)
        }
</style>

<body>
...
        <a href="E:\Projects\princexml\src\main\resources\fortoc\part_0.html#h2_1">Diagrams</a>
         <a href="part_0.htmel#h3_1">1 Model</a>
<a href="part_0.html#h3_1_1">1.1 Admin Rules A very very long title that spans multiple lines. It should look well-aligned and do not go to the area of page numbers</a>
         <a href="part_1.html#h3_1_1_1">1.1.1 A very long requirement which title also spans multiple lines but does not look when approaching the right page margin</a>

...


Arjana
  1. toc.png68.5 kB
    Current text wrapping with notes