|
|
Creating rounded corners with HTML tables - Part 1Creating rounded corners involves a working knowledge of HTML tables and for that you can refer to the in-depth HTML table tutorial. If you are already familiar with the various tags associated with HTML tables and their attributes, you can go ahead and dig right into this tip else, I would recommend that you first read the HTML table tutorial in the Advanced HTML Tutorial. That said, creating rounded corners in no rocket science. We simply employ HTML tables to create the layout accomplish our task - which is to produce something like the table with rounded corners below.
Remember, all elements on a web page are rectangular and this includes images! This should come as no surprise because the screen on our monitors is rectangular and so is the browser window and the active space in the browser (the space that displays the web page). Take a look at the image below. Though it might look circular it's actually a rectangle (a square to be precise) - read more about why images are rectangles.
The background color of the image above is the same as that of this web page (white - hexadecimal code #FFFFFF) and because of this it seems that the image is only the green colored circle. However, this is not true. The green circle us surrounded by white color which is actually our image background color. If we place the image is a table with a blue background, we can then see the area occupied by the image.
Now you see the white space that surrounds the green circle - don't you? The first step is to understand that a table with rounded corners is created by a table with 3 columns and 3 rows; thus, a total of 9 table cells - like the table below:
Cells 1, 3, 7 and 9 will contain the four quarters of a circle, cells 2, 4, 6 and 8 will form the top, left, right and bottom edges and Cell number 5 will have the actual contents. The four quarters of a circle that we plan to use are four different images. And to create these images you need the assistance of your favorite graphics editing tool. Any graphics tool will let you create a circle. Once you have done so, you need to split it into 4 squares and these will be the four quarters. For example, in Paint Shop Pro or Adobe Photoshop, start by creating a new image of 28x28 pixels. Draw a circle right in the middle of the image. IMPORTANT note: be sure that you have the anti-aliasing option selected before you draw the circle. Then with the selection tool extract 14x14 pixels from the top left. You can repeat this for other quarters or simply flip and mirror the first quarter that you've created. you need to save all the four images with different file names. So starting with an image of a circle, we can get 4 quarters as below:
We will now place the four images in 3x3 table inside the corresponding cells as detailed above, remove the borders, padding to give us our rounded rectangle. <TABLE WIDTH="200" CELLPADDING="0" CELLSPACING="0" BORDER="0" STYLE="background-color: #9C084A"> <TR> <TD WIDTH="14"><IMG SRC="rounded_corner1.gif" WIDTH="14" HEIGHT="14" BORDER="0" ALT="..."></TD> <TD WIDTH="172"></TD> <TD WIDTH="14"><IMG SRC="rounded_corner2.gif" WIDTH="14" HEIGHT="14" BORDER="0" ALT="..."></TD> </TR> <TR> <TD></TD> <TD ALIGN="CENTER">ACTUAL CONTENT</TD> <TD></TD> </TR> <TR> <TD><IMG SRC="rounded_corner3.gif" WIDTH="14" HEIGHT="14" BORDER="0" ALT="..."></TD> <TD></TD> <TD><IMG SRC="rounded_corner4.gif" WIDTH="14" HEIGHT="14" BORDER="0" ALT="..."></TD> </TR> </TABLE> Pay close attention to the code marked in blue. Changing the height and width of the table with rounded cornersAs I mentioned above, the width of the table with rounded corners can be anything you want. However, the beauty of this table code is that you dont have to do anything about its height. The height of this table is controlled by the actual contents... the contents placed in cell #5. So depending on the amount of content we place in this cell, the height of the table will increase on its own. Take a look below:
This was the first part of the creating a table with rounded corners. Now let us see how we can create more advanced and complex corners of such tables. This is discussed in the next part - Complex and more advanced rounded corners for HTML tables. | 1 |
2
Page contents: Details on creating rounded corners for HTML tables - HTML tables tutorial.
Page URL: http://www.webdevelopersnotes.com/tips/html/ html_table_tutorial_rounded_corners.php3
|
|