why can't I set a tr margin?

P

Philip

rosdi said:
I tried to separate my table rows a few pixels away from each other,
but my css below doest work, why?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
<!--
tr {
margin-bottom: 15px;
}
-->
</style>
</head>
<body>
<table width="100%">
<tr>
<td>row 1</td>
</tr>
<tr>
<td>row 2</td>
</tr>
</table>
</body>
</html>

Try padding-bottom instead.

A couple of other comments (that you didn't ask for):
- The browsers that got confused if you didn't wrap your CSS in <--
comments --> are long gone. You don't need to do this anymore.
- For most people, XHTML sounds a lot more useful than it actually is.
HTML 4.01 Strict is often a better choice.

HTH
 
R

rosdi

Philip said:
Try padding-bottom instead.

A couple of other comments (that you didn't ask for):
- The browsers that got confused if you didn't wrap your CSS in <--
comments --> are long gone. You don't need to do this anymore.
- For most people, XHTML sounds a lot more useful than it actually is.
HTML 4.01 Strict is often a better choice.

HTH

The reason I didn't use padding-bottom is because I am planning to
display the td border, using padding will make each rows appear fat at
the bottom. So tr really wont work? I am out of luck?

Thanks for the extra comments, will keep it in mind.
 
D

David Dorward

rosdi said:
I tried to separate my table rows a few pixels away from each other,
but my css below doest work, why?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
<!--

Two reasons, first - you commented out your stylesheet. So it will be
ignored (unless you're serving your XHTML as text/html, in which case -
what's the point?).

Second, tables are different when it comes to layout. Try border-spacing
instead.

http://www.w3.org/TR/CSS2/tables.html#separated-borders

I don't think anything exists that will work in MSIE though.
 
H

Harlan Messinger

David said:
Two reasons, first - you commented out your stylesheet. So it will be ignored

It won't. <!-- and --> are permitted to appear in CSS but aren't treated
as comment delimiters. This allows the CSS code to be hidden from agents
 
A

Alan J. Flavell

David Dorward wrote: [in reference to XHTML]
Two reasons, first - you commented out your stylesheet. So it will be
ignored

It won't.

You evidently don't understand XHTML.
<!-- and --> are permitted to appear in CSS

XHTML doesn't care in the least what the rules of CSS say. It has to
parse the document according to the rules of XHTML /before/ taking its
decision on what to do with the content - in this case, to pass the
content to CSS - but, by the time it gets that far, there *is* no
content left to be passed on, since it was all commented-out.
but aren't treated as comment delimiters.

HTML has declared the content of the style and script elements as
CDATA, so that's correct for HTML. But D.D was not talking about
HTML.

If you write XHTML, the rules of HTML are only of indirect interest.
This allows the CSS code to be hidden from agents that don't know
what <STYLE> tags are so that they don't treat it as (bad) HTML.

This is pretty much cargo-cult, you know. Pre-HTML/3.2 browsers would
be of little use nowadays anyway (for example, browsers from that era
typically did not support name-based virtual hosts, which makes them
of very limited practical use in today's web situation).

You don't seem to have perceived the significance of what you so
helpfully quoted!
 
R

rosdi

Alan said:
David Dorward wrote: [in reference to XHTML]
<style type="text/css">
<!--

Two reasons, first - you commented out your stylesheet. So it will be
ignored

It won't.

You evidently don't understand XHTML.
<!-- and --> are permitted to appear in CSS

XHTML doesn't care in the least what the rules of CSS say. It has to
parse the document according to the rules of XHTML /before/ taking its
decision on what to do with the content - in this case, to pass the
content to CSS - but, by the time it gets that far, there *is* no
content left to be passed on, since it was all commented-out.
but aren't treated as comment delimiters.

HTML has declared the content of the style and script elements as
CDATA, so that's correct for HTML. But D.D was not talking about
HTML.

If you write XHTML, the rules of HTML are only of indirect interest.
This allows the CSS code to be hidden from agents that don't know
what <STYLE> tags are so that they don't treat it as (bad) HTML.

This is pretty much cargo-cult, you know. Pre-HTML/3.2 browsers would
be of little use nowadays anyway (for example, browsers from that era
typically did not support name-based virtual hosts, which makes them
of very limited practical use in today's web situation).

Not trying to interpret the css specification or XHTML rules here. But
the css _IS_ read by IE (or Firefox for that matter). I know this
because some other css in there do take effects. The only problem is tr
{ margin: xx xx} is ignored altogether. Honestly I dont see any reason
why it should be ignored or why tr should be treated any different than
the rest of the elements.

Btw, I will make it a point NOT to comment out my css from now on, I
used to take it for granted because I dont see any ill effect of
commenting it. Probably it has become a bad habit of mine from the
frame and javascript days.
 
D

David Dorward

rosdi said:
Not trying to interpret the css specification or XHTML rules here. But
the css _IS_ read by IE (or Firefox for that matter).

You snipped the bit about serving XHTML as text/html.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,832
Latest member
GlennSmall

Latest Threads

Top