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

really easy tables question

P: n/a
Hi,

I'm trying to use a table and format it with CSS, but I cant get it to
render with a border. I know this is really easy, but I can't see what I
have wrong and when I search for tables and CSS I just get lots of stuff
about using tables for layout etc.

What I have is:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtm11/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head><title>crap</title>
<style type="text/css">
table {border: 2px;
font-size: 16pt;
color: blue;
}
</style>
</head>
<body>

<table>
<tr>
<tdtest test</td>
<tdtest2 test2</td>
</tr>
<tr>
<tdcrap crap </td>
<tdtest3 test3</td>
</tr>
</table>

</body>
</html>

Why do I not get a 2pixel border? Or any border?

Thanks for your help

Michael
Oct 8 '06 #1
Share this Question
Share on Google+
8 Replies


P: n/a
Michael wrote:
I'm trying to use a table and format it with CSS, but I cant get it to
render with a border. I know this is really easy, but I can't see what I
have wrong and when I search for tables and CSS I just get lots of stuff
about using tables for layout etc.
There's nothing special about tables when it comes to borders in CSS.
What I have is:
table {border: 2px;
So, that would be:

border-width: 2px;
border-style: none;

then?

(and don't forget the border-color).
font-size: 16pt;
Point units considered harmful on screen:
http://css-discuss.incutio.com/?page=UsingPoints

--
David Dorward <http://blog.dorward.me.uk/ <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Oct 8 '06 #2

P: n/a
On 2006-10-08, Michael wrote:
Hi,

I'm trying to use a table and format it with CSS, but I cant get it to
render with a border. I know this is really easy, but I can't see what I
have wrong and when I search for tables and CSS I just get lots of stuff
about using tables for layout etc.

What I have is:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtm11/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head><title>crap</title>
<style type="text/css">
table {border: 2px;
font-size: 16pt;
color: blue;
}
</style>
</head>
<body>

<table>
<tr>
<tdtest test</td>
<tdtest2 test2</td>
</tr>
<tr>
<tdcrap crap </td>
<tdtest3 test3</td>
</tr>
</table>

</body>
</html>

Why do I not get a 2pixel border? Or any border?
You must specify the type of border, e.g.:

table {
border: 2px solid;
}

And perhaps the color, as well:

table {
border: 2px solid black;
}
--
Chris F.A. Johnson <http://cfaj.freeshell.org>
================================================== =================
Author:
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
Oct 8 '06 #3

P: n/a
Scripsit David Dorward:
There's nothing special about tables when it comes to borders in CSS.
Actually there's quite a lot special, like border-collapse. But for the
border around a table itself, there's nothing different from the general
border concept in CSS.

What puzzles people who move from presentational HTML to using CSS is that
when you set a border for a table, you only set a border for the table
element as a whole. That's really the "nothing special" thing in CSS terms,
but it differs essentially from the effect of, say, <table border="2">.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

Oct 8 '06 #4

P: n/a
On Sun, 8 Oct 2006 16:51:21 +0800, "Michael" <mi*********@yahoo.com>
wrote:
>Hi,

I'm trying to use a table and format it with CSS, but I cant get it to
render with a border. I know this is really easy, but I can't see what I
have wrong and when I search for tables and CSS I just get lots of stuff
about using tables for layout etc.

What I have is:
snip>>>>>>>>>>
>
Thanks for your help

Michael
Hi Michael,

There is a site that gives about 80 samples of CSS table design. Some
are more than a little over the top but I have always found it useful
to at least see how they do it:

http://icant.co.uk/csstablegallery/index.php

All the best,

Andrew
--

Andrew
http://www.andrews-corner.org/
Oct 8 '06 #5

P: n/a

"David Dorward" <do*****@yahoo.comwrote in message
news:eg*******************@news.demon.co.uk...
Michael wrote:
>I'm trying to use a table and format it with CSS, but I cant get it to
render with a border. I know this is really easy, but I can't see what I
have wrong and when I search for tables and CSS I just get lots of stuff
about using tables for layout etc.

There's nothing special about tables when it comes to borders in CSS.
>What I have is:
table {border: 2px;

So, that would be:

border-width: 2px;
border-style: none;

then?

(and don't forget the border-color).
> font-size: 16pt;

Point units considered harmful on screen:
http://css-discuss.incutio.com/?page=UsingPoints

--
David Dorward <http://blog.dorward.me.uk/ <http://dorward.me.uk/>
Home is where the ~/.bashrc is

ahhhhhh! I knew it was something stupid.
Thanks for that

Michael
Oct 10 '06 #6

P: n/a

"Michael" <mi*********@yahoo.comwrote in message
news:45**********************@per-qv1-newsreader-01.iinet.net.au...
>
"David Dorward" <do*****@yahoo.comwrote in message
news:eg*******************@news.demon.co.uk...
>Michael wrote:
>>I'm trying to use a table and format it with CSS, but I cant get it to
render with a border. I know this is really easy, but I can't see what I
have wrong and when I search for tables and CSS I just get lots of stuff
about using tables for layout etc.

There's nothing special about tables when it comes to borders in CSS.
>>What I have is:
table {border: 2px;

So, that would be:

border-width: 2px;
border-style: none;

then?

(and don't forget the border-color).
>> font-size: 16pt;

Point units considered harmful on screen:
http://css-discuss.incutio.com/?page=UsingPoints

--
David Dorward <http://blog.dorward.me.uk/>
<http://dorward.me.uk/>
Home is where the ~/.bashrc is


ahhhhhh! I knew it was something stupid.
Thanks for that

Michael

Hmmmm.....

Now I have:

table {position: absolute;
top: 150px;
left: 150px;
border-width: 2px;
border-style: none;
font-size: 16pt;
}

I know the page is using the stylesheet because if I change the font-size it
changes, but I still have no border........

Thanks for your help

Regards

Michael
Oct 11 '06 #7

P: n/a
In article
<45**********************@per-qv1-newsreader-01.iinet.net.au>,
"Michael" <mi*********@yahoo.comwrote:
"Michael" <mi*********@yahoo.comwrote in message
news:45**********************@per-qv1-newsreader-01.iinet.net.au...

"David Dorward" <do*****@yahoo.comwrote in message
news:eg*******************@news.demon.co.uk...
Michael wrote:

I'm trying to use a table and format it with CSS, but I cant get it to
render with a border. I know this is really easy, but I can't see what I
have wrong and when I search for tables and CSS I just get lots of stuff
about using tables for layout etc.

There's nothing special about tables when it comes to borders in CSS.

What I have is:
table {border: 2px;

So, that would be:

border-width: 2px;
border-style: none;

then?

(and don't forget the border-color).

font-size: 16pt;

Point units considered harmful on screen:
http://css-discuss.incutio.com/?page=UsingPoints

--
David Dorward <http://blog.dorward.me.uk/>
<http://dorward.me.uk/>
Home is where the ~/.bashrc is

ahhhhhh! I knew it was something stupid.
Thanks for that

Michael

Hmmmm.....

Now I have:

table {position: absolute;
top: 150px;
left: 150px;
border-width: 2px;
border-style: none;
font-size: 16pt;
}

I know the page is using the stylesheet because if I change the font-size it
changes, but I still have no border........
It helps to consult the CSS specs for border-style:

none
No border. This value forces the computed value of ¹border-width¹
to be ¹0¹.
hidden
Same as ¹none¹, except in terms of border conflict resolution [p.
264] for table elements [p. 245] .
dotted
The border is a series of dots.
dashed
The border is a series of short line segments.
solid
The border is a single line segment.

http://www.w3.org/TR/REC-CSS2, for future reference!
Oct 11 '06 #8

P: n/a
Michael wrote:
>>So, that would be:
border-width: 2px;
border-style: none;
then?
border-style: none;
So now you're setting it to none explicitly, instead of having none because
its the default. None is, however, still none.
>>(and don't forget the border-color).
You're still forgetting the border colour.
>>Point units considered harmful on screen:
http://css-discuss.incutio.com/?page=UsingPoints
font-size: 16pt;
Point units are still considered harmfil, avoid them.

--
David Dorward <http://blog.dorward.me.uk/ <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Oct 11 '06 #9

This discussion thread is closed

Replies have been disabled for this discussion.