HTML Frames

Frames divide a browser window into several pieces or panes, each pane containing a separate XHTML/HTML document. One of the key advantages that frames offer is that you can then load and reload single panes without having to reload the entire contents of the browser window. A collection of frames in the browser window is known as a frameset.
The window is divided up into frames in a similar pattern to the way tables are organized: into rows and columns. The simplest of framesets might just divide the screen into two rows, while a complex frameset could use several rows and columns.
There are few drawbacks also you should be aware of with frames are as follows:
  • Some browsers do not print well from framesets.
  • Some smaller devices cannot cope with frames, often because their screen is not big enough to be divided up.
  • Some time your page will be displayed differently on different computers due to different screen resolution.
  • The browser's back button might not work as the user hopes.
  • There are still few browsers who do not support farme technology.
To create a frameset document, first you need the <frameset> element, which is used instead of the <body> element. The frameset defines the rows and columns your page is divided into, which in turn specify where each individual frame will go. Each frame is then represented by a <frame> element.
You also need to learn the <noframes> element, which provides a message for users whose browsers do not support frames.
Now we will discuss these tags in detail one by one.

Creating Frames - The <frameset> Element:

  • The <frameset> tag replaces the <body> element in frameset documents.
  • The <frameset> tag defines how to divide the window into frames.
  • Each frameset defines a set of rows or columns. If you define frames by using rows then horizontal frames are created. If you define frames by using columns then vertical farmes are created.
  • The values of the rows/columns indicate the amount of screen area each row/column will occupy.
  • Each farme is indicated by <frame> tag and it defines what HTML document to put into the frame.

Example:

Following is the example to create three horizontal frames:
<html>
<head>
<title>Frames example</title>
</head>
   <frameset rows="10%,80%,10%">
      <frame src="/html/top_frame.htm" />
      <frame src="/html/main_frame.htm" />
      <frame src="/html/bottom_frame.htm" />
      <noframes>
      <body>
      Your browser does not support frames.
      </body>
      </noframes>
   </frameset>
</html>
Now create three HTML files called top_frame.htmmain_frame.htm and bottom_frame.htm to be loaded into three frames with some content.

The <frameset> Element Attributes:

Following are important attributes of <frameset> and should be known to you to use frameset.
  • cols: specifies how many columns are contained in the frameset and the size of each column. You can specify the width of each column in one of four ways:
    • Absolute values in pixels. For example to create three vertical frames, usecols="100, 500,100".
    • A percentage of the browser window. For example to create three vertical frames, use cols="10%, 80%,10%".
    • Using a wildcard symbol. For example to create three vertical frames, usecols="10%, *,10%". In this case wildcard takes remainder of the window.
    • As relative widths of the browser window. For example to create three vertical frames, use cols="3*,2*,1*". This is an alternative to percentages. You can use relative widths of the browser window. Here the window is divided into sixths: the first column takes up half of the window, the second takes one third, and the third takes one sixth.
  • rows: attribute works just like the cols attribute and can take the same values, but it is used to specify the rows in the frameset. For example to create two horizontal frames, use rows="10%, 90%". You can specify the height of each row in the same way as explained above for columns.
  • border: attribute specifies the width of the border of each frame in pixels. For example border="5". A value of zero specifies that no border should be there.
  • frameborder: specifies whether a three-dimensional border should be displayed between frames. This attrubute takes value either 1 (yes) or 0 (no). For example frameborder="0" specifies no border.
  • framespacing: specifies the amount of space between frames in a frameset. This can take any integer value. For example framespacing="10" means there should be 10 pixels spacing between each frames.

Loading Content - The <frame> Element:

The <frame> element indicates what goes in each frame of the frameset. The <frame> element is always an empty element, and therefore should not have any content, although each <frame> element should always carry one attribute, src, to indicate the page that should represent that frame.
From the above example, lets take small snippet:
   <frame src="/html/top_frame.htm" />
   <frame src="/html/main_frame.htm" />
   <frame src="/html/bottom_frame.htm" />

The <frame> Element Attributes:

Following are important attributes of and should be known to you to use frames.
  • src: indicates the file that should be used in the frame. Its value can be any URL. For example, src="/html/top_frame.htm" will load an HTML file avaible in html directory.
  • name: attribute allows you to give a name to a frame. It is used to indicate which frame a document should be loaded into. This is especially important when you want to create links in one frame that load pages into a second frame, in which case the second frame needs a name to identify itself as the target of the link.
  • frameborder: attribute specifies whether or not the borders of that frame are shown; it overrides the value given in the frameborder attribute on the <frameset> element if one is given, and the possible values are the same. This can take values either 1 (yes) or 0 (no).
  • marginwidth: allows you to specify the width of the space between the left and right of the frame's borders and the frame's content. The value is given in pixels. For example marginwidth="10".
  • marginheight: allows you to specify the height of the space between the top and bottom of the frame's borders and its contents. The value is given in pixels. For example marginheight="10".
  • noresize: By default you can resize any frame by clicking and dragging on the borders of a frame. The noresize attribute prevents a user from being able to resize the frame. For example noresize="noresize".
  • scrolling: controls the appearance of the scrollbars that appear on the frame. This takes values either "yes", "no" or "auto". For example scrolling="no" means it should not have scroll bars.
  • longdesc: allows you to provide a link to another page containing a long description of the contents of the frame. For example longdesc="framedescription.htm"

Browser Support - The <noframes> Element:

If a user is using any old browser or any browser which does not support frames then <noframes> element should be displayed to the user.
In XHTML you must place a <body> element inside the <noframes> element because the <frameset> element is supposed to replace the <body> element, but if a browser does not understand the <frameset> element it should understand what is inside the <body> element contained in the <noframes> element.
You can put some nice message for your user having old browsers. For example Sorry!! your browser does not support frames.

Frame's name and target attributes:

One of the most popular uses of frames is to place navigation bars in one frame and then load the pages with the content into a separate frame.
As you have already seen, each <frame> element can carry the name attribute to give each frame a name.This name is used in the links to indicate which frame the new page should load into. Consider this very simple example, create following content in index.htm file:
<frameset cols="200, *">
   <frame src="/html/menu.htm" name="menu_page" />
   <frame src="/html/main.htm" name="main_page" />
</frameset>
There are two columns in this example. The first is 200 pixels wide and will contain the navigation bar. The second column or frame will contain the main part of the page. The links on the left side navigation bar will load pages into the right side main page.
Keep some content in main.htm file and the links in the menu.htm file look like this:
<a href="http://www.google.com" target="main_page">Google</a>
<br /><br />
<a href="http://www.microsoft.com" target="main_page">Microsoft</a>
<br /><br />
<a href="http://news.bbc.co.uk/" target="main_page">BBC News</a>

The target attribute can also take the attribute values listed in the table that follows.
VlaueDescription
_selfLoads the page into the current frame.
_blankLoads a page into a new browser window.opening a new window.
_parentLoads the page into the parent window, which in the case of a single frameset is the main browser window.
_topLoads the page into the browser window, replacing any current frames..

Inline Frames - The <iframe> Element:

You can define an inline frame with the <iframe> tag. The <iframe> tag is not used within a <frameset> tag. Instead, it appears anywhere in your document. The <iframe> tag defines a rectangular region within the document in which the browser displays a separate document, including scrollbars and borders.
Use the src attribute with <iframe> to specify the URL of the document that occupies the inline frame.
All of the other, optional attributes for the <iframe> tag, including name, class, frameborder, id, longdesc, marginheight, marginwidth, name, scrolling, style, and title behave exactly like the corresponding attributes for the <frame> tag.
Following is the example to show how to use the <iframe>. This tag is used along with <body> tag:
<body>
...other document content...
<iframe src="/html/menu.htm" width="75" height="200" align="right">
Your browser does not support inline frames. To view this
<a href="/html/menu.htm">document</a> correctly, you'll need
a copy of Internet Explorer or the latest Netscape Navigator.
</iframe>
...subsequent document content...
</body>
The align attribute lets you control where the frame gets placed in line with the adjacent text or moved to the edge of the document, allowing text to flow around the frame.
For inline alignment, use top, middle, or bottom as the value of this attribute. The frame is aligned with the top, middle, or bottom of the adjacent text, respectively. To allow text to flow around the inline frame, use the left or right values for this attribute. The frame is moved to the left or right edge of the text flow, respectively, and the remaining content of the document is flowed around the frame. A value of center places the inline frame in the middle of the display, with text flowing above and below.

HTML Tables

Tables are very useful to arrange in HTML and they are used very frequently by almost all web developers. Tables are just like spreadsheets and they are made up of rows and columns.
You will create a table in HTML/XHTML by using <table> tag. Inside <table> element the table is written out row by row. A row is contained inside a <tr> tag . which stands for table row. And each cell is then written inside the row element using a <td> tag . which stands for table data.

Example:

<table border="1">
<tr>
<td>Row 1, Column 1</td>
<td>Row 1, Column 2</td>
</tr>
<tr>
<td>Row 2, Column 1</td>
<td>Row 2, Column 2</td>
</tr>
</table>
This will produce following result:
Row 1, Column 1Row 1, Column 2
Row 2, Column 1Row 2, Column 2
NOTE: In the above example border is an attribute of <table> and it will put border across all the cells. If you do not need a border then you cal use border="0". The border attribute and other attributes also mentione din this session are deprecated and they have been replaced by CSS. So it is recommended to use CSS instead of using any attribute directly.

Table Heading - The <th> Element:

Table heading can be defined using <th> element. This tag will be put to replace <td> tag which is used to represent actual data. Normally you will put your top row as table heading as shown below, otherwise you can use <th> element at any place:
<table border="1">
<tr>
<th>Name</th>
<th>Salary</th>
</tr>
<tr>
<td>Name 1</td>
<td>5000</td>
</tr>
<tr>
<td>Name 2</td>
<td>7000</td>
</tr>
</table>
This will produce following result. You can see its making heading as a bold one:
NameSalary
Name 1
5000
Name 2
7000

NOTE: Each cell must, however, have either a <td> or a <th> element in order for the table to display correctly even if that element is empty.

Table Cellpadding and Cellspacing:

There are two attribiutes called cellpadding and cellspacing which you will use to adjust the white space in your table cell. Cellspacing defines the width of the border, while cellpadding represents the distance between cell borders and the content within. Following is the example:
<table border="1" cellpadding="5" cellspacing="5">
<tr>
<th>Name</th>
<th>Salary</th>
</tr>
<tr>
<td>Name 1</td>
<td>5000</td>
</tr>
<tr>
<td>Name 2</td>
<td>7000</td>
</tr>
</table>
This will produce following result:
NameSalary
Name 1
5000
Name 2
7000

Colspan and Rowspan Attributes:

You will use colspan attribute if you want to merge two or more columns into a single column. Similar way you will use rowspan if you want to merge two or more rows. Following is the example:
<table border="1">
<tr>
<th>Column 1</th>
<th>Column 2</th>
<th>Column 3</th>
</tr>
<tr><td rowspan="2">Row 1 Cell 1</td>
<td>Row 1 Cell 2</td><td>Row 1 Cell 3</td></tr>
<tr><td>Row 2 Cell 2</td><td>Row 2 Cell 3</td></tr>
<tr><td colspan="3">Row 3 Cell 1</td></tr>
</table>
This will produce following result:
Column 1Column 2Column 3
Row 1 Cell 1Row 1 Cell 2Row 1 Cell 3
Row 2 Cell 2Row 2 Cell 3
Row 3 Cell 1

Tables Backgrounds

You can set table background using of the following two ways:
  • Using bgcolor attribute - You can set background color for whole table or just for one cell.
  • Using background attribute - You can set background image for whole table or just for one cell.
NOTE:You can set border color also using bordercolor attribute.
Here is an example of using bgcolor attribute:
<table border="5" bordercolor="green" bgcolor="gray">
<tr>
<th>Column 1</th>
<th>Column 2</th>
<th>Column 3</th>
</tr>
<tr><td rowspan="2">Row 1 Cell 1</td>
<td bgcolor="red">Row 1 Cell 2</td><td>Row 1 Cell 3</td></tr>
<tr><td>Row 2 Cell 2</td><td>Row 2 Cell 3</td></tr>
<tr><td colspan="3">Row 3 Cell 1</td></tr>
</table>
This will produce following result:
Column 1Column 2Column 3
Row 1 Cell 1Row 1 Cell 2Row 1 Cell 3
Row 2 Cell 2Row 2 Cell 3
Row 3 Cell 1
To Become more comfortable - Do Online Practice
Here is an example of using background attribute:
<table border="1" background="/images/home.gif">
<tr>
<th>Column 1</th>
<th>Column 2</th>
<th>Column 3</th>
</tr>
<tr><td rowspan="2">Row 1 Cell 1</td>
<td bgcolor="red">Row 1 Cell 2</td><td>Row 1 Cell 3</td></tr>
<tr><td>Row 2 Cell 2</td><td>Row 2 Cell 3</td></tr>
<tr><td colspan="3" background="/images/pattern1.gif">
Row 3 Cell 1
</td></tr>
</table>
This will produce following result:
Column 1Column 2Column 3
Row 1 Cell 1Row 1 Cell 2Row 1 Cell 3
Row 2 Cell 2Row 2 Cell 3
Row 3 Cell 1

Table height and width:

You can set a table width and height using width and height attrubutes. You can specify table width or height in terms of integer value or in terms of percentage of available screen area. Following is the example:
<table border="1" width="400" height="150">
<tr>
<td>Row 1, Column 1</td>
<td>Row 1, Column 2</td>
</tr>
<tr>
<td>Row 2, Column 1</td>
<td>Row 2, Column 2</td>
</tr>
</table>
This will produce following result:
Row 1, Column 1Row 1, Column 2
Row 2, Column 1Row 2, Column 2

Using Table Caption:

The caption tags will serve as a title or explanation and show up at the top of the table. This tag is depracated in newer version of HTML/XHTML.
<table border="1">
<caption>This is the caption</caption>
<tr>
<td>row 1, column 1</td><td>row 1, columnn 2</td>
</tr>
</table>
This will produce following result:
This is the caption
row 1, column 1row 1, columnn 2

Using a Header, Body, and Footer:

Tables can be divided into three portions: a header, a body, and a foot. The head and foot are rather similar to headers and footers in a word-processed document that remain the same for every page, while the body is the main content of the table.
The three elements for separating the head, body, and foot of a table are:
  • <thead> - to create a separate table header.
  • <tbody> - to indicate the main body of the table.
  • <tfoot> - to create a separate table footer.
A table may contain several <tbody> elements to indicate different pages or groups of data. But it is notable that <thead> and <tfoot> tags should appear before <tbody>
<table border="1" width="100%">
<thead>
<tr>
<td colspan="4">This is the head of the table</td>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="4">This is the foot of the table</td>
</tr>
</tfoot>
<tbody>
<tr>
<td>Cell 1</td>
<td>Cell 2</td>
<td>Cell 3</td>
<td>Cell 4</td>
</tr>
<tr>
...more rows here containing four cells...
</tr>
</tbody>
<tbody>
<tr>
<td>Cell 1</td>
<td>Cell 2</td>
<td>Cell 3</td>
<td>Cell 4</td>
</tr>
<tr>
...more rows here containing four cells...
</tr>
</tbody>
</table>
This will produce following result:
This is the head of the table
This is the foot of the table
Cell 1Cell 2Cell 3Cell 4
...more rows here containing four cells...
Cell 1Cell 2Cell 3Cell 4
...more rows here containing four cells...

Nested Tables:

You can use one table inside another table. Not only tables you can use almost all the tags inside table data tag <td>.
Following is the example of using another table and other tags inside a table cell.
<table border="1">
<tr>
<td>
 <table border="1">
 <tr>
 <th>Name</th>
 <th>Salary</th>
 </tr>
 <tr>
 <td>Name 1</td>
 <td>5000</td>
 </tr>
 <tr>
 <td>Name 2</td>
 <td>7000</td>
 </tr>
 </table>
</td>
<td> 
 <ul>
 <li>This is another cell</li>
 <li>Using list inside this cell</li>
 </ul>
</td>
</tr>
<tr>
<td>Row 2, Column 1</td>
<td>Row 2, Column 2</td>
</tr>
</table>
This will produce following result:
NameSalary
Name 1
5000
Name 2
7000
  • This is another cell
  • Using list inside this cell
Row 2, Column 1Row 2, Column 2

HTML Marquees

A HTML marquee is a scrolling piece of text displayed either horizontally across or vertically down your web site page depending on the settings. This is created by using HTML tag <marquees>.
NOTE: The HTML <marquee> is an MSIE extension, but is now supported by NS 7 also. So please check if your browser supports this tag or not.

Syntax:

A simple syntax to use marquee is as follows:
<marquee attribute_name="attribute_value"....more attributes>

One or more lines or text message or image

</marquee>

Attrubutes:

A HTML marquee can have following attributes:
  • width: how wide the marquee is. This will have a value like 10 or 20%etc.
  • height: how tall the marquee is. This will have a value like 10 or 20% etc.
  • direction: which direction the marquee should scroll. This will have value either up,downleft or right.
  • behavior: what type of scrolling. This will have value scrollslid and alternate.
  • scrolldelay: how long to delay between each jump. This will have a value like 10 etc.
  • scrollamount: how far to jump. This will have a value like 10 etc.
  • loop: how many times to loop. The default value is INFINITE, which means that the marquee loops endlessly.
  • bgcolor: background color. This will have any color name or color hex value.
  • hspace: horizontal space around the marquee. This will have a value like 10 or 20%etc.
  • vspace: vertical space around the marquee. This will have a value like 10 or 20%etc.

Examples:

Here are few examples to demonstrate the usage of marquee tag.

<marquee>This is basic example of marquee</marquee>
This will produce following result:
This is basic example of marquee

<marquee width="50%">This example will take only 50% width</marquee>
This will produce following result:
This example will take only 50% width

<marquee direction="right">This text will scroll from left to right</marquee>
This will produce following result:
This text will scroll from left to right

<marquee direction="up">This text will scroll from bottom to up</marquee>
This will produce following result:
This text will scroll from bottom to up

HTML Fonts

Font face and color depends entirely on the computer and browser that is being used to view your page. But the <font> tag is used to add style, size, and color to the text on your site. You can use a <basefont> tag to set all of your text to the same size, face, and color.
The font tag is having three attributes called size, color, and face to customize your fonts.
To change any of the font attributes at any time within your page, simply use the <font> tag. The text that follows will remain changed until you close with the </font> tag. You can change any or all of the font attributes at the one time, by including all the required changes within the one <font> tag.
NOTE: The font and basefont tags are deprecated and it is supposed to be removed in a future version of HTML. So it should not be used. Its is suggested to use css styles to manipulate your font.

Font Size:

You can set the size of your font with size attribute. The range of accepted values is from 1(smallest) to 7(largest). The default size of a font is 3.
Example:
<font size="1">Font size="1"</font>
<font size="2">Font size="2"</font>
<font size="3">Font size="3"</font>
<font size="4">Font size="4"</font>
<font size="5">Font size="5"</font>
<font size="6">Font size="6"</font>
<font size="7">Font size="7"</font>
This will produce following result:
Font size="1"
Font size="2"
Font size="3"
Font size="4"
Font size="5"
Font size="6"
Font size="7"
SPECIFY THE RELATIVE FONT SIZE. <font size="+n"> or <font size="-n">:
You can specify how many sizes larger or how many sizes smaller than the preset font size should be.
Example:
<font size="-1">Font size="-1"</font>
<font size="+1">Font size="+1"</font>
<font size="+2">Font size="+2"</font>
<font size="+3">Font size="+3"</font>
<font size="+4">Font size="+4"</font>
This will produce following result:
Font size="-1"
Font size="+1"
Font size="+2"
Font size="+3"
Font size="+4"

Font Face:

You can set any font you like using face attribute but be aware that if the user viewing the page doesn't have the font installed, they will not be able to see it. Instead they will default to Times New Roman of your font with size attribute. See below few examples on using different font face
Example:
<font face="Times New Roman" size="5">Times New Roman</font>
<font face="Verdana" size="5">Verdana</font>
<font face="Comic sans MS" size="5">Comic Sans MS</font>
<font face="WildWest" size="5">WildWest</font>
<font face="Bedrock" size="5">Bedrock</font>
This will produce following result:
Times New Roman
Verdana
Comic Sans MS
WildWest
Bedrock

Specify alternate font faces:

A visitor will only be able to see your font if they have that font installed on their computer. So, it is possible to specify two or more font face alternatives by listing the font face names, separated by a comma.
Example:
<font face="arial,helvetica">
<font face="Lucida Calligraphy,Comic Sans MS,Lucida Console>
When your page is loaded, their browser will display the first font face that it has available. If none of your selections are installed....then it will display the default font face Times New Roman.

Font Color:

You can set any font color you like using color attribute. You can specify the color that you want by either the color name or hexadecimal code for that color.
Example:
<font color="#FF00FF">This text is hexcolor #FF00FF</font>
<font color="red">This text is red</font>
This will produce following result:
This text is hexcolor #FF00FF
This text is red

The <basefont> Element:

The <basefont> element is supposed to set a default font size, color, and typeface for any parts of the document that are not otherwise contained within a <font> element. You can then use the <font> elements to override the <basefont> settings.
The attributes that the <basefont> element takes are exactly the same as for the <font> element. You can also set the size of fonts relative to the size of the <basefont> by giving them a value of +1 for a size larger or -2 for two sizes smaller
NOTE: This element is deprecated in HTML 4 and will be removed from HTML, the preferred option is to use CSS styles. Your browser may not have support for this tag.

Example:

<basefont face="arial, verdana, sans-serif" size="2" color="#ff0000">
<p>This is the page's default font.</p>
<h2>Example of the &lt;basefont&gt; Element</h2>
<p><font size="+2" color="darkgray">Here is some darkgray text
two sizes larger</font></p>
<p><font face="courier" size="-1" color="#000000">Here is a courier
font, a size smaller, in black</font></p>
This will produce following result:

This is the page's default font.

Example of the <basefont> Element

Here is some darkgray text
two sizes larger
Here is a courier
font, a size smaller, in black
As you can see, the default font now takes on the properties specified in the <basefont> element. It is red, size 2, and uses the Arial typeface.
The paragraph after the <h2> element uses a font size two sizes larger than the default size and is gray text, whereas the following paragraph uses a font one size smaller than the default font. You can also see that the color of this font is black (overriding the default).

HTML Comments

Comments are piece of code which is ignored by any web browser. It is good practice to comment your code, especially in complex documents, to indicate sections of a document, and any other notes to anyone looking at the code. Comments help you and others understand your code.
HTML Comment lines are indicated by the special beginning tag <!-- and ending tag --> placed at the beginning and end of EVERY line to be treated as a comment.
Comments do not nest, and the double-dash sequence "--" may not appear inside a comment except as part of the closing --> tag. You must also make sure that there are no spaces in the start-of-comment string.
For example: Given line is a valid comment in HTML
<!--   This is commented out -->
But following line is not a valid comment and will be displayed by the borwser. This is because there is a space between the left angle bracket and the exclamation mark.
< !--   This is commented out -->
Be careful if you use comments to "comment out" HTML that would otherwise be shown to the user, since some older browsers will still pay attention to angle brackets inside the comment and close the comment prematurely -- so that some of the text that was supposed to be inside the comment mistakenly appears as part of the document.

Multiline Comments:

You have seen how to comment a single line in HTML. You can comment multiple lines by the special beginning tag <!-- and ending tag --> placed before the first line and end of the lastline to be treated as a comment.
For example:
<!--   
This is a multiline comment <br />
and can span through as many as lines you like.
-->

Conditional Comments :

Conditional comments only work in Explorer on Windows, and are thus excellently suited to give special instructions meant only for Explorer on Windows. They are supported from Explorer 5 onwards, and it is even possible to distinguish between 5.0, 5.5 and 6.0.
Conditional comments work as follows:
<!--[if IE 6]>
Special instructions for IE 6 here
<![endif]-->
  • Their basic structure is the same as an HTML comment (<!-- -->). Therefore all other browsers will see them as normal comments and will ignore them entirely.
  • Explorer Windows, though, has been programmed to recognize the special <!--[if IE]> syntax, resolves the if and parses the content of the conditional comment as if it were normal page content.
  • Since conditional comments use the HTML comment structure, they can only be included in HTML files, and not in CSS files.

Using Comment tag

There are few browsers who supports <comment> tag to comment a part of code.
<p>This is <comment>not</comment> Internet Explorer.</p>

Commenting Scripts and Style Sheets:

If you are using Java Script or VB Script in your HTML code then it is recommended to put that script code inside proper HTML Comments to make old browser works properly.
For example:
<script>
<!-- 
document.write("Hello World!")
//-->
</script>
Similarly if you are using Casecading Style Sheet in your HTML code then it is recommended to put that style sheet code inside proper HTML Comments to make old browser works properly.
For example:
<style>
<!-- 
img{
  border:0px;
}
//-->
</style>
NOTE: To become familiar with JAVA Script and Cascading Style Sheet you need to refer different tutorial.

HTML Phrase Tags

While some of these phrase elements are displayed in a similar manner to the <b>, <i>, <pre>, and <tt> elements you have already seen, they are designed for specific purposes. For example, the <em> and <strong> elements give text emphasis and strong emphasis respectively and there are several elements for marking up quotes.
We will see all phrase tags in this section with examples.

Emphasized Text - The <em> Element:

The content of an <em> element is intended to be a point of emphasis in your document, and it is usually displayed in italicized text. The kind of emphasis intended is on words such as "must" in the following sentence:
<p>You <em>must</em> remember to close elements in XHTML.</p>
This will produce following result:
You must remember to close elements in XHTML.

Strong Text - The <strong> Element:

The <strong> element is intended to show strong emphasis for its content; stronger emphasis than the <em> element. As with the <em> element, the <strong> element should be used only when you want to add strong emphasis to part of a document.
<p>You <strong>must</strong> remember to close elements in XHTML.</p>
This will produce following result:
You must remember to close elements in XHTML.

Text Abbreviation - The <abbr> Element :

You can indicate when you are using an abbreviated form by placing the abbreviation between opening <abbr> and closing </abbr> tags.
<p>I have a friend called <abbr title="Abhishek">Abhy</abbr>.</p>
This will produce following result:
I have a friend called Abhy.

Using Acronym - The <acronym> Element :

The <acronym> element allows you to indicate that the text between an opening <acronym> and closing </acronym> element is an acronym.
When possible use a title attribute whose value is the full version of the acronyms on the <acronym> element, and if the acronym is in a different language, include an xml:lang attribute in XHTML documents.
<p>This chapter covers marking up text in <acronym title="Extensible Hypertext Markup Language">XHTML</acronym>.</p>
This will produce following result:
This chapter covers marking up text in XHTML.
At present, the major browsers do not change the appearance of the content of the <acronym> element.

Special Terms - The <dfn> Element :

The <dfn> element allows you to specify that you are introducing a special term. Its use is similar to the words that are in italics in the midst of paragraphs in this book when new key concepts are introduced.
Typically, you would use the <dfn> element the first time you introduce a key term and only in that instance. Most recent browsers render the content of a <dfn> element in an italic font.
<p>This tutorial teaches you how mark up your documents for the web using <dfn>XHTML</dfn>.</p>
This will produce following result:
This tutorial teaches you how mark up your documents for the web using XHTML.

Quoting Text - The <blockquote> Element :

When you want to quote a passage from another source, you should use the <blockquote> element.
Text inside a <blockquote> element is usually indented from the left and right edges of the surrounding text, and sometimes uses an italicized font.
<p>The following description of XHTML is taken from the W3C Web site:</p>

<blockquote> XHTML 1.0 is the W3C's first Recommendation for XHTML, following on from earlier work on HTML 4.01, HTML 4.0, HTML 3.2 and HTML 2.0. </blockquote>
This will produce following result:
The following description of XHTML is taken from the W3C Web site:
XHTML 1.0 is the W3C's first Recommendation for XHTML, following on from earlier work on HTML 4.01, HTML 4.0, HTML 3.2 and HTML 2.0.
You can use the cite attribute on the <blockquote> element to indicate the source of the quote.
<p>The following description of XHTML is taken from the W3C Web site:</p>

<blockquote cite="http://www.w3.org/markup/"> XHTML 1.0 is the W3C's first Recommendation for XHTML, following on from earlier work on HTML 4.01, HTML 4.0, HTML 3.2 and HTML 2.0. </blockquote>

Short Quotations - The <q> Element :

The <q> element is intended to be used when you want to add a quote within a sentence rather than as an indented block on its own.
<p>Amit is in Spain, <q>He is their at my home. I think I am wrong</q>.</p>
This will produce following result:
Amit is in Spain, He is their at my home. I think I am wrong.
The <q> element can also carry the cite attribute. The value should be a URL pointing to the source of the quote.

Citations - The <cite> Element :

If you are quoting a text, you can indicate the source placing it between an opening <cite> tag and closing </cite> tag
As you would expect in a print publication, the content of the <cite> element is rendered in italicized text by default.
<p>This HTML Tutorial is derived from <cite>World Wide Web Standard for HTML</cite>.</p>
This will produce following result:
This HTML Tutorial is derived from World Wide Web Standard for HTML.

Computer Code - The <code> Element :

Any code to appear on a Web page should be placed inside a <code> element. Usually the content of the <code> element is presented in a monospaced font, just like the code in most programming books.
<h1> <code>This is inside code element</code></h1>
This will produce following result:

This is inside code element


Keyboard Text - The <kbd> Element :

When you are talking about computers, if you want to tell a reader to enter some text, you can use the <kbd> element to indicate what should be typed in, as in this example.
The content of a <kbd> element is usually represented in a monospaced font rather like the content of the <code> element.
<h1> <kbd>This is inside kbd element</kbd></h1>
This will produce following result:

This is inside kbd element


Programming Variables - The <var> Element :

This element is usually used in conjunction with the <pre> and <code> elements to indicate that the content of that element is a variable that can be supplied by a user.
<p><code>document.write("<var>user-name</var>")</code></p>
This will produce following result:
document.write("user-name")

Program Output - The <samp> Element :

The <samp> element indicates sample output from a program, script, or the like. Again, it is mainly used when documenting programming concepts. For example:
<p>Result produced by the program is <samp>Hello World</samp></p>
This will produce following result:
Result produced by the program is Hello World

Addresses - The <address> Element :

The <address> element is used to contain any address. For example:
<address>304, Menna Colony, Hyderabad - INDIA, 500032</address>
This will produce following result:
304, Menna Colony, Hyderabad - INDIA, 500032


Block and Inline Elements:

We can categories all the elements into two sections:
  • Block-level elements - Block-level elements appear on the screen as if they have a carriage return or line break before and after them. For example the <p>, <h1>, <h2>, <h3>, <h4>, <h5>, <h6>, <ul>, <ol>, <dl>, <pre>, <hr />, <blockquote>, and <address> elements are all block level elements. They all start on their own new line, and anything that follows them appears on its own new line.
  • Inline elements - Inline elements, on the other hand, can appear within sentences and do not have to appear on a new line of their own. The <b>, <i>, <u>, <em>, <strong>, <sup>, <sub>, <big>, <small>, <li>, <ins>, <del>, <code>, <cite>, <dfn>, <kbd>, and <var> elements are all inline elements.
The elements which we have not discussed till now, will be discussed in subsequent chapters.