471,066 Members | 935 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,066 software developers and data experts.

Positioning table elements with CSS <div> tags

Hi,

I'm trying to position a <tr> ("row") element with CSS.
The table itself is positioned with <div> tags. The problem is when I
use <div> tags to position the rows within the table nothing happens.

In the following example, I want to position two table rows relative
to the table itself.

Can anyone tell me what I am doing wrong? Please provide sample code.

Thanks

Here is the code:

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<style type="text/css">
<!--
..questionText {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
font-weight: bold;
}
-->
</style>
<style type="text/css">
<!--
..instructionText {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 9px;
font-weight: bold;
}
-->
</style>
<style type="text/css">
<!--
..tableDefault {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
color: #000033;
border: 1px solid;
}
-->
</style>
</head>

<body>

<div style="position: absolute; left: 74px; top: 58px; width: 492px;
height: 71px;">
<table width="469" cellpadding="0" cellspacing="1"
class="tableDefault">
<div style="position: relative; left: 100px;">
<tr class="questionText">
<td height="16" colspan="10" valign="top">How satisfied are
you with
the following: </td>
<td width="26"></td>
</tr>
</div>
<div style="position: relative; left: 50px;">
<tr class="instructionText">
<td height="16" colspan="10" valign="top">(fill out
completey)</td>
</tr>
</div>
</table>
</div>

</body>
</html>
Jul 20 '05 #1
7 16854
*Herbman* <hr******@yahoo.com>:

The table itself is positioned with <div> tags.
How do you do that? Usually one would use CSS for that. ;)
when I use <div> tags to position the rows within the table nothing happens.
'Div' isn't allowed inside 'table' nor 'tbody', but 'tr' is. OTOH you can
position /any/ box with CSS, e.g. one generated by an 'tr' element. Your
HTML resp. CSS teachers / books / tutorials should have told you that.
In the following example, I want to position two table rows relative
to the table itself.
Don't margin or padding work better?
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px; font-weight: bold;
font: bold 1em sans-serif;
<style type="text/css">
Why do you use a style element for each ruleset? The 'media' attribute is
useful, but not required.
<div style="position: absolute; left: 74px; top: 58px; width: 492px; height: 71px;">
Better use an ID instead of the 'style' attribute; and on the 'table', not
an extra 'div'.
<table width="469" cellpadding="0" cellspacing="1" class="tableDefault">


Mixing presentational HTML attributes with CSS is hazardous.
These here translate to

table.tableDefault {width: 449px; border-spacing: 1px}
table.tableDefault td {padding: 0}.

--
Useless Fact #5:
'Dreamt' is the only English word that ends in the letters 'mt'.
'I am.' is the shortest complete sentence in the English language.
The longest one-syllable word in the English language is 'screeched.'
Jul 20 '05 #2

"Christoph Paeper" <cr***********@gmx.net> wrote in message
news:bo**********@ariadne.rz.tu-clausthal.de...
*Herbman* <hr******@yahoo.com>:

The table itself is positioned with <div> tags.
How do you do that? Usually one would use CSS for that. ;)
when I use <div> tags to position the rows within the table nothing

happens.
'Div' isn't allowed inside 'table' nor 'tbody',is 'screeched.'


What is wrong with tbody being in a table? Are you sure about that?
If your correct then I'd better not be using thead and tfoot as well!
Can you clarify please
David
Jul 20 '05 #3
"David Graham" <da************@ntlworld.com> wrote in message
news:Rr**************@newsfep1-gui.server.ntli.net...

"Christoph Paeper" <cr***********@gmx.net> wrote in message
news:bo**********@ariadne.rz.tu-clausthal.de...
*Herbman* <hr******@yahoo.com>: 'Div' isn't allowed inside 'table' nor 'tbody',....


What is wrong with tbody being in a table?


I read that as..
'Div' isn't allowed inside 'table' and
'div' isn't allowed inside 'tbody'..

--
Andrew Thompson
http://www.AThompson.info/
http://www.PhySci.org/
http://www.1point1C.org/
Jul 20 '05 #4
In article David Graham wrote:
'Div' isn't allowed inside ('table' nor 'tbody'),is 'screeched.'

Added parenthesis to group words. Notice that there is no "is" between
"nor" and tbody.
What is wrong with tbody being in a table? Are you sure about that?
Can you clarify please
David

--
Lauri Raittila <http://www.iki.fi/lr> <http://www.iki.fi/zwak/fonts>
Saapi lähettää meiliä, jos aihe ei liity ryhmään, tai on yksityinen
tjsp., mutta älä lähetä samaa viestiä meilitse ja ryhmään.

Jul 20 '05 #5
On Sun, 2 Nov 2003, Andrew Thompson wrote:
"David Graham" <da************@ntlworld.com> wrote in message

"Christoph Paeper" <cr***********@gmx.net> wrote in message

*Herbman* <hr******@yahoo.com>: [nothing that you quoted]
'Div' isn't allowed inside 'table' nor 'tbody',....


What is wrong with tbody being in a table?


I read that as..
'Div' isn't allowed inside 'table' and
'div' isn't allowed inside 'tbody'..


Indeed. More accurately, it "isn't allowed as the immediate
descendent of ...". Wrapped in a table cell, which in turn is wrapped
in a table row, div would be fine.

Jul 20 '05 #6
In article <Pi*******************************@ppepc56.ph.gla. ac.uk>,
"Alan J. Flavell" <fl*****@ph.gla.ac.uk> wrote:
On Sun, 2 Nov 2003, Andrew Thompson wrote:
"David Graham" <da************@ntlworld.com> wrote in message

"Christoph Paeper" <cr***********@gmx.net> wrote in message

> *Herbman* <hr******@yahoo.com>: [nothing that you quoted]
'Div' isn't allowed inside 'table' nor 'tbody',....

What is wrong with tbody being in a table?


I read that as..
'Div' isn't allowed inside 'table' and
'div' isn't allowed inside 'tbody'..


Indeed. More accurately, it "isn't allowed as the immediate
descendent of ...". Wrapped in a table cell, which in turn is wrapped
in a table row, div would be fine.


"The DIV element in a table is only allowed inside a table cell (TD ot
TH).", that would sum it all up.

--
Kris
kr*******@xs4all.netherlands (nl)
Jul 20 '05 #7
*Andrew Thompson* <an******@bigNOSPAMpond.com>:
"David Graham" <da************@ntlworld.com> wrote in message
"Christoph Paeper" <cr***********@gmx.net> wrote in message

'Div' isn't allowed inside 'table' nor 'tbody',....


What is wrong with tbody being in a table?


I read that as..
'Div' isn't allowed inside 'table' and
'div' isn't allowed inside 'tbody'..


That's how the sentence was meant. The intention to add 'tbody' to the
statement was, that the element is implied in HTML4 (but not in XHTML), i.e.

<table><tr><td>foo</table>

is equal to

<table><tbody><tr><td>foo</td></tr></table>

-- therefore the selector "table>tr" will never match anything in an HTML4
document.

<table><div><tr><td>foo</td></tr></div></table>

could be either

<table><tbody><div><tr><td>foo</td></tr></div></tbody></table>

or

<table><div><tbody><tr><td>foo</td></tr></tbody></div></table>

if it was valid, which it is not.

--
My god lives -- sorry for yours!
Jul 20 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

61 posts views Thread by Toby Austin | last post: by
1 post views Thread by Steve Klett | last post: by
8 posts views Thread by localhost | last post: by
8 posts views Thread by Patrick | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.