Top 100 HTML Interview Questions and Answers - Follow Us for More
1.What is HTML?
a.??????HTML stands for Hypertext Markup Language. It is the standard markup language used for creating web pages.
2.??????What are the basic building blocks of HTML?
a.??????The basic building blocks of HTML are tags, which are used to structure and define the content of a web page.
3.??????What is the DOCTYPE declaration in HTML?
a.??????The DOCTYPE declaration is used to specify the version of HTML that the web page is written in. It helps the browser render the page correctly.
4.??????What is the difference between HTML elements, tags, and attributes?
a.??????HTML elements are the individual components that make up a web page, such as headings, paragraphs, and images. Tags are used to mark the beginning and end of HTML elements. Attributes provide additional information or modify the behavior of HTML elements.
5.??????What are some common HTML tags?
a.??????Some common HTML tags include <h1> to <h6> for headings, <p> for paragraphs,
<a> for links, <img> for images, <ul> and <li> for unordered lists, and <table> for tables.
6.??????What is the purpose of the <head> tag in HTML?
a.??????The <head> tag is used to contain meta-information about the HTML document, such as the title, character encoding, and linked stylesheets or scripts.
7.??????What is the purpose of the <body> tag in HTML?
a.??????The <body> tag is used to define the main content of the HTML document that is displayed in the browser.
8.??????What is the difference between block-level elements and inline elements?
a.??????Block-level elements start on a new line and take up the full width available, while inline elements do not start on a new line and only take up the necessary width to display the content.
9.??????What is the purpose of the <div> tag in HTML?
a.??????The <div> tag is a container used to group and style HTML elements. It is commonly used for layout and organization purposes.
10.????What is the purpose of the <span> tag in HTML?
a.??????The <span> tag is an inline container used to apply styles or manipulate specific portions of text within a larger block of content.
11.????What is the purpose of the <a> tag in HTML?
a.??????The <a> tag is used to create hyperlinks to other web pages, files, or locations within the same page.
12.????What is the purpose of the href attribute in the <a> tag?
a.??????The href attribute specifies the URL or destination of the hyperlink.
13.????What is the purpose of the <img> tag in HTML?
a.??????The <img> tag is used to display images on a web page.
14.????What is the purpose of the src attribute in the <img> tag?
a.??????The src attribute specifies the source file or URL of the image.
15.????What is the purpose of the <table> tag in HTML?
a.??????The <table> tag is used to create tabular data with rows and columns.
16.????What are the <thead>, <tbody>, and <tfoot> tags used for?
a.??????The <thead> tag is used to group the header content in a table. The <tbody> tag is used to group the body content, and the <tfoot> tag is used to group the footer content.
17.????What is the purpose of the <tr> tagin HTML?
18.?????The <tr> tag is used to define a row in a table.
19.????What is the purpose of the <th> and <td> tags in HTML?
a.??????The <th> tag is used to define a header cell in a table, while the <td> tag is used to define a data cell.
20.????What is the purpose of the colspan and rowspan attributes in the <td> and <th> tags?
a.??????The colspan attribute specifies the number of columns a cell should span, and the rowspan attribute specifies the number of rows a cell should span.
21.????What is the purpose of the <form> tag in HTML?
a.??????The <form> tag is used to create an interactive form on a web page to collect user input.
22.????What are some commonly used form elements in HTML?
a.??????Some commonly used form elements include <input> for text input, checkboxes, and radio buttons, <select> for dropdown lists, and <textarea> for multiline text input.
23.?????What is the purpose of the name attribute in form elements?
a.??????The name attribute is used to identify form elements and is used to retrieve their values on the server side.
24.?????What is the purpose of the method attribute in the <form> tag?
a.??????The method attribute specifies the HTTP method used to send form data to the server. The most common values are "GET" and "POST".
25.?????What is the purpose of the action attribute in the <form> tag?
a.??????The action attribute specifies the URL or destination where the form data should be sent.
26.?????What is the purpose of the <input> tag in HTML?
a.??????The <input> tag is used to create various types of form input fields, such as text fields, checkboxes, radio buttons, and submit buttons.
27.????What is the purpose of the type attribute in the <input> tag?
a.??????The type attribute specifies the type of input field to be created, such as "text", "checkbox", "radio", "submit", etc.
28.?????What is the purpose of the <label> tag in HTML?
a.??????The <label> tag is used to associate a text label with a form element. It improves accessibility and allows users to click on the label to activate the associated form element.
29.?????What is the purpose of the <select> tag in HTML?
a.??????The <select> tag is used to create a dropdown list of options for users to choose from.
30.?????What is the purpose of the <option> tag in the <select> tag?
a.??????The <option> tag is used to define an option within a dropdown list.
31.????What is the purpose of the value attribute in the <option> tag?
a.??????The value attribute specifies the value associated with an option. It is sent to the server when the form is submitted.
32.?????What is the purpose of the <textarea> tag in HTML?
a.??????The <textarea> tag is used to create a multiline text input field where users can enter larger blocks of text.
33.?????What is the purpose of the <iframe> tag in HTML?
a.??????The <iframe> tag is used to embed another web page or document within the current HTML document.
34.?????What is the purpose of the <div> tag in HTML?
a.??????The <div> tag is a container used to group and style HTML elements. Itis commonly used for layout and organization purposes.
35.?????What is the purpose of the <span> tag in HTML?
a.??????The <span> tag is an inline container used to apply styles or manipulate specific portions of text within a larger block of content.
36.?????What is the purpose of the <audio> and <video> tags in HTML?
a.??????The <audio> tag is used to embed audio content on a web page, and the <video> tag is used to embed video content. They provide built-in controls for playing and pausing the media.
37.????What is the purpose of the <canvas> tag in HTML?
a.??????The <canvas> tag is used to draw graphics, animations, and other visualizations on a web page using JavaScript.
38.?????What is the purpose of the <header>, <main>, <footer>, and <nav> tags in HTML?
a.??????The <header> tag is used to define the header section of a web page. The <main> tag is used to define the main content area. The <footer> tag is used to define the footer section, and the <nav> tag is used to define the navigation section.
39.?????What is the purpose of the <article> and <section> tags in HTML?
a.??????The <article> tag is used to define an independent, self-contained content section that can be distributed and reused. The <section> tag is used to define a section of related content within an HTML document.
40.?????What is the purpose of the <aside> tag in HTML?
a.??????The <aside> tag is used to define content that is related to the main content but can be considered separate from it, such as sidebars or pull-out quotes.
41.????What is the purpose of the <figure> and <figcaption> tags in HTML?
a.??????The <figure> tag is used to encapsulate self-contained content, such as images, diagrams, or videos, along with an optional caption defined using the <figcaption> tag.
42.?????What is semantic HTML?
a.??????Semantic HTML is the practice of using HTML elements that accurately describe the meaning or purpose of the content they contain. It improves accessibility, search engine optimization, and code readability.
43.?????What are the advantages of using external CSS stylesheets?
a.??????Some advantages of using external CSS stylesheets include easier maintenance, consistent styling across multiple pages, better separation of concerns (HTML for structure, CSS for presentation), and faster page loading times due to browser caching.
44.?????What is the purpose of the class attribute in HTML?
a.??????The class attribute is used to assign one or more class names to an HTML element. It allows for targeted styling and JavaScript manipulation.
45.?????What is the purpose of the id attribute in HTML?
a.??????The id attribute is used to assign a unique identifier to an HTML element. It is used for targeting specific elements with CSS or JavaScript.
46.?????What is the purpose of the CSS display property?
a.??????The display property is used to control how an element is rendered and displayed in the browser. It can change an element's behavior from block to inline, or vice versa.
47.?????What is the purpose of the CSS position property?
a.??????The position property is used to specify the positioning method of an element on the web page. It can be set to static, relative, absolute, or fixed.
48.?????What is the purpose of the CSS float property?
a.??????The float property is used to align an element to theleft or right of its container, allowing other content to wrap around it.
49.?????What is the purpose of the CSS box-sizing property?
a.??????The box-sizing property is used to control how the width and height of an element are calculated. It can be set to content-box (default) or border-box.
50.?????What is the purpose of the CSS flexbox layout?
a.??????The CSS flexbox layout is a flexible box layout model that allows you to create responsive and flexible layouts. It provides powerful tools for arranging and aligning elements within a container.
51.????What is the purpose of the CSS grid layout?
a.??????The CSS grid layout is a two-dimensional layout model that allows you to create complex grid-based layouts. It provides precise control over the positioning and alignment of elements.
领英推荐
52.?????What is the purpose of the <meta> tag in HTML?
a.??????The <meta> tag is used to provide metadata about an HTML document, such as the character encoding, viewport settings, or author information.
53.?????What is the purpose of the viewport meta tag in HTML?
a.??????The viewport meta tag is used to control the width and scaling of the viewport on mobile devices. It ensures that web pages are displayed correctly and responsively on different screen sizes.
54.?????What is the purpose of the alt attribute in the <img> tag?
a.??????The alt attribute is used to provide alternative text for an image. It is displayed if the image cannot be loaded or for accessibility purposes.
55.?????What is the purpose of the title attribute in HTML?
a.??????The title attribute is used to provide additional information or a tooltip text for an element. It is displayed when the user hovers over the element.
56.?????What is the purpose of the <fieldset> and <legend> tags in HTML?
a.??????The <fieldset> tag is used to group related form elements together, and the
<legend> tag is used to provide a caption or description for the <fieldset>.
57.?????What is the purpose of the <datalist> tag in HTML?
a.??????The <datalist> tag is used to provide a list of predefined options for an <input> field. It provides suggestions as the user types.
58.?????What is the purpose of the <meter> tag in HTML?
a.??????The <meter> tag is used to represent a scalar measurement within a known range, such as a progress bar, disk usage, or temperature.
59.?????What is the purpose of the <time> tag in HTML?
a.??????The <time> tag is used to represent a specific time or date. It can be used for machine-readable dates, event schedules, or time-related content.
60.?????What is the purpose of the required attribute in form elements?
a.??????The required attribute is used to specify that a form input field must be filled out before submitting the form.
61.????What is the purpose of the autocomplete attribute in form elements?
a.??????The autocomplete attribute is used to control whether a form input field should have autocomplete suggestions or not.
62.?????What is the purpose of the <nav> tag in HTML?
a.??????The <nav> tag is used to define a section of a web page that contains navigation links.
63.?????What is the purpose of the <abbr> tag in HTML?
a.??????The <abbr> tag is used to define an abbreviation or acronym. It can provide additional information when the user hovers over it.
64. What is the purpose of the <pre> tag in HTML?
The <pre> tag is used to display preformatted text, preserving both spaces and line breaks as they appear in the HTML code.
65. What is the purpose of the disabled attribute in form elements?
The disabled attribute is used to make a form input field or button non-editable or non- clickable. It prevents user interaction with the element
66. What is the purpose of the readonly attribute in form elements?
The readonly attribute is used to make a form input field non-editable. It allows the user to view the value but not modify it.
67.What is the purpose of the <progress> tag in HTML?
The <progress> tag is used to represent the progress of a task or the completion of a process, such as a file upload or a download.
68. What is the purpose of the placeholder attribute in form elements?
The placeholder attribute is used to provide a hint or example value for a form input field. It is displayed in the field until the user enters their own value.
69.What is the purpose of the <ruby> and <rt> tags in HTML?
The <ruby> tag is used to annotate or provide pronunciation guidance for characters in East Asian typography. The <rt> tag is used to define the pronunciation of the characters.
70.What is the purpose of the <bdi> tag in HTML?
The <bdi> tag is used to isolate a section of text that is to be formatted in a different direction from its surrounding text. It is often used for multilingual content.
71.What is the purpose of the <details> and <summary> tags in HTML?
The <details> tag is used to create a collapsible section that can be toggled open or closed. The <summary> tag is used to provide a summary or heading for the collapsible section.
72. What is the purpose of the <wbr> tag in HTML?
?The <wbr> tag is used to suggest a line break opportunity within a word. It is used to control word wrapping in long URLs or strings without adding unnecessary spaces.
73. What is the purpose of the contenteditable attribute in HTML?
The contenteditable attribute is used to make an element editable by the user. It allows the user to modify the content directly in the browser.
74. What is the purpose of the spellcheck attribute in form elements?
The spellcheck attribute is used to enable or disable spell checking for a form input field.
75. What is the purpose of the <cite> tag in HTML?
?The <cite> tag is used to mark a reference to a creative work, such as a book, article, or movie title.
76. What is the purpose of the download attribute in the <a> tag?
The download attribute is used to specify that a hyperlink should be downloaded instead of navigated to when clicked. It specifies the filename of the downloaded file.
77. What is the purpose of the <script> tag in HTML?
The <script> tag is used to embed or reference JavaScript code within an HTML document.
78. What is the difference between inline and external JavaScript?
Inline JavaScript is directly embedded within the HTML document using the <script> tag, while external JavaScript is saved in a separate .js file and linked to the HTML document using the src attribute of the <script> tag.
79. What is the purpose of the <noscript> tag in HTML?
The <noscript> tag is used to provide an alternative content that should be displayed if a web browser does not support or has disabled JavaScript.
80. What is the purpose of the defer attribute in the <script> tag?
The defer attribute is used to indicate that the script should be executed after the document has been parsed, allowing it to not block rendering.
81. What is the purpose of the async attribute in the <script> tag?
?The async attribute is used to indicate that the script can be executed asynchronously, without blocking the rendering of the page.
82.What is the purpose of the <iframe> tag in HTML?
?The <iframe> tag is used to embed another web page or document within the current HTML document.
83.What is the purpose of the sandbox attribute in the <iframe> tag?
?The sandbox attribute is used to restrict the capabilities of the content within the <iframe>, providing a secure and isolated environment.
84.What is the purpose of the <datalist> tag in HTML?
The <datalist> tag is used to provide a list of predefined options for an <input> field. It provides suggestions as the user types.
85.What is the purpose of the autocomplete attribute in form elements?
The autocomplete attribute is used to control whether a form input field should have autocomplete suggestions or not.
86.What is the purpose of the <figure> and <figcaption> tags in HTML?
?The <figure> tag is used to encapsulate self-contained content, such as images, diagrams, or videos, along with an optional caption defined using the <figcaption> tag.
87.What is the purpose of the <meter> tag in HTML?
?The <meter> tag is used to represent a scalar measurement within a known range, such as a progress bar, disk usage, or temperature.
88.What is the purpose of the <time> tag in HTML?
?The <time> tag is used to represent a specific time or date. It can be used for machine- readable dates, event schedules, or time-related content.
89. What is the purpose of the required attribute in form elements?
The required attribute is used to specify that a form input field must be filled out before submitting the form.
90.What is the purpose of the autocomplete attribute in form elements?
?The autocomplete attribute is used to control whether a form input field should have autocomplete suggestions or not.
91.What is the purpose of the <nav> tag in HTML?
The <nav> tag is used to define a section of a web page that contains navigation links.
?
92.What is the purpose of the <abbr> tag in HTML?
The <abbr> tag is used to define an abbreviation or acronym. It can provide additional information when the user hovers over it.
93.What is the purpose of the <pre> tag in HTML?
?The <pre> tag is used to display preformatted text, preserving both spaces and line breaks as they appear in the HTML code.
94. What is the purpose of the disabled attribute in form elements?
The disabled attribute is used to make a form input field or button non-editable or non- clickable. It prevents user interaction with the element.
95. What is the purpose of the readonly attribute in formelements?
The readonly attribute is used to make a form input field non-editable. It allows the user to view the value but not modify it.
96. What is the purpose of the <progress> tag in HTML?
The <progress> tag is used to represent the progress of a task or the completion of a process, such as a file upload or a download.
97.What is the purpose of the placeholder attribute in form elements?
The placeholder attribute is used to provide a hint or example value for a form input field. It is displayed in the field until the user enters their own value.
98. What is the purpose of the <ruby> and <rt> tags in HTML?
The <ruby> tag is used to annotate or provide pronunciation guidance for characters in East Asian typography. The <rt> tag is used to define the pronunciation of the characters.
99. What is the purpose of the <bdi> tag in HTML?
The <bdi> tag is used to isolate a section of text that is to be formatted in a different direction from its surrounding text. It is often used for multilingual content.
100What is the purpose of the <details> and <summary> tags in HTML?
?
The <details> tag is used to create a collapsible section that can be toggled open or closed. The <summary> tag is used to provide a summary or heading for the collapsible section.
What is the purpose of the <wbr> tag in HTML?
- The <wbr> tag is used to suggest a line break opportunity within a word. It is used to control word wrapping in long URLs or strings without adding unnecessary spaces.
python || C++ || Html || CSS || Javascript ||Oops || Database || SQL. graduate student at JEC-23 Jabalpur.
11 个月Thanks
Software Developer
1 年So many questions got repeated. Anyway nice collection. TQ
Adjunct faculty, ICFAI Foundation for Higher Education
1 年Gave all details of HTML precisely. Useful
"Associate Software Engineer at Accenture | Core & Advanced Java | Microservices | Spring Boot | Agile | GitHub | MySQL | Full Stack Development"
1 年Very useful??
Cybage
1 年Thanks