Click below for Step by Step and Interview Q & A (dotnetinter) wrote,
Click below for Step by Step and Interview Q & A

ASP.NET HTML 5 interview questions on SVG and Canvas

We are thankful to to provide these HTML 5 interview questions. They have awesome 500 videos ASP.NET and C# interview questions and answers which are awesome for interview preparation for .NET interviews.

What is SVG?

SVG stands for scalable vector graphics. It’s a text based graphic language which draws images using text, lines, dots etc. This makes it lightweight and renders faster.

Can we see a simple example of SVG using HTML 5?

Let’s say we want to display the below simple line using HTML 5 SVG.


Below is how the code of HTML 5. You can see the SVG tag which encloses the polygon tag for displaying the star image.


What is canvas in HTML 5?

Canvas is an HTML area on which you can draw graphics.

So how can we draw a simple line on Canvas?

  • Define the Canvas area.

  • Get access to canvas context area.

  • Draw the graphic.

Define the canvas area

So to define canvas area you need to use the below HTML code. This defines the area on which you can draw.


Get access to canvas area

To draw on the canvas area we need to first get reference of the context section. Below is the code for canvas section.


Draw the graphic

Now once you have access to the context object we can start drawing on the context. So first call the “move” method and start from a point , use line method and draw the line and then apply stroke over it.


Below is the complete code.


You should get the below output.



Tags: html 5 interview questions, canvas, csharp interview questions, html 5 canvas interview questions, html svg interview questions, it interview questions, programming interview questions, svg interview questions

  • Post a new comment


    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded