1. What is HTML?
HTML stands for Hyper Text Markup Language. It is the standard markup language used to create web
pages and describe their structure. HTML uses various tags to define the elements and content within a
web page.
2. What are the different versions of HTML?
The major versions of HTML are:
HTML4: The version released in 1997.
XHTML: A stricter and cleaner version of HTML, based on XML.
HTML5: The latest version, introduced in 2014, with new features and improvements for modern web
development
3. What is the difference between HTML and HTML5?
HTML5 introduced several new elements and APIs, providing better support for multimedia, improved
semantics, and enhanced functionality. Some notable features in HTML5 include native video and audio
support, canvas for graphics, local storage, and improved form elements.
4. What is the purpose of a DOCTYPE declaration?
A DOCTYPE declaration is used at the beginning of an HTML document to specify the version of HTML
being used. It helps the browser render the page correctly by triggering the appropriate rendering
mode.
5. What are the block-level and inline elements in HTML?
Block-level elements create a block on the page and typically start on a new line. Examples include
<div>, <p>, <h1> to <h6>, and <ul>. Inline elements, on the other hand, do not start on a new line and
only take up as much width as necessary. Examples include <span>, <a>, <strong>, and <em>.
6. What is the purpose of the <div> element?
The <div> element is a generic container that allows you to group and style other elements. It is
commonly used for layout purposes and to apply CSS styles to a group of related elements.
7. What are meta tags in HTML?
Meta tags provide metadata about an HTML document. They are placed in the <head> section of an
HTML page and are not displayed on the web page itself. Commonly used meta tags include the
character encoding declaration, viewport configuration, and description of the page for search engines.
8. How do you include CSS styles in an HTML document?
You can include CSS styles in an HTML document using the <style> tag within the <head> section, or by
linking an external CSS file using the <link> tag.
9. What is the difference between <div> and <span> elements?
The <div> element is a block-level container used for grouping and applying styles to sections of content.
It is typically used for layout purposes. The <span> element, on the other hand, is an inline container
used for applying styles to small sections of text or inline elements.
10. What are the different types of lists in HTML?
HTML supports three types of lists:
<ul>: Unordered list, which creates a bullet point list.
<ol>: Ordered list, which creates a numbered list.
<dl>: Definition list, which consists of terms and their corresponding definitions.
11. What is the purpose of the <iframe> element?
The <iframe> (inline frame) element is used to embed another HTML document within the current
document. It is commonly used to display external content such as maps, videos, or other web pages.
12. How do you create a hyperlink in HTML?
To create a hyperlink, you use the <a> (anchor) element. The href attribute is used to specify the URL or
the location the link should navigate to. For example: <a href="https://www.example.com">Visit
Example</a>
13. What is the purpose of the <img> element?
The <img> element is used to insert an image into an HTML document. It requires the src attribute to
specify the image source (URL or file path) and the alt attribute to provide alternative text that is
displayed if the image cannot be loaded
14. What is the difference between the <strong> and <em> elements?
The <strong> element is used to indicate strong importance or emphasis, typically displayed in bold. It
carries more weight than normal text. The <em> element, on the other hand, is used to emphasize text,
typically displayed in italics. It indicates a change in emphasis or a different tone.
15. How do you create a table in HTML?
To create a table, you use the <table> element along with its related elements:
<tr>: Table row, used to define a row in the table.
<td>: Table data, used to define a cell within a row.
<th>: Table heading, used to define a header cell in the table.
16. What is the purpose of the <form> element?
The <form> element is used to create an interactive form on a web page. It can contain various form
elements like input fields, checkboxes, radio buttons, and buttons. The data entered in the form can be
submitted to a server for processing using the action attribute.
17. What is the difference between HTML and CSS?
HTML (HyperText Markup Language) is used for creating the structure and content of a web page. It
defines the elements and their arrangement. CSS (Cascading Style Sheets), on the other hand, is used for
styling and formatting the HTML elements. It controls the presentation and appearance of the web
page.
18. What are semantic elements in HTML5?
Semantic elements in HTML5 are tags that carry meaning and describe the structure of the content they
enclose. Examples of semantic elements include <header>, <nav>, <section>, <article>, <footer>, and
<aside>. These elements provide more context to the content and assist search engines in
understanding the page structure.
19. What is the purpose of the alt attribute in the <img> tag?
The alt attribute in the <img> tag specifies alternative text for an image. It is used when the image
cannot be displayed or to provide accessibility to visually impaired users who use screen readers. The
alternative text should describe the image in a meaningful way.
20. How do you create a hyperlink that opens in a new tab?
To create a hyperlink that opens in a new tab, you can use the target attribute with the value _blank. For
example: <a href="https://www.example.com" target="_blank">Visit Example</a>. This attribute
instructs the browser to open the linked page in a new browser tab.
21. What is the purpose of the <head> section in an HTML document?
The <head> section of an HTML document contains metadata about the document, including the title of
the page, links to external stylesheets, scripts, and various meta tags. It does not directly contain visible
content but provides information about the page to the browser and search engines.
22. How do you create a numbered list starting from a specific number in HTML?
To create a numbered list starting from a specific number, you can use the start attribute with the <ol>
tag. For example: <ol start="5">. This will start the numbering from 5 instead of the default 1.
23. How can you add comments in HTML?
In HTML, you can add comments using the <!-- and --> delimiters. Anything placed between these
delimiters will be treated as a comment and will not be rendered by the browser. Comments are useful
for adding notes and explanations within the HTML code.
24. What is the purpose of the <meta charset> tag?
The <meta charset> tag is used to declare the character encoding for an HTML document. It ensures that
the browser interprets the text correctly, especially for special characters and non-English characters.
The most commonly used character encoding is UTF-8, which supports a wide range of characters.
25. What is the purpose of the colspan and rowspan attributes in an HTML table?
The colspan attribute is used to specify the number of columns a table cell should span. It allows a cell to
occupy multiple columns horizontally. Similarly, the rowspan attribute specifies the number of rows a
table cell should span, allowing it to occupy multiple rows vertically.