HTML Interview Questions And Answers

1.
Define HTML?
HTML acronym for Hypertext Markup Language. HTML is used to create Webpages. Hypertext is a way to link the text. Markup language defines the definition and presentation of a text or marking up text into a structural unit like headings, paragraphs etc.
2.
What is W3C?
W3C is World Wide Web Consortium, which is responsible for developing open standards for the web. W3C introduced XHTML to solve the problems in the HTML version 4.
3.
What is the role of XHTML?
XHTML makes the HTML5 more compliant with wide variety of browsers and webpage readers, generators and validators.
4.
What are overcome in HTML5 from HTML4?
In HTML5, we can make interactive web pages that can play audio, video and support animations from within browsers without including any plug-ins, flash etc.
5.
Define an element?
An element is composed of a beginning tag, ending tag and the contents between the tags.
Example -
<p> Hello World! </p>
6.
What is an attribute?
Attribute provides additional features to tag or we can say that it enhances the performance of a webpage. Attribute performs a major role in the form, table, to provide styles to the element. Attribute always come in name/value pairs.
In this example, bgcolor is an attribute.

<body bgcolor="red"><p>Welcome to etutorialspoint.</p>




7.
What is readonly attribute?
The readonly attribute is used to prevent the user from typing data into a text box, password, or text area. This attribute can not be modified
<input type="text" name="org" value="Global" readonly />
8.
What is iframe?
Iframe is used to embed an inline frame that contains an HTML document within the current HTML document. The <iframe> element creates a nested browser content into which another HTML document can be loaded.
<iframe src="/menu.html"></iframe>

9.
What is sandboxing embedded content?
Sandboxing is used for preventing malware and annoyances such as pop-ups from being introduced when the content is embedded on your HTML page.The sandbox attribute places a set of extra restrictions on any content hosted by the iframe. When the sandbox attribute is set, the content is treated as being from a unique and potentially dangerous origin.
<iframe sandbox src="http://someOtherDomain.net/content"> </iframe>
10.
Give some examples of hyperlink target attribute with definition.
_blank : Open in a new browser window.
_parent : Open in a parent frame or window.
_self : Open in the current window or frame.
_top : Open in the topmost frame, thus replacing the contents of the window.
11.
What are the header elements?
The header element contain h1 to h6 visible heading.




12.
What is thematic break?
<hr/> element is thematic break. It is void element, so it cannot have any content. This is used to denote a transition to another topic.
13.
How many types of listing elements?
There are three types of listing elements -
i. Ordered List - An ordered list is a number list. <ol> element is used to create ordered list.
ii. Unordered List - An unordered list is not auto-numbered. <ul> element is used to create unordered list.
iii. Description List - <dl> element is used to create description list.
14.
What is meta data?
Meta Data contains information about the document itself, or associated with related resources such as scripts and stylesheets. It provides additional information about the page, for example, which character encoding the page uses, a summary of the page's content, instructions to search engines about whether or not to index content, and so on.
15.
What is Doctype?
The doctype declaration, which should be the first item to appear in the source markup of any web page, is an instruction to the web browser (or other user agent) that identifies the version of the markup language in which the page is written. It refers to a known Document Type Definition, or DTD for short.
16.
What is the body element.
The body element wraps around all of the content that will be displayed on screen, such as headings, paragraphs, images, tables, and so on.
17.
What is the role of background attribute?
The background attribute is used to display a background image on the web page.
18.
Define <br> tag?




The br element creates a line break within a block of text, leaving no padding or margins between the two blocks of text created by the line break.
19.
What is the role of align attribute?
The align attribute affects the text content inside the h1, aligning it to the "left", "right", or "center", or setting it to "justify" on the page.
20.
Define target attribute?
The target attribute in the base element is almost certainly going to be used in the context of a frameset, where you want all links from a document in one frame to open in another named frame.
21.
What is the role of language attribute?
The language attribute tells the browser which scripting language is to be used inside the script block (or in the file referred to by the src attribute, as shown in the example).
22.
Define <li> element?
The li element defines an individual list item and can only appear inside the handful of list-related elements detailed above.
23.
What is the role of type attribute?
The type attribute lets the web page author change the style of the numbering.
24.
What is blink element?
The sole purpose of this element is to blink text on and off, and its sole result is the annoyance of all who come across it.
25.
How to show deleted content?
The del element is used to indicate a change that saw the author delete content which appeared in an earlier version of a document. del can be used to identify any removed content, from a specific word or phrase




26.
What is the use of span element?
For an element that offers no semantic information about the content inside and also provides no styling change, or any other visual change to speak of, the only span element is one of the most useful elements in your HTML toolbox.
27.
What is the use of strong element?
The strong element is used to emphasize a phrase of text content.
28.
What is <sub> element?
The sub element is used to define subscript-text which appears half a character's height below the baseline of the line it's on, and is most often used in mathematical or chemical formulae.
Here's an example of the sub element used for chemical formulas:
<p>That's not just water. That's not just H<sub>2</sub>O. That's
H<sub>2</sub>-woah!


29.
What is <sup> element?
The sup element is used to define superscript text that appears half a character's height above the baseline of the line it's on. It's most often used in mathematical formulas, or for the purposes of indicating footnote references.
30.
How can you underline a text?
By using <u> element, we can add a solid underline on text.
31.
What is the role of disabled attribute?
The disabled attribute stops the user from interacting with the form control. In this case, it stops the user clicking on the button, or tabbing to it using the keyboard. It prevents the user from activating the control.
32.
How can we call a webpage after submitting a form?
By using action attribute, we can inform the browser what page (or script) to call once the "submit" button is pressed.
33.
How can we send the form submission result on the same page?




By using _self target attribute, we can send the form submission result on the same page.
34.
What is the role of _blank attribute?
The _blank attribute is used to send the results to completely new window.
35.
What is the role of disable attribute?
The disabled attribute prevents the user from interacting with the form control to which it's applied. In this case, it stops the user from clicking on the checkbox, or tabbing to it with the keyboard, so the user can't activate the control.
36.
What is the hidden input type?
A hidden form input is one that, though it doesn't appear on the page, can be used for storing a value. The value in a hidden field may be set at page-load time, or it may be entered or changed dynamically, via JavaScript.
37.
How to define width of textarea element?
The cols attribute defines the width of the textarea, the value of which reflects the number of characters that can be entered. If cols isn't specified at all (even though it's a required attribute), the textarea will render with a width of 20 characters.
38.
What is Object attribute?
The object element's purpose is to embed into a document a variety of different kinds of media files.
39.
What is cellpadding?
Use the cellpadding attribute to create some space around the contents of table cells.




40.
What is cellspacing?
The cellspacing attribute is used to create space around (that is, outside of) table cells.
41.
What is valign?
The valign allows you to override the default vertical alignment for content inside table cells.
42.
What is bgcolor?
The presentation, and deprecated bgcolor attribute allows you to set a background for specific tr elements using a recognized color name or hexadecimal value.




43.
What is the use of frame?
The frame element defines one particular window within a frameset collection.
44.
What is the use of onchange attribute?
The onchange attribute is used only within the context of a form. It can be applied to an input, a textarea, or a select control to identify when the value of one of those elements is changed either by the user directly, or as a result of some scripting on the page.
45.
What is the use of onclick attribute?
The onclick event handler captures a click event from the user's mouse button on the element to which the onclick attribute is applied.
46.
What is the onload?
The onload event is used to trigger an action once a web page has completely loaded all content and, importantly, all of the external resources that the page calls in (including images, script files, CSS files, and so on).




47.
What is the use of canvas element?
Used to draw graphics, on the fly, via scripting (usually JavaScript).
48.
What is HTML5 Geolocation?
HTML5 Geolocation is basically used to locate the position of current internet user.
49.
How do you create a link to connect to a webpage?
By using anchor tag and specifying webpage link in href tag, we can create a link to connect to a webpage.
Example -
<a href="demo.html">Demo</a>


50.
What is the !DOCTYPE?
!DOCTYPE is an instruction to the web browser about what version of HTML the page is written in.


HTML Related Articles

HTML5 Geolocation
HTML5 Drag and Drop
HTML5 Canvas
HTML5 MathML
HTML5 Video
HTML5 Audio
HTML Table Alternate Row Color
Program to find prime number
HTML open link in new tab
Simple Show Hide Menu Navigation
Complete HTML Form Validation
Image popup on page load using HTML
Display data from MySQL in HTML table
Dynamically Add/Delete HTML Table Rows




Read more articles


General Knowledge



Learn Popular Language