
- HTML Tutorial
- HTML - Home
- HTML - Overview
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Comments
- HTML - Images
- HTML - Tables
- HTML - Lists
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Frames
- HTML - Iframes
- HTML - Blocks
- HTML - Backgrounds
- HTML - Colors
- HTML - Fonts
- HTML - Forms
- HTML - Embed Multimedia
- HTML - Marquees
- HTML - Header
- HTML - Style Sheet
- HTML - Javascript
- HTML - Layouts
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- HTML - Fonts Ref
- HTML - Events Ref
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
How to save DIV as Image with HTM5 canvas to image with the extension?
DIV content can be saved as an image with the help of html2canvas() function in JavaScript. DIV tag defines a section in HTML document.
Example
<div id = ”cpimg” style = ”padding: 25px ; ” > <h4>Welcome</h4> </div>
This shows the division area named cpimg.
The html2canvas() function save div as an image with the following code −
html2canvas(document.querySelector(“#cpimg”)).then(canvas { document.body.appendChild(canvas) });
It saves the referred div section “cpimg” into the image.
- Related Articles
- How to save DIV as Image with canvas2image with extension in HTML?
- How to save HTML Canvas as an Image with canvas.toDataURL()?
- How to save an image with matplotlib.pyplot?
- How to save an array as a grayscale image with Matplotlib/Numpy?
- How to create a canvas with Image using FabricJS?
- How to create a canvas with background image using FabricJS?
- How to Move an Image in Tkinter canvas with Arrow Keys?
- How can I make a div with irregular shapes with CSS3 and HTM5?
- How to save a Librosa spectrogram plot as a specific sized image?
- How to rotate an image with the canvas HTML5 element from the bottom center angle?
- How to set the image to be used as a border with JavaScript?
- How to set an image as the list-item marker with JavaScript?
- How to save a canvas as PNG in Selenium?
- Making an image scale mouse over on HTM5
- How to keep the image at the back of the HTML5 canvas when moving elements with fabric.js?

Advertisements