0

I am automating the conversion of a latex index to HTML and the code I generate looks like this:

<div style="float:left;">
    Abricots à la Colbert
    <a style="float:right" href="../text/ch005.xhtml#ix1941">1941</a>
</div>

Unfortunately this does not work: the '1941' page number does not float to the right of the page. The entire line is left aligned and the page number is displayed immediately after the 't' of Colbert with no intervening space.

On the other hand if I code something such as this:

<div style="text-align:left;">
This text is left aligned
<span style="float:right;">
    This text is right aligned
</span>
</div>

...everything works as expected.

Anyone could explain why?

What would be the correct way to code this?

guv'
  • 1,359
  • 13
  • 8

1 Answers1

0

I think that you place your whole div on the left and then since the a tag is inside the div, you want to place it to the right. You can try something like this:

 <div>
   <div style="float:left;">
      Abricots à la Colbert
   </div>
   <div style="float:right;">
      <a style="float:right" href="../text/ch005.xhtml#ix1941">1941</a>
   </div>
</div>
mtrip
  • 67
  • 3
  • 10
  • Edward Cooper I changed my code generation template as recommended and it gives the correct result. Since the 'float:left / float:right + text is left aligned etc.' stuff that I copied from another issue and my failed effort have exactly the same logical structure (with the float:right attribute inside the
    ) ... the only thing I can think of is that for some reason the renderer just ignores the 'float:right' attribute when it styles an tag.
    – guv' Dec 12 '20 at 21:03
  • comment deleted – guv' Dec 12 '20 at 21:05