SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Nov 2007
    Posts
    130
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    converting table to div with CSS only?

    Hi,

    I have a table which is displaying a form in. I cannot modify the table tags because of the way a script is written.

    Is there anyway, using CSS, that I can convert the table tags to divs or to act as divs?

    Thanks

  2. #2
    The CSS Clinic is open silver trophybronze trophy
    Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    40,514
    Mentioned
    182 Post(s)
    Tagged
    6 Thread(s)
    Quote Originally Posted by ebsolutions View Post
    Hi,

    I have a table which is displaying a form in. I cannot modify the table tags because of the way a script is written.

    Is there anyway, using CSS, that I can convert the table tags to divs or to act as divs?

    Thanks
    Hi,

    You can set the display of the table elements to be something else (such as block) (ie8+) but you will still be limited to the actual structure of the html.

    e.g.
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Untitled Document</title>
    <style type="text/css">
    .table, .table tr, .table td, .table th { display:block }
    </style>
    </head>
    
    <body>
    <table class="table">
    		<tr>
    				<th scope="col">Table header</th>
    				<th scope="col">Table header</th>
    		</tr>
    		<tr>
    				<td>Row 1 Data 1</td>
    				<td>Row 1 Data 2</td>
    		</tr>
    		<tr>
    				<td>Row 2 data 1</td>
    				<td>Row 2 data2</td>
    		</tr>
    </table>
    </body>
    </html>

  3. #3
    Mouse catcher silver trophy Stevie D's Avatar
    Join Date
    Mar 2006
    Location
    Yorkshire, UK
    Posts
    5,892
    Mentioned
    123 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by ebsolutions View Post
    Hi,

    I have a table which is displaying a form in. I cannot modify the table tags because of the way a script is written.

    Is there anyway, using CSS, that I can convert the table tags to divs or to act as divs?

    Thanks
    Are you doing this because you want to change the layout to something different (in which case what Paul said is spot on) or are you doing it because you've heard that "tables are bad". Because if it's that then you're wasting your time - tables (for non-tabular data) are bad because they misuse <table> tags. If you said you can't change the HTML, you're stuck with the <table> tags, and no amount of effort with the CSS will change that.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •