Leon Atherton Leon is a developer at IDRsolutions and product manager for BuildVu. He oversees the BuildVu product strategy and roadmap in addition to spending lots of time writing code.

Why canvas is not a self closing HTML5 tag

39 sec read

While debugging a page produced by our PDF to HTML5 Converter, I noticed that Firefox was showing some of the tags in the HTML source in red.

Specifically, there was a closing div tag.

 

The solution I thought was quite obvious – there must be no opening div tag for it to close.
But scrolling up, indeed there was a div tag for it to close.

The problem itself was actually in the line above – the canvas tag.

The line used was <canvas id=”pdf15″ width=”1053″ height=”813″ >. Although our canvas tag has nothing inside it because of the way that the canvas works, that doesn’t mean that we are allowed to self close it like we would an </canvas>.

The reason that canvas tag requires a separate closing tag is because it’s actually possible to put content inside that will display instead of the canvas if the user’s browser does not support HTML5.

 

Problem solved!

This post is part of our “HTML5 Article index” in these articles, we aim to help you understand the world of HTML5.



Are you a Developer working with PDF files?

Our developers guide contains a large number of technical posts to help you understand the PDF file Format.

Do you need to solve any of these problems?

Display PDF documents in a Web app
Use PDF Forms in a web browser
Convert PDF Documents to an image
Work with PDF Documents in Java
Leon Atherton Leon is a developer at IDRsolutions and product manager for BuildVu. He oversees the BuildVu product strategy and roadmap in addition to spending lots of time writing code.

Leave a Reply

Your email address will not be published. Required fields are marked *

IDRsolutions Ltd 2022. All rights reserved.