PDA

View Full Version : list inside tables cells



s.g.d
06-28-2005, 04:24 PM
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! :thumbsup:

nikkiH
06-28-2005, 04:49 PM
No, that's invalid html and will mess up even more browsers.
Your CSS is at fault here, not the UL tag.

EX:

<!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>

Grant Palin
06-28-2005, 04:50 PM
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!

s.g.d
06-28-2005, 07:37 PM
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 :rolleyes:

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.