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 4 of 4
  1. #1
    New Coder
    Join Date
    Mar 2005
    Posts
    62
    Thanks
    0
    Thanked 0 Times in 0 Posts

    list inside tables cells

    im trying to get my list formatting inside different table cells. table looks similar to what is posted below. i would like to try and use only one <ul> to format all the <li>'s is this possible? because using a UL inside each cell is ugly and it doesnt work well between different browsers.

    <table>
    <tr>
    <td><li>info</li></td>
    <td><li>info</li></td>
    </tr>

    <tr>
    <td><li>info</li></td>
    <td><li>info</li></td>
    </tr>
    </table>

    thanks!

  • #2
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    No, that's invalid html and will mess up even more browsers.
    Your CSS is at fault here, not the UL tag.

    EX:
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>Untitled Document</title>
    <style type="text/css">
    ul {
    padding: 0;
    margin: 0;
    list-style:square; 
    }
    li {
    margin-left: 15px;
    }
    </style>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    
    <body>
    <h1>test</h1>
    <table border="1">
    <tr>
    <td><ul><li>info</li></ul></td>
    <td><ul><li>info</li></ul></td>
    </tr>
    
    <tr>
    <td><ul><li>info</li></ul></td>
    <td><ul><li>info</li></ul></td>
    </tr>
    </table></body>
    </html>

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Location
    Victoria, BC, Canada
    Posts
    962
    Thanks
    0
    Thanked 1 Time in 1 Post
    According to the HTML standard, it's best to keep list items (li) directly inside a list (ul)...The only elements a list can legally contain are list items, which you have already. So each table cell that contains a list must contain the ul element.

    With that done, you say using list elements (ul) inside a tahble cell looks ugly...how's that? Is it because of the extra spacing added? If so, that (and other appearance aspects of the lists) can be controlled using stylesheets.

    EDIT: Yaaaaah! nikkiH beat me to it!

  • #4
    New Coder
    Join Date
    Mar 2005
    Posts
    62
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Grant Palin
    According to the HTML standard, it's best to keep list items (li) directly inside a list (ul)...The only elements a list can legally contain are list items, which you have already. So each table cell that contains a list must contain the ul element.

    With that done, you say using list elements (ul) inside a tahble cell looks ugly...how's that? Is it because of the extra spacing added? If so, that (and other appearance aspects of the lists) can be controlled using stylesheets.

    EDIT: Yaaaaah! nikkiH beat me to it!

    yeah, thats what i figured about the <ul> <li> relation, i just dont like the idea of having a UL in every cell, which what i meant by looks messy inside the code. im kinda picky about that even thought most of the sites my company works on end up being a little scrambled

    anyway, i decided to skip the table entirely, and just add the data to the body text. less headache, and it saved the space we wanted.

    thanks for the help all.


  •  

    Posting Permissions

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