By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,445 Members | 1,160 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,445 IT Pros & Developers. It's quick & easy.

Can I position items inside a <td>?

P: n/a
Hello folks,

Is it possible to position an item within a <td> element? For
instance see below. The table has multiple rows, one for each
database record. Each row has 3 hrefs associated with it (for
edit, delete and update). I want to position these 3 href items
in the same columns, which would be posible if the span could be
positioned - for instance on the extreme right of the td in
which it is contained.

I can't use 2 or more <td> elements as the <td> is put there
using an ASP.NET repeater control - so unless there is an
equivalent of this control using <div> and <span> that is not
possible.

Somehow, I anticipate that the answer will be to use a different
ASP.NET control. Don't bother posting a reply if that is the
case.

++++++++++
<html>
<head><title>DataList Position</title>
<style type="text/css">
cControl {position:inherit; left:600px; text-align:right;
float:right}
</style>
</head>
<body>
<p>
<table>
<tr>
<td> -- Content --
<span class="cControl">
<a href="href A">E</a>
<a href="href B">D</a>
<a href="href C">U</a>
</span>
</td>
</tr>
<tr>
<td> -- Some other Content --
<span class="cControl">
<a href="href A">E</a>
<a href="href B">D</a>
<a href="href C">U</a>
</span>
</td>
</tr>
</table>
</body>
</html>

Jul 20 '05 #1
Share this Question
Share on Google+
14 Replies


P: n/a
From: 6.**********@spamgourmet.com
(Zenobia)
Hello folks,
Is it possible to position an item within a
<td> element?


<td align="right"> ...use center or left also...</td>

Web Design, Magic, Painting, Junking, More
http://www.davmagic.com
Paint A House
http://www.paintahouse.com
NOTE: This emailbox is CLOSED do NOT reply!!!

Jul 20 '05 #2

P: n/a
Zenobia <6.**********@spamgourmet.com> wrote:
Is it possible to position an item within a <td> element?
Yes. Set position: relative; for the <td> and then position: absolute;
and whichever of left, right, top and bottom you need for the child
element. However beware of bugs (IIRC Mozilla has a nasty one
concerning posititioning relative to table cells).
For
instance see below. The table has multiple rows, one for each
database record. Each row has 3 hrefs associated with it (for
edit, delete and update). I want to position these 3 href items
in the same columns, which would be posible if the span could be
positioned - for instance on the extreme right of the td in
which it is contained.
Sure.
td {position: relative;}
span {position: absolute; right: 0;}

But from the sound of it just adding text-align: right; or
align="right" for the td will work just as well in this case.
I can't use 2 or more <td> elements as the <td> is put there
using an ASP.NET repeater control
Sounds like ASP.NET is seriously broken if it won't let you insert
three coloumns instead of one. I don't believe that it is seriously
broken (well not that seriously broken) so I guess that the mistake is
either your choice of control or your implementation of it.
- so unless there is an
equivalent of this control using <div> and <span> that is not
possible.

Somehow, I anticipate that the answer will be to use a different
ASP.NET control. Don't bother posting a reply if that is the
case.
Tough. People will post what people want to post. And if people think
taht you're being an arse by using a defective ASP.NET control then
they'll tell you that.
cControl {position:inherit; left:600px; text-align:right;
float:right}
Well, in the absence of a URL we'll have to assume that this is your
entire stylesheet. In which case it's 75% useless. position: inherit;
in the absence of a parent element with position set is going to work
out as position: static; which means that left: 600px; will be
ignored. text-align doesn't apply to inline elements like spans, but
float right makes it a block element. However no width is specified so
many (but not all) browsers will shrink the element to fit round the
content so the text-align is once again useless.
<p>
What's the point of this empty paragraph? If you want to add space
above the table set margin-top.
<table>
<tr>
<td> -- Content --
<span class="cControl">
<a href="href A">E</a>
<a href="href B">D</a>
<a href="href C">U</a>
</span>
</td>


Well the span should be floated to the right from your CSS. Isn't that
what you wanted? If you wanted the span to be alongside your other
content then you should have place the span first.

Steve

--
"My theories appal you, my heresies outrage you,
I never answer letters and you don't like my tie." - The Doctor

Steve Pugh <st***@pugh.net> <http://steve.pugh.net/>
Jul 20 '05 #3

P: n/a
On Mon, 14 Jun 2004 13:07:24 -0400, Davmagic .Com <DL**@webtv.net> wrote:
From: 6.**********@spamgourmet.com
(Zenobia)
Hello folks,
Is it possible to position an item within a
<td> element?
<td align="right"> ...use center or left also...</td>


Except in up-to-date HTMl the align attribute is deprecated. Don't advise
this method, please.
Web Design, Magic, Painting, Junking, More
http://www.davmagic.com
Paint A House
http://www.paintahouse.com
NOTE: This emailbox is CLOSED do NOT reply!!!


Oh my.
Jul 20 '05 #4

P: n/a
"Neal" <ne*****@yahoo.com> wrote in message
news:op**************@news.individual.net...
On Mon, 14 Jun 2004 13:07:24 -0400, Davmagic .Com <DL**@webtv.net> wrote:
<td align="right"> ...use center or left also...</td>


Except in up-to-date HTMl the align attribute is deprecated. Don't advise
this method, please.


It may be deprecated, but it is still supported, and is essential for NN4
support.
Jul 20 '05 #5

P: n/a

From: ne*****@yahoo.com (Neal)
On Mon, 14 Jun 2004 13:07:24 -0400,
Davmagic .Com <DL**@webtv.net>
wrote: From: 6.**********@spamgourmet.com
(Zenobia)
Hello folks,
Is it possible to position an item within a
<td> element?
<td align="right"> ...use center or left
also...</td>

Except in up-to-date HTMl the align
attribute is deprecated. Don't advise this
method, please.


"Oh my"... pretty please with sugar on it?

Web Design, Magic, Painting, Junking, More
http://www.davmagic.com
Paint A House
http://www.paintahouse.com
NOTE: This emailbox is CLOSED do NOT reply!!!

Jul 20 '05 #6

P: n/a
DU
Steve Pugh wrote:
Zenobia <6.**********@spamgourmet.com> wrote:

Is it possible to position an item within a <td> element?

Yes. Set position: relative; for the <td>


That would make the <td> be offset and a <td> is not just an ordinary
block-level element here but a part, a child of a special block-level
element.

and then position: absolute; and whichever of left, right, top and bottom you need for the child
element.
Why not just set text-align: right of the content of the <td> instead?
W3C CSS2 and CSS2.1 recommends against setting absolute and relatively
positioned elements within a table cell.
Section 17.5 of CSS 2/2.1
However beware of bugs (IIRC Mozilla has a nasty one concerning posititioning relative to table cells).

For
instance see below. The table has multiple rows, one for each
database record. Each row has 3 hrefs associated with it (for
edit, delete and update). I want to position these 3 href items
in the same columns, which would be posible if the span could be
positioned - for instance on the extreme right of the td in
which it is contained.

Sure.
td {position: relative;}
span {position: absolute; right: 0;}

But from the sound of it just adding text-align: right; or
align="right" for the td will work just as well in this case.


Exactly. My point.

http://www10.brinkster.com/doctorunc...ormatting.html
I can't use 2 or more <td> elements as the <td> is put there
using an ASP.NET repeater control

Sounds like ASP.NET is seriously broken if it won't let you insert
three coloumns instead of one. I don't believe that it is seriously
broken (well not that seriously broken) so I guess that the mistake is
either your choice of control or your implementation of it.

- so unless there is an
equivalent of this control using <div> and <span> that is not
possible.

Somehow, I anticipate that the answer will be to use a different
ASP.NET control. Don't bother posting a reply if that is the
case.

Tough. People will post what people want to post. And if people think
taht you're being an arse by using a defective ASP.NET control then
they'll tell you that.

cControl {position:inherit; left:600px; text-align:right;
float:right}

Well, in the absence of a URL we'll have to assume that this is your
entire stylesheet. In which case it's 75% useless. position: inherit;
in the absence of a parent element with position set is going to work
out as position: static; which means that left: 600px; will be
ignored. text-align doesn't apply to inline elements like spans, but
float right makes it a block element. However no width is specified so
many (but not all) browsers will shrink the element to fit round the
content so the text-align is once again useless.

<p>

What's the point of this empty paragraph? If you want to add space
above the table set margin-top.

<table>
<tr>
<td> -- Content --
<span class="cControl">
<a href="href A">E</a>
<a href="href B">D</a>
<a href="href C">U</a>
</span>
</td>

Well the span should be floated to the right from your CSS. Isn't that
what you wanted? If you wanted the span to be alongside your other
content then you should have place the span first.

Steve


From the beginning of the original post, I am convinced that such fine
formating of a table cell content implies table-design for the page,
certainly not formating for tabular data within a table. So, the whole
discussion is most likely flawed.

DU
Jul 20 '05 #7

P: n/a
Zenobia wrote:
Somehow, I anticipate that the answer will be to use a different
ASP.NET control. Don't bother posting a reply if that is the case.


If you don't want us to respond, I'm happy to oblige. However,
curiousity compels me to ask why you posted in the first place.

--
Brian (remove ".invalid" to email me)
http://www.tsmchughs.com/
Jul 20 '05 #8

P: n/a
DU
Davmagic .Com wrote:
From: ne*****@yahoo.com (Neal)
On Mon, 14 Jun 2004 13:07:24 -0400,
Davmagic .Com <DL**@webtv.net>
wrote:

From: 6.**********@spamgourmet.com
(Zenobia)
Hello folks,
Is it possible to position an item within a
<td> element?

<td align="right"> ...use center or left
also...</td>

Except in up-to-date HTMl the align
attribute is deprecated. Don't advise this
method, please.

"Oh my"... pretty please with sugar on it?


Are you suggesting that the align attribute for <td> is not deprecated
or are you insinuating that CSS1 text-align property is not well
supported by a very wide majority of web browsers in use on the web?

DU
Jul 20 '05 #9

P: n/a
On Mon, 14 Jun 2004 23:21:43 GMT, C A Upsdell
<cupsdell0311XXX@-@-@XXXrogers.com> wrote:
"Neal" <ne*****@yahoo.com> wrote in message
news:op**************@news.individual.net...
On Mon, 14 Jun 2004 13:07:24 -0400, Davmagic .Com <DL**@webtv.net>
wrote:
> <td align="right"> ...use center or left also...</td>


Except in up-to-date HTMl the align attribute is deprecated. Don't
advise
this method, please.


It may be deprecated, but it is still supported, and is essential for NN4
support.


In the context of this ng - being www authoring - support for NN4 is not
really practical. I assume unless otherwise prompted that the main goal is
good markup for *current* browsers. As it's trivial to serve content to
NN4 without (optional) presentation, I don't see any reason to offer the
align attribute as blanket advice for a presentational situation.

Jul 20 '05 #10

P: n/a
"Neal" <ne*****@yahoo.com> wrote in message
news:op**************@news.individual.net...
On Mon, 14 Jun 2004 23:21:43 GMT, C A Upsdell
<cupsdell0311XXX@-@-@XXXrogers.com> wrote:
"Neal" <ne*****@yahoo.com> wrote in message
news:op**************@news.individual.net...
On Mon, 14 Jun 2004 13:07:24 -0400, Davmagic .Com <DL**@webtv.net>
wrote:
> <td align="right"> ...use center or left also...</td>

Except in up-to-date HTMl the align attribute is deprecated. Don't
advise
this method, please.


It may be deprecated, but it is still supported, and is essential for NN4 support.


In the context of this ng - being www authoring - support for NN4 is not
really practical. I assume unless otherwise prompted that the main goal is
good markup for *current* browsers. As it's trivial to serve content to
NN4 without (optional) presentation, I don't see any reason to offer the
align attribute as blanket advice for a presentational situation.


Stats vary, but on my site 1.2% use NN4. I dumped NN4 long ago, but am not
yet ready to dump my NN4 visitors.

You have a point, however, when you say "I don't see any reason to offer the
align attribute as blanket advice for a presentational situation". Perhaps
the best advice would have been to present the CSS solution, and then add
what is required for NN4 for those sites which still attract a significant
number of NN4 users.


Jul 20 '05 #11

P: n/a
DU
C A Upsdell wrote:
"Neal" <ne*****@yahoo.com> wrote in message
news:op**************@news.individual.net...
On Mon, 14 Jun 2004 13:07:24 -0400, Davmagic .Com <DL**@webtv.net> wrote:
<td align="right"> ...use center or left also...</td>


Except in up-to-date HTMl the align attribute is deprecated. Don't advise
this method, please.

It may be deprecated, but it is still supported, and is essential for NN4
support.

NS 4.x supports CSS1 text-align property according to these sources

http://www.westciv.com/style_master/...port/text.html

http://devedge.netscape.com/library/...astergrid.html
(see section 5.4.6)

and to Top Style software (see CSS safe list and NS 4 CSS support).

In any cases, what matters is graceful degradation for non-CSS-compliant
browsers. If content is accessible, then support for this or that css
property should not the decisive issue.

DU
Jul 20 '05 #12

P: n/a
"Zenobia" <6.**********@spamgourmet.com> schrieb im Newsbeitrag
news:0f********************************@4ax.com...

[...]
Somehow, I anticipate that the answer will be to use a different
ASP.NET control. Don't bother posting a reply if that is the
case.


Do you allow me to post a reply if I think you should consider switching to
PHP if ASP.NET makes it impossible to use 3 separate tds?

Seriously: After having had a very short introduction into ASP.NET I doubt
that it is a problem to use 3 tds, one for each link. For sure it will be
easier than figuring out a cross browser working positioning hack.

--
Markus
Jul 20 '05 #13

P: n/a
On Mon, 14 Jun 2004 18:12:52 +0100, Steve Pugh <st***@pugh.net>
wrote:
Zenobia <6.**********@spamgourmet.com> wrote:
Is it possible to position an item within a <td> element?
Yes. Set position: relative; for the <td> and then position: absolute;
and whichever of left, right, top and bottom you need for the child
element. However beware of bugs (IIRC Mozilla has a nasty one
concerning posititioning relative to table cells).
For
instance see below. The table has multiple rows, one for each
database record. Each row has 3 hrefs associated with it (for
edit, delete and update). I want to position these 3 href items
in the same columns, which would be posible if the span could be
positioned - for instance on the extreme right of the td in
which it is contained.


Sure.
td {position: relative;}
span {position: absolute; right: 0;}

But from the sound of it just adding text-align: right; or
align="right" for the td will work just as well in this case.


Thanks Steve. Your reply was most helpful. This worked. Your
solution without the td class.
<html>
<head><title>DataList Position</title>
<style type="text/css">
.cControl {position: absolute; right: 0}
</style>
</head>
<body>
<table>
<tr>
<td> -- Content --
<span class="cControl">
<a href="href A">E</a>
<a href="href B">D</a>
<a href="href C">U</a>
</span>
</td>
</tr>
<tr>
<td> -- Some other Content --
<span class="cControl">
<a href="href A">E</a>
<a href="href B">D</a>
<a href="href C">U</a>
</span>
</td>
</tr>
</table>
</body>
</html>
Steve


Jul 20 '05 #14

P: n/a
On Mon, 14 Jun 2004 13:07:24 -0400, DL**@webtv.net (Davmagic
..Com) wrote:
From: 6.**********@spamgourmet.com
(Zenobia)
Hello folks,
Is it possible to position an item within a
<td> element?
<td align="right"> ...use center or left also...</td>


Thanks but no thanks. Given that everyone's having a go a me
for suggesting they shouldn't waste time replying if they have
no relevant comments - I'll have a go at you.

Please read the question in future before replying. The td cell
has two items of content. The first needs to be aligned left and
the second aligned right. The simplest solution is given below.
Your solution won't work. The clue is in the question "items
inside a <td>?" not just "text inside a <td>?"
Web Design, Magic, Painting, Junking, More
http://www.davmagic.com
Paint A House
http://www.paintahouse.com
NOTE: This emailbox is CLOSED do NOT reply!!!


I wish I could recommend spamgourmet as a solution to spam but
the spam keeps coming now that I'm giving people a box to reply
to. At least the viruses have stopped.

Jul 20 '05 #15

This discussion thread is closed

Replies have been disabled for this discussion.