I am trying to display normal HTML to load as an image on my page.
For example:
<h1>Hello World</h1>
This will display text on my page.
How do I convert this so that the h1 tag will display "Hello World" as an image on my page?
Any help would be greatly appreciated.
2
Answers
I think you could use canvas element to render an image. More documentation here: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/canvas
I think the easiest way would be to add the text to a hidden canvas tag, then use
toDataURL
.The javascript:
The css:
The html: