Interview Questions HTML

HTML


1. What is HTML?
HTML is short for Hyper Text Markup Language and is a language used to create electronic documents, especially pages on the World Wide Web that contain connections called hyperlinks to other pages. Every web page you see on the Internet, including this one contains HTML code that helps format and show text and images in an easy to read format. Without HTML a browser would not know how to format a page and would only display plain text with no formatting that contained no links. Below is an example of a basic web page in HTML code.

2. What is a tag?
When you write HTML, you are writing HTML tags. These are made up of:
A less-than sign <
A word or character
Optional space followed by:
Any number of optional HTML attributes in the form of a name="value" pair
And finally a greater-than sign >

For example:
<p>
<html>
<small>

Are all HTML tags without attributes. <p> defines a paragraph. <html> defines the page as HTML. And <small> defines small print, such as in a legal document.

The following are also HTML tags:
<a href="URL">
<img src="URL">
<div id="ID">

These are all HTML tags with attributes. The <a href="URL"> is a link to another document. The <img src="URL"> points to an image to display on the page. The <div id="ID"> defines a division of the content of the page with a unique ID.
An HTML tag is the building block of HTML. In order to learn HTML, you should learn the different tags, what they are for, how they can be used, and when it's appropriate to use them. In fact, one way to learn HTML is to simply memorize all the HTML tags.

3. What is HTML attribute?
Tags can also have attributes, which are extra bits of information. Attributes appear inside the opening tag and their values sit inside quotation marks. They look something like <tag attribute="value">Margarine</tag>. We will come across tags with attributes later.

4. What is HTML element?
In common usage, the terms ?HTML element? and ?HTML tag? are used interchangeably. A tag is an element is a tag.
But according to the W3C HTML specification, an element is the basic building block of HTML and is typically made up of two tags: an opening tag and a closing tag.
For example, the paragraph element <p></p> is made up of the opening tag <p> and the closing tag </p>. The element is the collection of both the starting tag and the ending tag.
In other words, the element is the entire HTML block that creates a paragraph. And the tags are the two pieces of the element?the opening piece and the closing piece.
Most HTML elements have an opening tag and a closing tag. These tags surround the text that will display on the web page. For example, the paragraph tag has an opening tag: <p>and a closing tag: </p>. To write a paragraph of text, you write the text to display on the page and then surround it with these tags:

<p>
This is a paragraph that will display on the web page. It is surrounded by opening and closing paragraph tags.
</p>
Some HTML elements do not have a closing tag. These are called ?singleton? or ?void? elements. Void elements are easy to use because you only have to include one tag in your web page. For example, to add a line break to your page you would use the BR tag:
<br>
Void elements have only one tag as part of the element, but in XHTML, you would also include a trailing slash in the beginning tag to show that it is a void element. For example, in XHTML to add a line break you would use the BR element with a closing slash:
<br />
In general, when I refer to an HTML element or tag, I will use the term ?element? to indicate that I am referring to all parts of the element (both opening and closing tags). But I may use the term tag to mean the same thing?an HTML item that will define something on your web page.

5. What is the simplest HTML page?
HTML Code:
<HTML>
<HEAD>
<TITLE>This is my web page title! </TITLE>
</HEAD>
<BODY>
This is my message ?Hello world?!
</BODY>
</HTML>

Browser Display:
This is my message ?Hello world?!

6. Comments in HTML?
HTML comments begin with ?<!?? and ends with ??>?.
<!-- Insert comment here. -->

7. What is a Hypertext link in HTML?
A hypertext link is a special tag that links one page to another page or resource. If you click the link, the browser jumps to the link's destination.
Code example: <a href=http://www.example.com>Example</a>

8. How do I create frames in HTML?
The frameset, frame, and noframes elements are not supported in HTML5.
Frames allow an author to divide a browser window into multiple (rectangular) regions. Multiple documents can be displayed in a single window, each within its own frame. Graphical browsers allow these frames to be scrolled independently of each other, and links can update the document displayed in one frame without affecting the others.
You can't just "add frames" to an existing document. Rather, you must create a frameset document that defines a particular combination of frames, and then display your content documents inside those frames. The frameset document should also include alternative non-framed content in a NOFRAMES element.
The HTML 4 frames model has significant design flaws that cause usability problems for web users. Frames should be used only with great care.

9. What is a frameset?
The <frameset> element holds one or more <frame> elements. Each <frame> element can hold a separate document.
The <frameset> element specifies HOW MANY columns or rows there will be in the frameset, and HOW MUCH percentage/pixels of space will occupy each of them.
example : A simple two framed page.
<frameset cols="25%,*,25%">
<frame src="frame_1.htm">
<frame src="frame_2.htm">
</frameset>

10. Can I nest tables within tables?
Yes, a table can be embedded inside a cell in another table. Here's a simple example: 

<table>
<tr>
<td>this is the first cell of the OUTER table</td>
<td>this is the second cell of the OUTER table,

with the INNER table embedded in it
<table>
<tr>
<td>this is the first cell of the INNER table</td>
<td>this is the second cell of the INNER table</td>
</tr>
</table>
</td>
</tr>
</table>