☰
HTML Interview Questions
Last updated on Dec 21, 2024
This article covers the most frequently asked HTML and HTML5 questions asked in interviews.
Before starting with the interview questions on HTML Language, let’s first go through HTML, what is HTML, the career opportunities it provides, etc.
What is HTML?
HTML stands for HyperText Markup Language. It is a standard text formatting language used for developing web pages released in 1993. HTML is a language that is interpreted by the browser and it tells the browser what to display and how to display.
HTML is an important language to learn if anyone wants to work in the web development domain [Web designers, Web Developers]. HTML alone is not sufficient for a web developer because HTML only defines the structure of the data that will be rendered on the browser in a webpage, to make it visually appealing and to make it functional, we will need to use CSS and Javascript respectively.
The latest version of HTML is HTML5. There are two main components in HTML language, Tags and Attributes. The below image shows some basic HTML tags and attributes.
HTML Interview Questions and Answers
- Can we display a web page inside a web page or Is nesting of webpages possible?
Yes, we can display a web page inside another HTML web page. HTML provides a tag using which we can achieve this functionality.
-
What are tags and attributes in HTML?
Tags are the primary component of the HTML that defines how the content will be structured/ formatted, whereas Attributes are used along with the HTML tags to define the characteristics of the element. For example,Interview questions
, in this the ‘align’ is the attribute using which we will align the paragraph to show in the center of the view.
-
What are void elements in HTML?
HTML elements which do not have closing tags or do not need to be closed are Void elements. For Example
,,
, etc.
-
What is the advantage of collapsing white space?
In HTML, a blank sequence of whitespace characters is treated as a single space character, Because the browser collapses multiple spaces into a single space character and this helps a developer to indent lines of text without worrying about multiple spaces and maintain readability and understandability of HTML codes. -
What are HTML Entities?
In HTML some characters are reserved like ‘<’, ‘>’, ‘/’, etc. To use these characters in our webpage we need to use the character entities called HTML Entities. Below are a few mapping between the reserved character and its respective entity character to be used.
Character Entity Name Entity Number
< < <
& & &
(non-breaking space) Eg. 10 PM Eg.10  PM
- What are different types of lists in HTML?
-
What is the ‘class’ attribute in HTML?
The class attribute is used to specify the class name for an HTML element. Multiple elements in HTML can have the same class value. Also, it is mainly used to associate the styles written in the stylesheet with the HTML elements. -
What is the difference between the ‘id’ attribute and the ‘class’ attribute of HTML elements?
Multiple elements in HTML can have the same class value, whereas a value of id attribute of one element cannot be associated with another HTML element. -
Define multipart form data?
Multipart form data is one of the values of the enctype attribute. It is used to send the file data to the server-side for processing. The other valid values of the enctype attribute are text/plain and application/x-www-form-urlencoded. -
Describe HTML layout structure.
Every web page has different components to display the intended content and a specific UI. But still, there are few things which are templated and are globally accepted way to structure the web page, such as:
: Stores the starting information about the web page.
: Represents the last section of the page.
: The navigation menu of the HTML page.
: It is a set of information.
: It is used inside the article block to define the basic structure of a page.
: Sidebar content of the page.
- How to optimize website assets loading?
To optimize website load time we need to optimize its asset loading and for that:
CDN hosting – A CDN or content delivery network is geographically distributed servers to help reduce latency.
File compression – This is a method that helps to reduce the size of an asset to reduce the data transfer
File concatenation – This reduces the number of HTTP calls
Minify scripts – This reduces the overall file size of js and CSS files
Parallel downloads – Hosting assets in multiple subdomains can help to bypass the download limit of 6 assets per domain of all modern browsers. This can be configured but most general users never modify these settings.
Lazy Loading – Instead of loading all the assets at once, the non-critical assets can be loaded on a need basis.
- What are the various formatting tags in HTML?
HTML has various formatting tags:
– makes text bold
– makes text italic
– makes text italic but with added semantics importance
– increases the font size of the text by one unit
– decreases the font size of the text by one unit
– makes the text a subscript
– makes the text a superscript
– displays as strike out text
– marks the text as important
– highlights the text
– displays as added text
- What are the different kinds of Doctypes available?
The three kinds of Doctypes which are available:
Strict Doctype
Transitional Doctype
Frameset Doctype
- Please explain how to indicate the character set being used by a document in HTML?
The character set is defined in tag inside element.
<!DOCTYPE html>
…
…
…
- What is the difference between , tags and , tags?
The effect on a normal webpage of the tags , and , is the same. and tags stands for bold and italic. These two tags only apply font styling and bold tag , just adds more ink to the text, these tags don’t say anything about the text.
Whereas, and tags represent that the span of text is of strong importance or more importance and emphatic stress respectively than the rest of the text. These tags have semantic meaning.