HTML Interview Questions And Answers

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.
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.
What is the role of XHTML?
XHTML makes the HTML5 more compliant with wide variety of browsers and webpage readers, generators and validators.
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.
Define an element?
An element is composed of a beginning tag, ending tag and the contents between the tags.
Example -
<p> Hello World! </p>
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>

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 />
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>

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=""> </iframe>
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.
What are the header elements?
The header element contain h1 to h6 visible heading.

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.
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.
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.
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.
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.
What is the role of background attribute?
The background attribute is used to display a background image on the web page.
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.
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.
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.
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).
Define <li> element?
The li element defines an individual list item and can only appear inside the handful of list-related elements detailed above.
What is the role of type attribute?
The type attribute lets the web page author change the style of the numbering.
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.
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

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.
What is the use of strong element?
The strong element is used to emphasize a phrase of text content.
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

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.
How can you underline a text?
By using <u> element, we can add a solid underline on text.
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.
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.
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.
What is the role of _blank attribute?
The _blank attribute is used to send the results to completely new window.
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.
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.
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.
What is Object attribute?
The object element's purpose is to embed into a document a variety of different kinds of media files.
What is cellpadding?
Use the cellpadding attribute to create some space around the contents of table cells.

What is cellspacing?
The cellspacing attribute is used to create space around (that is, outside of) table cells.
What is valign?
The valign allows you to override the default vertical alignment for content inside table cells.
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.

What is the use of frame?
The frame element defines one particular window within a frameset collection.
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.
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.
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).

What is the use of canvas element?
Used to draw graphics, on the fly, via scripting (usually JavaScript).
What is HTML5 Geolocation?
HTML5 Geolocation is basically used to locate the position of current internet user.
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>

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 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