Interview Questions on HTML

41. What is <canvas> element?

The HTML <canvas> element is used to draw graphics on a web page.
Syn :- <canvas id="myCanvas" width="200" height="100"></canvas>

42. What is SVG?

SVG stands for Scalable Vector Graphics
SVG is used to define graphics for the Web
SVG is a W3C recommendation

43. What is Differnce b/w canvas and svg?

SVG is a language for describing 2D graphics in XML.
Canvas draws 2D graphics with a JavaScript).

44. How to display Video in HTML ?

<video width="320" height="240" >
<source src="movie.mp4" type="video/mp4">
<source src="movie.ogg" type="video/ogg">
Your browser does not support the video tag.
</video>

45. How to display controls in video tag?

<video width="320" height="240" controls>
<source src="movie.mp4" type="video/mp4">
<source src="movie.ogg" type="video/ogg">
Your browser does not support the video tag.
</video>

46. How to play video automatically in HTML ?

Use autoplay attribute in video tag.
<video width="320" height="240" autoplay>
<source src="movie.mp4" type="video/mp4">
<source src="movie.ogg" type="video/ogg">
Your browser does not support the video tag.
</video>

46. How to play Audio files ?

<audio controls>
<source src="horse.ogg" type="audio/ogg">
<source src="horse.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>

47. How to display flash image or .swf images in HTML?

Use <object> tag.
<object width="400" height="50" data="fliname.swf"></object>

48. How to play youtube video in HTML?

Use :
<iframe width="420" height="315" src="http://www.youtube.com/embed/XGSy3_Czz8k?autoplay=1">
</iframe>

49. Which one is used for largest heading <h1> or <h6>?

<h1>


Questions 41-50

Interview Questions on HTML

31. What are the block level elements?

Block level elements starts with new line and occupies full width(By default).
<div>
<h1> ,<h2>_ _ _ <h6>
<p>
<form>

32. What are all the inline elements?

Inline leements does not start in new line and takes as much width as necessary.
<span>
<a>
<img>

33. What is Difference b/w <div> and <span> elements?

1. <div> :
<div> is a block level element and takes full width by default.
It is used as container to write other HTML elements.
Ex:-
<div style="background-color:black; color:white; padding:20px;">
<h2>London</h2>
<p>London is the capital city of England. It is the most populous city in the United Kingdom, with a metropolitan area of over 13 million inhabitants.</p>
</div>

2. <span> :
<span> is inline elements and take as much width as necessary.
It is used to apply styles for the text.

<h1>My <span style="color:red">Important</span> Heading</h1>

34. Tell me Some of HTML5 elements?

header Defines a header for a document or a section
Nav Defines a container for navigation links
Section Defines a section in a document
Article Defines an independent self-contained article
Aside Defines content aside from the content (like a sidebar)
Footer Defines a footer for a document or a section
Details Defines additional details
summary Defines a heading for the details element

35. What is the use of <iframe>?

<iframe> tag is used to load another web page in current webpage.
Ex:- <iframe src="URL"></iframe>

36. Explain about <form> Element?

<form> is used to collect the user input and pass it to serverpage.
Syn : - <form>
.
form elements
.
</form>

37. What is <input> element?

<input> tag is used to take input from the user.
It can be following types :
1. Text :- take the input as text format
2. Radio :- take input as radio buttons
3. Checkbox :- take input as check box button.
4. Password :- take the input in radio buttons
5. Hidden :- input doesn’t show to the user.
6. Submit :- provides button to submit all inputs.

38. Write sample code for <form> which uses <input> tags?

<form action="action_page.php">
First name:<br>
<input type="text" name="firstname" value="Mickey">
<br>
Last name:<br>
<input type="text" name="lastname" value="Mouse">
<br><br>
<input type="submit" value="Submit">
</form>

39. How to write drop down boxes?

<select>
<option value=”1”> option1 </option>
<option value=”2”> option1 </option>
<option value=”3”> option1 </option>
<option value=”4”> option1 </option>
</select>

40. Explain about <textarea> tag?

Used to take multiline text as input

Ex:-
<textarea name="message" rows="10" cols="30">
</textarea>


Questions 31-40

Interview Questions on HTML

21. How to write comments in HTML?

In b/w <! - - and - - >

22. How to write tables in html?

By using <table>,<tr>,<td> or <th>tags.
Ex:-
<table style="width:100%">
<tr>
<td>Jill</td>
<td>Smith</td>
<td>50</td>
</tr>
<tr>
<td>Eve</td>
<td>Jackson</td>
<td>94</td>
</tr>
</table>

Explanation:
Tables are defined with the <table> tag.
Tables are divided into table rows with the <tr> tag.
Table rows are divided into table data with the <td> tag.
A table row can also be divided into table headings with the <th> tag.

23. How to do colspan in tables in HTML?

<table style="width:100%">
<tr>
<td colspan=”2”>Jill</td>
<td>Smith</td>
<td>50</td>
</tr>
<tr>

<td>Jackson</td>
<td>94</td>
</tr>
</table>

24. How to do row span ?

<table style="width:100%">
<tr>
<td rowspan=”2”>Jill</td>
<!—second cell also it will occpy - - >
<td>50</td>
</tr>
<tr>
<td>Eve</td>
<td>Jackson</td>
<td>94</td>
</tr>
</table>

25. Can we use rowspan and colspan in <tr> tag?

No, only in <td> tags.

26. How to align text to right side in tables?

Use align=”right” attribute.
<td align=”right”>Jill</td>

27. How to collapse all borders of cells into single line border?

Use this in styles : border-collapse: collapse;

28. How to write ordered list and how to write un-ordered lists?

Ordered lists:-
<ol style="list-style-type:disc">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>

Un ordred lists :-
<ul style="list-style-type:disc">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>

29. How to remove bullets in unordered lists?

Use style attribute list-style-type:none

30. How to assign letters as serial numbers in ordered lists?

Use style type=”A”
Ex :-
<ol type="A">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>


Questions 21 - 30

Interview Questions on HTML

11. How would you display image in html?

By using <img> tag.
Ex :- <img src="w3schools.jpg" />

12. What is the use of ‘alt’ in <img> tag?

If browser is not supporting to display the image then alternatively browser will show that text which is assigned to alt attribute.

13. How to keep new line or break lines in html?

Use <br/> tag.

14. How would to keep more spaces in html?

By using ‘&nbsp’.
It stands for non breaking space.

15. What happens if we not close tags?

Closing tag is considered as optional.
Never rely on this. It might produce unexpected results some times.

16. Write html code for image which has 100px width and 150px height?

<img src=”image_to_link” width=”100px” height=”150px” />

17. How to write inline styles in html?

Use style attribute in tags.
Ex:- <img src=”link” style=”width:500px; height:500px;” />

18. How to not allow to modify input text?

Use ‘disabled’ attribute in the input box.
Ex:- <input type="text" name="inputname" disabled />

19. How to view the html source code of webpage in browser?

Method1 :- right click on webpage and click on view page source.
Method2 :- press ctrl + u
Method3 :- open developer tolls in settings.

20. What is the use of <pre> tag?

<pre> tag is use to display the text as it is where in <pre> tags.
Ex:- <pre> asdad a as</pre>


Questions 11-20

Interview Questions on HTML

1. What is HTML?

HTML Stands For Hyper text Markup Language.
We used to write web pages which are executed in browser.

2. Where should we write styles <style> </style> in html?

Any where. It can be body, div, or head.
But we usually write in b/w  tags.

3. Where should we wirte java script code in html page?

Any where. It can be body, div, or head.

4. How to declare doctype in HTML5?

By using "<!doctype html>" at first line.

5. Explain about tags?

HTML tags are keywords (tag names) surrounded by angle brackets:
Syn :-
<tagname>content</tagname> 
Ex :- 
<p> paragraph Text </p>

6. How to write and execute HTML Page?

1. Write code in text editor like notepad,editplus or notepad++.
2. And save it as “filename.html” file.
3. Open it. It will show output in browser. 

7. What is the use of and tags?

<head> :- provides information about the document.
<body> :- provides visible content to the web page.

8. What is the use of <title> and <p> tags?

<title> :- provides title for document. 
<p> :- describes paragraph content.

9. How to provide links to another page in html?

By using anchor tag. <a>
Syntax :- <a href=”path to another page” >link name</a> 
Ex :- <a href="programmersInterview.com">This is a link</a>

10. How to open link in new tab?

Use target=”_blank”
Ex:- <a href="programmersInterview.com" target="_blank">This is a link</a>

Questions 1- 10