Skip to content
This repository has been archived by the owner on Jan 2, 2023. It is now read-only.

Anchors / internal links not working [solution] #3486

Closed
benedekh opened this issue May 25, 2017 · 3 comments
Closed

Anchors / internal links not working [solution] #3486

benedekh opened this issue May 25, 2017 · 3 comments

Comments

@benedekh
Copy link

benedekh commented May 25, 2017

It is just a reminder to future self and everyone, who is struggling with the problem: "anchors, internal links not working in wkhtmltopdf 0.12.4 (or maybe earlier versions also)"

Problem:

If you have an anchor whose content is empty, then they will be removed by WebKit. (Thank you @ashkulz for pointing it out!)

<a name="here"></a>
....
I want to go <a href="#here">there.</a>

Solution:

Put anything within the anchor, and it should work now:

<a name="here">&nbsp;</a>
....
I want to go <a href="#here">there.</a>

This issue is linked to #1554, #2153, #2949, #2957 and maybe to some other PRs and issues also that I have not found yet.

Acknowledgement:

I would like to say a huge thank you to @ashkulz for pointing out the issue with WebKit. I would also like to say thank you to any contributor who fixes (or has already fixed, e.g. @rpedela in #2957) this problem in a PR.

@allenwu1973
Copy link

allenwu1973 commented Jul 2, 2019

Thanks! You saved my day. I found setting display to block with CSS also fix this.

a:empty {
  display: block;
  position: absolute; /* see #4404 */
}

@benedekh
Copy link
Author

benedekh commented Jul 2, 2019

@allenwu1973 I'm glad, that I could help you. :-)

@asmshaon
Copy link

Thanks! You saved my day. I found setting display to block with CSS also fix this.

a:empty {
  display: block;
  position: absolute; /* see #4404 */
}

This works for me, thanks a lot

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

4 participants