PDA

View Full Version : What To Nest?



sunny
04-04-2005, 08:37 PM
I just want to know that which tag should be nested in another.
That is, whether it's better to nest <table> into <div>or <div> into<table>.

mwinter
04-05-2005, 12:25 AM
I just want to know that which tag should be nested in another.
That is, whether it's better to nest <table> into <div>or <div> into<table>.It's impossible to say without knowing the structure of your document: that is, after all, what your mark-up should reflect. However, only table cells (td) or headers (th) could contain a div. None of the other table-related elements (including table itself) can.

Mike

sunny
04-08-2005, 02:11 PM
SOrry,not to supply you with the correct question--
So here's a part of the code --


<LINK HREF="script.css" REL="STYLESHEET" TYPE="text/css">
<style>
.easy{background-color:black; color:magenta; font-size:13pt}
.difficult{background-color:black;color:red; font-size:13pt}
</style>
</head>
<body>
<table width="500" cellpadding=0 cellspacing=0 border=0>
<td>
<marquee class="mq" behavior="alternate">EASY ....... DIFFICULT</marquee></td><tr>
<td>
<div class="easy" align=left>
Easy is to get a place is someone's address book.</div></td><tr>
<td>
<div class="difficult" align=right>
Difficult is to get a place in someone's heart.</div></td><tr>
<td>
<div class="easy" align=left>
Easy is to judge the mistakes of others.</div></td><tr>
<td>
<div class="difficult" align=right>
Difficult is to recognize our own mistakes.</div></td><tr>
<td>
<div class="easy" align=left>
Easy is to talk without thinking.</div></td><tr>
<td>
<div class="difficult" align=right>
Difficult is to refrain the tongue.</div></td><tr>
<td>
<div class="easy" align=left>
Easy is to hurt someone who loves us.</div></td><tr>
<td>
<div class="difficult" align=right>
Difficult is to heal the wound...</div></td><tr>
<td>
<div class="easy" align=left>
Easy is to forgive others.</div></td><tr>
<td>
<div class="difficult" align=right>
Difficult is to ask for forgiveness</div></td><tr>
<td>
<div class="easy" align=left>
Easy is to set rules.</div></td><tr>
<td>
<div class="difficult" align=right>
Difficult is to follow them...</div></td><tr>
<td>
/*...
.......*/
</table>
For full code:
http://www.powow.com/wowarticles/easy.html
Again,
Is it Better to nest <td> in <div> Or <div> in <td

further,
I would like to know in which situations which tag should be nested in which tag?
My opinion is that huge data residing under <table> <td> should be nested into <div>tag.

mwinter
04-09-2005, 11:12 PM
SOrry,not to supply you with the correct questionIt doesn't change my answer: you cannot nest table cells within div elements.

By the way, you don't actually need a table at all for what you're doing. In fact, a table is inappropriate. It would be just as easy to align the text (using the text-align property) within a series of paragraphs:


<style type="text/css">
body, p {
background-color: black;
}
.easy, .difficult {
margin: 0;
padding: 0;
width: 40em;
}
.easy {
color: magenta;
text-align: left;
}
.difficult {
color: magenta;
text-align: left;
}
</style>

<p class="easy">Easy is to get a place is someone's address book.</p>
<p class="difficult">Difficult is to get a place in someone's heart.</p>
<p class="easy">Easy is to judge the mistakes of others.</p>
<p class="difficult">Difficult is to recognize our own mistakes.</p>And so forth. You might need to tweak that as I haven't looked at the result, but you get the idea. Finally, don't use points or pixels to specify font sizes: it makes text impossible to resize in IE, which is bad for users. Instead, use percentages which are based off of the user agent defaults. Ideally, body text will not be smaller than 100%.


I would like to know in which situations which tag should be nested in which tag?As I said before: when it's structurally sound to do so. HTML is a structural language that uses nesting to indicate relationships.

Each element has a purpose, and the most appropriate element should be used when marking-up content. A basic example is paragraphs of text being placed in individual p elements. A less used, but nevertheless correct, example is placing a series of links - such as those in a navigation section - in an unordered list.

If there are logical sections to a document, you should use a div element to indicate these groupings. For example, headers, navigation side bars, and so forth.


My opinion is that huge data residing under <table> <td> should be nested into <div>tag.Why? That doesn't seem to make any sense to me. Care to elaborate?

Mike