HTML Interview Questions -03
How to create nest tables within tables in HTML?
We can create nest table i.e. table inside a table. To create table we use following attributes:
<table>……</table>: declare starting and ending of table.
<tr>…</tr>: declare table row.
<td>…</td>: table data.
<table>
<tr>
<td>first cell of the outer table</td>
<td>second cell of the outer table,
creating second table inside the first table
<table>
<tr>
<td>first cell of the second table</td>
<td>second cell of the second table</td>
</tr>
</table>
</td>
</tr>
</table>
Explain Non Breaking space in HTML.
When we add many spaces in the content then HTML remove all space except one space this is Non Breaking Space. To overcome this problem we use “ ”. Suppose we want to add 3 space between two words then we have to use &nbp three time.
Example:
actual code:- hello I m Rohit Srivastava.
Display as:- Hello I m Rohit Srivastava.
But when we use  :
Actual code:- Hello   ; I m Rohit Srivastava.
Display as:- Hello I m Rohit Srivastava
How do I link to a location in the middle of an HTML document?
We can link to a location in the middle of an HTML document. Using Following steps:
- Label the destination of the link. There are two ways of labeling destination using Anchor:
o NAME attribute:
Example: <h2><a name=”destination”>Destination: Explanation</a></h2>
o ID attribute:
Example: <h2 id=”Destination_ID”> Destination: Explanation </h2> - Link to the labeled destination: we can link with the destination in the same URL page and with Different URL page.
Example:
Same URL: <a href=”#Destination”> Visit to destination</a> or
Different URL: <a href=”thesis.html#section2″>go to Section 2 of my thesis</a>
Explain Cell Padding and Cell Spacing.
Cell Padding: it refers to the gap or space between the cell content and cell border or cell wall.
Cell Spacing: It refers to the gap between the two cells of same tables.
In HTML cell spacing and padding both are used with Table Border layout.
Example:
<table border cellpadding=2>
<table border cellspacing=2>
<table border cellpadding=2 cellspacing=2>
How to create a button which acts like a link?
To create buttons which act as a hyperlink, there are two ways:
- <FORM ACTION=”[url]” METHOD=get>
<INPUT TYPE=submit VALUE=”Text on button”>
</FORM> - <INPUT TYPE=”submit” VALUE=”Go to my link location”
ONCLICK=” http://www.careerride.com/;” />
What is difference between HTML and XHTML?
The differences between HTML and XHTML are:
- HTML is application of Standard Generalized Markup Language(SGML) whereas XML is application of Extensible Markup Language(XML).
- HTML is a static Web Page whereas XHTML is dynamic Web Page.
- HTML allows programmer to perform changes in the tags and use attribute minimization whereas XHTML when user need a new markup tag then user can define it in this.
- HTML is about displaying information whereas XHTML is about describing the information
How many types CSS can be include in HTML?
There are three ways to include the CSS with HTML:
- Inline CSS: it is used when only small context is to be styled.
o To use inline styles add the style attribute in the relevant tag. - External Style Sheet: is used when the style is applied to many pages.
o Each page must link to the style sheet using the <link> tag. The <link> tag goes inside the head section:
<head>
<link rel=”stylesheet” type=”text/css” href=”mystyle.css” />
</head> - Internal Style Sheet: is used when a single document has a unique style.
o Internal styles sheet needs to put in the head section of an HTML page, by using the <style> tag, like this:
<head>
<style type=”text/css”>
hr {color:sienna}
p {margin-left:20px}
body {background-image:url(“images/back40.gif”)}
</style>
</head>
What are logical and physical tags in HTML?
Logical tags are used to tell the meaning of the enclosed text. The example of the logical tag is <strong> </strong> tag. When we enclosed text in strong tag then it tell the browser that enclosed text is more important than other text.
Physical text are used to tell the browser that how to display the text enclosed in the physical tag.
Some example of the physical tags are: <b> , <big> , <i>
Does HTML support Javascripts?
Yes, HTML supports JavaScripts. We can use JavaScript anywhere in the HTML Coding. Mainly there are four sections where we can add JavaScript in HTML.
- Head Section: we can add JavaScript in Head section of HTML.
<head>…..Javascript…. </head> - Body Section: <body>….. Javascript…</body>
- Head and Body both: we can add Javascript in both head and body section.
<body….Javascript…</body> and <head>…..Javascript…. </head> - External File: script in and external file and then include in <head> ….. </head> section.
Explain marquee tag.
Marquee tag: Marquee tag is used when we want that some text or content move in the web page whether horizontally or vertically.
Syntax of Marquee tag: <marquee>move text</marquee>
Attribute of Marquee tag are: bgcolor, direction, height, width, vspace etc.
How do I add midi music to my web page?
We can add midi Music in our HTML web page using following tag:
<bgsound src=”music.mid” loop=”1″>
Attribute LOOP= 1: shows that music.mid is played only for one time. We can also set the value of loop to infinite. This tag is supported by Netscape and Internet Explorer.
Example: <embed src=”canyon.mid” Autostart=TRUE Width=145 Height=60 Loop=true>
What are new Media Elements in HTML5?
Following are the New Media Elements are present in HTML5:
- <audio> tag: for playing audio.
- <video> tag: for playing video.
- <source> tag: For media resources for media elements.
- <embed> tag: For embedded content,
- <track> tag: For text tracks used in media players
Explain various HTML list tags.
In HTML we can list the element in two ways:
- Ordered list: in this list item are marked with numbers.
Syntax: <ol>
<li> first item </li>
<li>second item </li> </ol>
Display as: 1. First item
2. Second item. - Unordered Lists: in this item are marked with bullets.
Syntax: <ul>
<li> first item </li>
<li>second item </li> </ul>
Display as:
-First item
-Second item.
Explain HTML background.
There are two types of background in HTML:
- Colored Background: in this the background of the html is colored.
The Syntax is: <body bgcolor = “red”>
The value of the bgcolor can be set in three ways by hexadecimal number, an RGB value and Color name.
Example: <body bgcolor = “black”>
<body bgcolor = “rgb(0,0,0)”>
<body bgcolor = “#000000”> - Image Background: in this we set the background of the website by an image. Syntax used for this is : <body background=”study.gif”>
What is CSS?
CSS stands for Cascading Style Sheets. By using CSS with HTML we can change the look of the web page by changing the font size and color of the font. CSS plays an important role in building the website. Well written CSS file can be used to change the presentation of each web page. By including only one CSS file. It gives web site developer and user more control over the web pages.
What is difference between HTML and HTML5?
The differences between HTML and HTML5 are:
- Document of HTML is very large as compare to the HTML5.
- Audio and Video tags are not present in HTML whereas HTML5 contains audio and video tags.
- Vector technology is not integral part of HTML whereas HTML5 Vector technology is the integral part of it.
- HTML supported by all old browsers whereas HTML5 is supported by new browser.
- In HTML web sockets are not available whereas in HTML5 Full duplex communication channel is present.
How to insert Javascript in HTML?
We can insert JavaScript in HTML using <Script tag>. JavaScript can be enclosed in <script type = text/javascript> and ending with </script>.
Example:
<html>
<body>
<script type=”text/javascript”>
…JavaScript….
</script>
</body>
</html>
What is the Use of SPAN in HTML and give one example?
SPAN: Used for the following things:
- Highlight the any color text
- For adding colored text
- For adding background image to text.
Example:
<p>
<span style=”color:#000000;”>
In this page we use span.
</span>
</p>