Learn HTML step-by-step from A to Z or improve your professional skills.  Home HTML and CSS Tutorials Creating HTML Borders of Any Type (Exclusive Tutorial)
Your Ad Here

Creating HTML Borders of Any Type (Exclusive Tutorial)


There are many ways to create attractive borders.

The simplest way is to use the parameter border <table> tag.

Example:

<table border=1>

Significantly widening our possibilities, we will use CSS – in which, for example, you can change some features of the borders, including the thickness, type, and color of the borders.

Example:

<table style="border:10px solid #ff0000">

However, what should we do in the event that these means are not enough, and we wish to create real unrepeatable borders or to completely build a fragment of a site in the existent style?

In this tutorial, you will learn how to create borders in any way you wish. The code which shall be the result of this tutorial is universal, and can be used in all but a few circumstances. If you are absolutely unfamiliar with HTML, then I suggest that you read this tutorial as a starter, although you will not understand everything.?

1. Take the picture with the border you want to convert to HTML.

image 1

Divide the existent frame into eight parts - 4 corners and 4 bodies of content - and save the pictures with their respective names, including their positions (as in the diagram). If we are working with repeating frames (as in our case) then for the body of the frame it is necessary to save at least the part which can be duplicated and used as the initial frame.

image 2

2. Create a table having the size of 3*3 cells. Here is the code:

<table>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
</table>

All cells other than the central one are needed in the creation of the frame itself.

3. Now you should define the table size. To do this write the following in the <table> tag height="100%" width="100%" cellSpacing=0 cellPadding=0 border=0.
Height="100%" width="100%" – in order to ensure that the frame and its content occupy the same space.

Cellspacing=0 cellPadding=0 border=0 – in order to remove standard borders and margins in our table – we will work with them later.

Now define the width of the middle (horysontal) cells - with="3px" to the left and right, width="100%" to the central one.

4. Now lay out the margins of cells with transparent pictures in order to prevent the frame from becoming narrower or wider in any case. To do this, create a transparent picture having the size of 1px*1px and name it spacer.gif (or take it here). Now rewise what size did you take the corner border pictures and give the same size to spacer (3px*3px in our case). Now between all tags <td> and </td> insert spacer.gif. Here is the code:
<img src="/img_articles/3162/spacer.gif" width="3px" height="3px">

Here is the code that you should see.

<table height="100%" width="100%" cellspacing=0 cellpadding=0 border=0>
<tbody>
<tr>
<td><img src="/img_articles/3162/spacer.gif" width="3px" height="3px"></td>
<td><img src="/img_articles/3162/spacer.gif" width="3px" height="3px"></td>
<td><img src="/img_articles/3162/spacer.gif" width="3px" height="3px"></td>
</tr>
<tr>
<td width="3px"><img src="/img_articles/3162/spacer.gif" width="3px" height="3px"></td>
<td width="100%"><p>here we go!</p></td>
<td width="3px"><img src="/img_articles/3162/spacer.gif" width="3px" height="3px"></td>
</tr>
<tr>
<td><img src="/img_articles/3162/spacer.gif" width="3px" height="3px"></td>
<td><img src="/img_articles/3162/spacer.gif" width="3px" height="3px"></td>
<td><img src="/img_articles/3162/spacer.gif" width="3px" height="3px"></td>
</tr>
</tbody>
</table>

4. Now insert the pictures in the corresponding celsl in the table. In order to insert the picture in the cell you need to use the parameter background=“” in the <td> tag.

This is what you should see:

<table height="100%" width="100%" cellspacing=0 cellpadding=0 border=0>
<tbody>
<tr>
<td background="top-right.gif><img src="/img_articles/3162/spacer.gif" width="3px" height="3px"></td>
<td background="top-center.gif"><img src="/img_articles/3162/spacer.gif" width="3px" height="3px"></td>
<td background="top-right.gif"><img src="/img_articles/3162/spacer.gif" width="3px" height="3px"></td>
</tr>
<tr>
<td width="3px" background="middle-left.gif"><img src="/img_articles/3162/spacer.gif" width="3px" height="3px"></td>
<td width="100%"><p>here we go!</p></td>
<td width="3px" background="middle-right.gif"><img src="/img_articles/3162/spacer.gif" width="3px" height="3px"></td>
</tr>
<tr>
<td background="bottom-left.gif"><img src="/img_articles/3162/spacer.gif" width="3px" height="3px"></td>
<td background="bottom-center.gif"><img src="/img_articles/3162/spacer.gif" width="3px" height="3px"></td>
<td background="bottom-right.gif"><img src="/img_articles/3162/spacer.gif" width="3px" height="3px"></td>
</tr>
</tbody>
</table>

5. As for the central cells, you can adjust the margins inside the box using style="padding:10px 10px 10px 10px" (top, right, bottom, left), and likewise you can fill in the background, or apply color (bgcolor-“”). It is now possible to begin working with the content in the center of the box. You can insert any text, pictures, or whatever you wish into the central cells.

See the result(it is pased in the table with the default size):

The content comes here!

Well, that’s all there is to it. Now you can use already existent code for the creation of new borders. Simply insert the code, save new images, and a new outline is ready!



About the Author:

Click to Visit Author's Website

Dustin Kein is an editor at Web Design Library. He's in charge of selecting materials for the PhotoShop and HTML sections of this site. From time to time Dustin contributes some of his tutorials to WDL in order to cover the most actual topics for WDL visitors. Besides this, he's an active forum member whose posts are always helpful, concise and timely.
read more about this author

Author's URL: Reiven
Thank you for voting.
Rate this Materials:
Bad 
1 2 3 4 5 Excellent
print this page subscribe to newsletter subscribe to rss

HTML is Hyper Text Markup Language that is used to make hypermedia and hypertext documents for the Web. More HTML and CSS: Most Popular Materials | Fresh Materials | More HTML Tutorials at Markuptutorials.com

Add comments to "Creating HTML Borders of Any Type (Exclusive Tutorial)"

Only registered users can write comment

No comments yet...