HTML Interview Questions and Answers

Here are 50+ commonly asked HTML interview questions and answers which will definitely help you in toughest interviews.

1. Explain Semantic HTML?
Semantic HTML is a Style of Programming. It is basically making use of HTML Markup to reinforce the Meaning of the Content. Example: In semantic HTML , we prefer to use <strong> Tag instead of <b> Tag for Bold Statements.Similarly, we prefer to use <em> Tag instead of <i> Tags for Italic Statements.

2. What is LongDesc in HTML?
Longdesc is an attribute that allows you to provide a Link to another page that contains a description of the frame contents. For example: longdesc=”framedescription.html”.

 

HTML Interview Questions and Answers

Image Source

 

3. Explain the Drawbacks of using FRAME Tag.
1. Some compact devices such as Tablets and Mobile Phones cannot cope up with the content within a FRAME Tag due to Screen Resolution issues.
2. The Browser’s Back Button may not work as expected.
3. Sometimes, the Web pages may be showcased in different manner depending upon the Device.
4. There are few handful of Browsers that do not support FRAME Tags

4. What is Cell Spacing?
Cell Spacing is an Attribute that defines the Width of the Border of an HTML Web Page. It basically controls the Space between Table Cells. It is done by determining the Pixel Width.

5. What is Form Get?
The Form data is encoded into a URL by the Browser. The form data is Visible in the URL which helps to Bookmark the Content. The form data is restricted to ASCII codes.

6. What is a Marquee?
Marquee is used to display a Scrolling Text on a Web Page. You should put the text which you want to scroll within the <marquee>……</marquee> Tag. You can optionally add color to the Text and even the sequence of the Scroll.

7. How to make a picture a background image of a web page?
In order to make a picture as a Background of any particular Web page, you need to manipulate the BODY Tag which occurs after HEAD Tag.
Eg.: <BODY Background = “image1.png”>
Background is an Attribute which takes the Image Source.

8. What is Cell Padding?
Cell Padding is an Attribute that defines the Space between the Contents of the Cell. It is basically used to define space between different Cells and also within every Cell., while cellpadding represents the distance between the content within a cell and cell borders.

9. What is the difference between SPAN and DIV?
DIV is container or area that usually is used to layout element or group of elements. DIV is basically used to highlight an Area or a Block of Text in a HTML Web Page so that one can apply Styles to it. DIV tag is also an alternative to the Paragraph tag <p> as it creates a logical division of an HTML document.

SPAN is used for Formatting Elements within SPAN Block. SPAN is used to select Inline Text and allows users to apply different Styles to it. doesn’t have own container or area.

10. Explain Tag.
A Tag is basically used to indicate the Browser about the work that the Browser needs to perform. When you write any Text within an HTML Webpage, you generallyy write it within a Tag which helps the Browser to now what function it needs to perform.

11. What is the difference between HTML and HTML 5?
HTML 1.0 included all specifications forrepresenting Text and Images on a Web page. It also includes providing Semantic data which allows automated categorization and correlation of HTML documents.

HTML5 is very different from HTMl5. It is more of an Application Development Platform, that includes Text, Images, Video, Audio, Interactive 2D and 3D graphics, storing data in the application, Real-Time Networking and much more.

12. What is a Button Tag?
The Button Tag is supported in latest version of HTML i.e., HTML 5. It is primarily used to create a Button within HTML form on a web page. This Button can be clicked to generate an Event. It is usually used to create a “Reset” or a “Submit” Button.

13. What are Inline Elements?
Inline Elements are those that can appear within any sentence and they need not appear on a New Line. This can be performed by the following Tags: <em>,<ins>, <i>, <strong>, <b >, <sub>, <big>, <li>, <del>, <u >, <sup>

14. What is SPAN Tag used for?
SPAN is used for Formatting Elements within SPAN Block. SPAN is used to select Inline Text and allows users to apply different Styles to it. doesn’t have own container or area.

15. What is the difference between HTML elements and tags?
HTML elements are used to communicate details to the Web Browser for Text Rendering purposes. When the HTML Elements are surrounded by Brackets <>, they are converted into HTML Tags. Usually, Tags come in pair and surround content.

16. Explain DIV Tag?
DIV is container or area that usually is used to layout element or group of elements. DIV is basically used to highlight an Area or a Block of Text in a TML Web Page so that one can apply Styles to it. DIV tag is also an alternative to the Paragraph tag <p> as it creates a logical division of an HTML document.

17. Explain META Tag?
It’s primarily used by Web Browsers and Search Engines to Lookup for Keywords. The <meta> tag provides Information about the HTML document. Metadata is Data about Data. It is used to store details such as Page Expiry, Page Author, Keyword List, Page Description

18. How to include Comments in HTML?
HTML uses SGML Comment Syntax as HTML is an SGML application. The complete syntax is complex, and most browsers don’t support. Therefore, a shorter but the best way is:
An HTML comment:<!–Comment–>

19. What is Form Post?
The name value pairs are submitted in the message body of the HTTP request with Form Post. The name value pairs cannot be seen in the web browser bar. It does not have any restrictions on the length of the string.

20. What is a Script?
A Script is a piece of a program that can add Interactivity features to your website. A Script can help to generate a Pop-Up Alert Box Message, or develop a Dropdown Menu. You can write different concise functions, known as Event Handlers, using any of the Scripting Language such as VB Script or JavaScript and then you can trigger those functions using HTML attributes.

21. Can a Web page contain Multiple Headers within a single HTML Document?
Yes. An HTML Document can contain multiple Headers within a single document. Usually, HEADER Tag is used to serve the function in relation to whatever its Parent section may be. So, a HEADER Tag can be included in a BODY TAG, an ARTICLE Tag and much more.

22. Explain FONT Tag.
The FONT Tag is used to manipulate the shape and size of a Text on a Web page. It requires a Closing Tag. However, the FONT Tag and the BASEFONT Tags have been taken off from HTM5. So, the best option to change the FONT is to use it within CSS. It has the following attributes: Color, Size, Face, etc.

23. Explain the Difference between Cell Spacing and Cell Padding?
Cell Spacing is an Attribute that defines the Width of the Border of an HTML Web Page. It basically controls the Space between Table Cells. Cell Padding is an Attribute that defines the Space between the Contents of the Cell. Cell Spacing is basically used to define space between different Cells and also within every Cell, while cellpadding represents the distance between the content within a cell and cell borders.

24. Enlist Features of HTML 5.
1. Provisions for Extension to JavaScript Application Programming Interface (API) that includes Caching, Geo-Locations, Storage, Drag and Drop and much more.

2. Updated List of Form Controls: <time>,<url>, <calendar>, <email>, <date>, <search>.

3. Improved Support for Graphics, Video and Audio Data via Embedding Tags such as <video>, <canvas> and <audio>.

4. Updated Semantic Tags includeing <main>,<aside>, <section>, <nav>, <header>, <article> and <footer>.

25. Can we include Javascript Code within HTML Web Page? If yes, then how?
<script type=”text/javascript”>
</script>
<html>
<body>
<script>
alert(‘Hello, World!’)
</script>
</body>
</html>

26. Enlist the Internationalization Attributes for XHTML Element.
1. XML: Lang
2. DIR
3. LANG

27. What is CSS?
CSS is an abbreviated form of Cascading Style Sheets. It provides easy and effective alternatives to specify various attributes for the HTML Tags. Using CSS, you can mention a Style properties for any HTML element. Without the need of mentioning the details separately in every Web Page, you can just make a .CSS file and fill in the details there. It will automatically be updated to every .HTML Web page.

28. What is difference between Form Get and Form Post?
Get
The Form data is encoded into a URL by the Browser. The form data is Visible in the URL which helps to Bookmark the Content. The form data is restricted to ASCII codes.

Post
The name value pairs are submitted in the message body of the HTTP request with Form Post. The name value pairs are invisible in the web browser bar. It does not have any restrictions on the length of the string.

Form Post and Form Get primarily correspond to different HTTP requests and they are submitted in different ways. Different Decoding techniques may be needed as the data is encoded in different ways.

29. Enlist the Form Elements.
There are various form elements available which are as follows:
1. Text Fields
2. Textarea field
3. Dropdown Menus
4. Radio buttons
5. Checkboxes

30. Explain DOCTYPE Tag in HTML?
It referes to the Document Type Definition. It mentions the rules for the Markup Language for the Browser to render the Content correctly. The DOCTYPE is not mandatory in HTML5 now. However, it needs to be placed before the HTML Tag i.e., the very first line of any HTML Document. It is not an HTML Tag but an instruction to the Web Browser that indicates the Version of the Markup Language that the Web Page is written in.

31. Explain XHTML.
XHTML stands for Extensible HyperText Markup Language. It is almost Identical to HTML. It is more strict in terms of syntax as compared to HTML. XHTML is an extension of HTML that includes XML application i.e, Extensible Markup Language. The major benefit of using is XHTML is that it is supported by all the major Web Browsers.

32. What is IFRAME tag?
IFRAME Tag is basically used to Embed the documents within an HTML Document. However, the latest developments in HTML 5 has taken off support for the IFRAME Tag and hence you should avoid using it.

33. What extensions does an HTML Web Page use?
The extensions used by an HTML document are:
1. .html
2. .htm
However, you should stick on with .html format as it a convention and looks more efficient.

34. Do all HTML Tags have an Ending Tag?
No. Most of them have an Ending Tags. However, there are few that do not need an Ending Tag such as <BR/> and <HR/> Tags. It is not mandotory to use an ending tag for these two Tags.

35. Enlist some common Lists that are used in designing an HTML Web page?
There are many common lists which are used to design a page. You can select any combination or even a single list of the following list types:
1. Definition List
2. Menu List
3. Ordered List
4. Directory List
5. Unordered List

36. What is a Box Model?
Every Element on a Page is a Rectangular Box and may have Width, Height, Padding, Borders, and Margins. Every section of the box model relates to a CSS property: width, height, padding, border, and margin.

37. How can you insert an Image within an HTML Document along with different attributes?
You can insert any Image within an HTML Document using the IMG Tag. It makes use of multiple attributes that helps to showcase the image in a better way. This tag doesn’t require an Ending Tag like other Tags.

<img src=image1.png” alt=”thecrazyprogrammer” height=”25″ width=”30″>

38. What are Hyperlinks?
Hyperlinks contain contents linked to other URL. It helps the visitors to Navigate between Web Sites or Web Pages within the Same Website. It can be linked to Text or an Image on a Webpage.

39. What is Noresize used for?
Noresize attribute is used within Frames. It is used to prevent a User from resizing the Frame within an HTML Document. However, a Frame is resizable by default and you can do it by Clicking and Dragging the Borders of any Frame.

40. What are Block Elements?
These are the elements that appear on the screen in terms of a Bloc. They have a Line Space Before and After the Starting and Ending Tags respectively. They start on a New Line.
The Following Tags are used for Block Elements:
HR, ADDRESS, HEADING, OL, PRE, BLOCKQUOTE, DL

41. What are HTML Forms?
HTML Forms are needed when you want to collect Data from the Visitor. It is used to collect things such as name, email address, credit card number, etc. A form will take input from the Visitor and will store it to Back-End application such as CGI, ASP Script or PHP script etc.

42. What is EMBED Tag?
Embed Tag is used to include a Video or an Audio withing an HTML Document. The Embed Tag requires a Closing Tag. It requires the Source of the Video or the Audio file that needs to be displayed onto the Page.
Syntax: <EMBED> Source File </EMBED>

43. Explain the Term Pseudo Classes.
A Pseudo Class is used to enhance the effects of few HTML Elements including Hover Actions, Link Colors and few others. A Pseudo Class is similar to a normal class in HTML. The only difference is that it is not explicitly defined in the HTML Markup. A Pseudo Class is defined by listing the Selector followed by a Colon and a Class Element.

44. Explain Z Index Functioning.
When you use CSS for positioning Elements within an HTML document, there are possibilities of Overlapping. To avoid this overlapping, Z Index is used. It is basically an Integer and can contain Positive as well as Negative values. The default value is Zero.

45. Explain methods of CSS application to HTML documents.
The following methods are used to include CSS styles in HTML documents:
INLINE: This is the best method to use if you want to style to a single element within an HTML document. You just need to define the STYLE Tag by inserting it within a Paragraph tag such as <p> or <a>.

INTERNAL: This is accomplished by defining the HEAD of an HTML document by wrapping attributes within a STYLE tag.

EXTERNAL: This is done by making a separate .CSS file and including the LINK of it within the HTML document. This can increase the Page Load Time.

46. Enlist Disadvantages of External Style Sheets:
1. It requires more data to download to import style information for each HTML document from a relative .CSS file.
2. Rendering an HTML document is not possible if the Style Sheet is not loaded properly.
3. For a small quantity of Style Definitions within a Single Page, it is not recommended to use an external CSS file.

47. Explain Float Property in Cascading Style Sheet?
Suppose you need to move an Image to the Left or Right of an HTML Page along with its Caption Text or any Text that iis wrapped around it, you should make use of Float property.

48. What is CSS Selector?
CSS Selector is an equivalent alternative for HTML Element. It acts as a String that identifies the Elements to which a declaration will be applied. It can also be a set of declarations. A Selector can be thought of as a Link between HTML document and the Style Sheet.

49. Explain Image Sprites in CSS.
When multiple images or a set of images is combined into a single image, it is known as an Image Sprite. It is better to use Sprite Images as loading every image on a Web page takes time and this reduces the page load time.

50. Enlist the Merits of Embedded Style Sheets.
1. No extra download from external .css is required thereby reducing page load time and increased speed.
2. It is therefore possible to create Multiple Tags within a single HTML document.
3. Styles can implemented using grouping methods and also with Selectors.

51. Explain the difference between a Class and an ID Selector?
A Class can be linked to number of HTML elements whereas an ID Selector can be linked to only one occurrence of an element in a single HTML document.

52. Explain Logical and Physical Tags.
Logical Tags is an old concept in HTML and they are mainly for Content appearance. With the advancement in Physical Tags, Logical tags have now taken a back step. Physical Tags are used extensively for presentational mark-up features and are better for appearance in an HTML document.

So this was the list of some important HTML interview questions and answers. If you found any information incorrect or missing in above list then please mention it by commenting below.

5 thoughts on “HTML Interview Questions and Answers”

  1. This is very good article for web designer’s. They can learn more about Html from this post 🙂 thank you admin

  2. Who in his right mind write a aler(‘hello world’) in html body. If someone going to do that in interview. they will never get a job

Leave a Comment

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