473,396 Members | 1,966 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

how to create table based structure using div tag

254 100+
Hi

I want to create table based structure but without using table tag. I want to use div tag. How can I do that?
Apr 8 '08 #1
5 75463
harshmaul
490 Expert 256MB
Hi,
Firstly define what you mean by a table based structure.

If you want a table based structure (like a grid of data) then surely you would use a table.

If your talking about for layout, then you would use CSS.
Apr 8 '08 #2
mukeshrasm
254 100+
Hi,
Firstly define what you mean by a table based structure.

If you want a table based structure (like a grid of data) then surely you would use a table.

If your talking about for layout, then you would use CSS.
No I am talking about layout then how could I do it?
Apr 8 '08 #3
harshmaul
490 Expert 256MB
Heres a good article

http://www.devarticles.com/c/a/Web-S...yout-with-CSS/
Apr 8 '08 #4
sevry
3
Heres a good article
Yeah, getting the 5/box-3/col set with fixed heights is trivially easy. Try getting 'equal columns' if you don't fix the height, however. That's the challenge. It's been so for many years, and is well known. How to get a table /grid without any table tags, using only css?

What happens is that the columns only go down as far as the content pushes them, much like the old NN not responding to cell/column widths if there wasn't enough text in the cell. One can provide a common background and give the impression of full length and equal columns. But try to color one column, try to color the shortest column, and one instantly sees the problem with css, used that way.

But it's an old way with the arrival of FF 2 and Opera 9. Sure IE6 is out of luck, here. But IE6, good for its day, is subject to TOO MANY hack-arounds as it is.

In FF and Opera, you simply use the CSS2 table stylings. Now, admittedly, these are presently designed to work with HTML table tags. But that said - two will work just with any element. These are display: table-row and display: table-cell. You can even make up your own element name, or just use class.

First, the way one might have done it, before, and that works in IE6. It's limited. Even FF didn't seem to like the percentage column widths. So fixed widths are used for the columns. One floats left. The middle has left and right margins to keep it out of right and left columns. And the right column is positioned absolutely to the right border. Since the columns don't expand vertically, a common background is used for all three columns. Here the footer attaches to the middle column. It could be assumed that the middle will always be the tallest. But should either the left or right have more content and become taller, then the footer will still cling to the bottom of the middle column, and will overlap the longest column in an ugly way. It's a lot of compromises, assumptions. But in this way, it works.

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  2. <html>
  3. <head>
  4. <title>CSS 'equal columns'</title>
  5. <style>
  6.  
  7. .containdiv {
  8. width: 100%;
  9. display: block;
  10. border: 1px solid #000;
  11. background: #afa;
  12. }
  13.  
  14. .col {
  15. padding: 1em;
  16. }
  17.  
  18. .col1 {
  19. float: left;
  20. width: 200px;
  21. }
  22.  
  23. .col2 {
  24. display: block;
  25. top: 0;
  26. margin-left: 220px;
  27. margin-right: 230px;
  28. }
  29.  
  30. .col3 {
  31. width: 200px;
  32. position: absolute;
  33. right: 0;
  34. top: 0;
  35. }
  36.  
  37. .ftr SPAN, .hdr SPAN {
  38. display: block;
  39. padding: 0.5em;
  40. }
  41.  
  42. .hdr {
  43. border-left: 1px solid #000;
  44. border-top: 1px solid #000;
  45. background: #ffa;
  46. }
  47.  
  48. .ftr {
  49. border-left: 1px solid #000;
  50. border-bottom: 1px solid #000;
  51. border-top: none;
  52. clear: left;
  53. background: #ffa;
  54. }
  55.  
  56. </style>
  57. </head>
  58. <body>
  59. <div class="containdiv">
  60.  
  61. <div class="hdr">
  62. <span style="text-align:center;">Header</span>
  63. </div>
  64.  
  65. <div style="position:relative;width:100%;">
  66. <span class="col col1">some text</span>
  67.  
  68. <span class="col col2"> In the second Oration, delivered next day, he dwells on the Sacrament of Baptism and its spiritual effects; and takes occasion to reprove the then still prevalent practice of deferring Baptism till the near approach of death. He likewise dwells on the truth that the validity and spiritual effect of the Sacrament is wholly independent of the rank or worthiness of the Priest who may minister it
  69. </span>
  70.  
  71. <span class="col col3">some text</span>
  72. </div>
  73.  
  74. <div class="ftr">
  75. <span style="text-align:center;clear:both;">Footer</span>
  76. </div>
  77.  
  78. </div>
  79. </body>
  80. </html> 
  81.  
So that's for IE, FF and Opera. It should work in all three. However, if one wanted separate colors in each column, one would be out of luck in IE6. So here's the change, using table-cell from CSS2. All one does is substitute the following rules for the same rules above. Try it.

Expand|Select|Wrap|Line Numbers
  1. .containdiv {
  2. width: 100%;
  3. display: block;
  4. border: 1px solid #000;
  5. }
  6.  
  7. .col {
  8. padding: 1em;
  9. display: table-cell;
  10. }
  11.  
  12. .col1 {
  13. width: 10%;
  14. background: #dde;
  15. }
  16.  
  17. .col2 {
  18. background: #ede;
  19. }
  20.  
  21. .col3 {
  22. width: 10%;
  23. background: #edd;
  24. }
  25.  
Now, all of a sudden, it looks like a table. Full-floating. Percentage widths. Each cell full height. Each cell has its own color. And each cell is full top to bottom, touching header and footer. Again, won't work in IE6. But one would presume that this just above would be in the main external stylesheet. And those previously that worked in IE6 would be in whatever 'iefix' stylesheet that is separately loaded in. Everyone does that, these days. IE6 is the 'downscale' browser that requires some fix-up and touch-up. So one would just include the first col and container styles in the iefix stylesheet, and it would display with all the compromises, but the same HTML would display properly (after a fashion) in IE6.
Apr 8 '08 #5
harshmaul
490 Expert 256MB
Sevry just about got more detail that i would've given! Bookmarking for next time!
Apr 9 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: J West | last post by:
Warning: Error while executing this query:CREATE TABLE "purchaseorder" ( "PurchaseOrderID" int(10) unsigned NOT NULL auto_increment, "PurchaseCost" double unsigned zerofill NOT NULL default...
8
by: rong.guo | last post by:
Greetings! I am now doing one type of analysis every month, and wanted to creat table names in a more efficient way. Here is what happens now, everytime I do the analysis, I will create a...
6
by: Bruce | last post by:
I want to create a new table based on an existing table, but I don't want the tables to have any enforced relationship. Is this possible without having to do a CREATE TABLE and an INSERT? ...
2
by: Alicia | last post by:
Does anyone know why I am getting a "Syntax error in Create Table statement". I am using Microsoft Access SQL View to enter it. Any other problems I may run into? CREATE TABLE weeks (...
6
by: Peter Nurse | last post by:
For reasons that are not relevant (though I explain them below *), I want, for all my users whatever privelige level, an SP which creates and inserts into a temporary table and then another SP...
1
by: dave.j.thornton | last post by:
I'm attempting to create a new table, and populate it using the fields from two existing tables. The code is printed below. I get the error: "Run-time error '-2147217900 (80040e14)': Syntax error...
0
by: ramseyscripts | last post by:
I have Table A that is displayed through a form. Table A can be filtered through the form to create a subset of Table A records. How can I create a new table, Table B, with only the records in the...
0
by: remya1000 | last post by:
I have a field called Departments in my database. and I have 3 monitors. So when Page_Load, I need to check number of departments I have in database. And depends upon that number of departments I...
11
by: furqi | last post by:
hi every one my question is that i actually want to make a table in a database and update delete the recordsin that table The thing is that i dont want to make the database table in the sql...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.