Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Oct 2007
    Posts
    86
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Tables and css Borders

    Hi all.

    Im designing a website the html trans way which is consisting of tables and divs.

    Im trying to set some css border attributes to a table but it is appling the attributes to all my tables. Iv tried naming the classes different etc but it still applies to all my tables. Any ideas on how i can use the borders for one table?

    Cheers

  • #2
    Regular Coder
    Join Date
    Jun 2004
    Posts
    495
    Thanks
    0
    Thanked 82 Times in 80 Posts
    Use id (or class)
    Code:
    <script type="text/javascript">
    </script>
    
    <style type="text/css">
    #tableborder {border:1px solid #9cf;}
     
    </style>
    
    </head>
    <body>
    <table id="tableborder" border="0" cellpadding="0" cellspacing="0" summary="">
    <tbody>
    <tr><td>Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat.</td></tr>
    </tbody>
    </table>
    <table border="0" cellpadding="0" cellspacing="0" summary="">
    <tbody>
    <tr><td>Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat.</td></tr>
    </tbody>
    </table>
    </body>
    Tables are for data not layout.

  • #3
    New Coder
    Join Date
    Oct 2007
    Posts
    86
    Thanks
    8
    Thanked 0 Times in 0 Posts
    Thanks but i have sorted it now

  • #4
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,928
    Thanks
    6
    Thanked 1,041 Times in 1,014 Posts
    Quote Originally Posted by Fang View Post
    Tables are for data not layout.
    But also: Part of semantic HTML is to name IDs and classes according to the function of the element, not the alleged look.

  • #5
    Regular Coder
    Join Date
    Jun 2004
    Posts
    495
    Thanks
    0
    Thanked 82 Times in 80 Posts
    Quote Originally Posted by VIPStephan View Post
    But also: Part of semantic HTML is to name IDs and classes according to the function of the element, not the alleged look.
    The example table has no function.

  • #6
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,928
    Thanks
    6
    Thanked 1,041 Times in 1,014 Posts
    However, you could still give better examples then by naming it, for example “table1” or something like this. “tableborder” assumes that the table with that ID has or is supposed to have a border which can change if the potential design is changed but the content stays the same (e. g. through a stylesheet switcher).

    The important thing is not whether or not your example has a function but rather to give examples that don’t tempt “students” to get off on the wrong foot.


  •  

    Posting Permissions

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