Pixel Question

S

Sparticus

I have been doing web development for a while now (as a hobby) but
there is one thing I never understood. It's about tables and pixels
widths.

For example,

1.) If I make a table at tell it to be 800 pixels wide, with border="1"
(which I don't think is 1 pixel... but just size 1) is the table
something like 796 pixels wide, ple 4 pixels for the border? Or 800
pixels wide, plus 4 pixels for the border? (a total of 804).

2.) If I do the same thing as question 1, but with no border, I assume
my table is in fact 800 pixels wide... so, can I toss in an 800 pixel
wide image and have it fit perfectly (none if it is clipped)?

3.) I normally always set my cellspacing and cellpadding to zero, but
if I don't, how does that affect the answers to the other questions?



I understand I'm asking allot... but it's always bothered me and I
never found any documentation to help me. if anyone can answer these
questions for me I'd be very grateful.

Thanx in advance!

Ryan Ritten
 
N

Neredbojias

With neither quill nor qualm, Sparticus quothed:
I have been doing web development for a while now (as a hobby) but
there is one thing I never understood. It's about tables and pixels
widths.

For example,

1.) If I make a table at tell it to be 800 pixels wide, with border="1"
(which I don't think is 1 pixel... but just size 1) is the table
something like 796 pixels wide, ple 4 pixels for the border? Or 800
pixels wide, plus 4 pixels for the border? (a total of 804).

The inner width of the table is 800px. Even in IE.
2.) If I do the same thing as question 1, but with no border, I assume
my table is in fact 800 pixels wide... so, can I toss in an 800 pixel
wide image and have it fit perfectly (none if it is clipped)?

There's white space to consider. If your markup handles that correctly,
an image can fit "perfectly" in most browsers.
3.) I normally always set my cellspacing and cellpadding to zero, but
if I don't, how does that affect the answers to the other questions?

Both add inter-cell spacing with different effects. For example,
padding will show *cell* background color and spacing won't.
 
X

X l e c t r i c

Sparticus wrote:

"I have been doing web development for a while now (as a hobby) but
there is one thing I never understood. It's about tables and pixels
widths.

For example,

1.) If I make a table at tell it to be 800 pixels wide, with border="1"
(which I don't think is 1 pixel... but just size 1) is the table
something like 796 pixels wide, ple 4 pixels for the border? Or 800
pixels wide, plus 4 pixels for the border? (a total of 804).

2.) If I do the same thing as question 1, but with no border, I assume
my table is in fact 800 pixels wide... so, can I toss in an 800 pixel
wide image and have it fit perfectly (none if it is clipped)?

3.) I normally always set my cellspacing and cellpadding to zero, but if
I don't, how does that affect the answers to the other questions?

I understand I'm asking allot... but it's always bothered me and I never
found any documentation to help me. if anyone can answer these questions
for me I'd be very grateful.

Thanx in advance!

Ryan Ritten"

Yes, as already pointed out the table should be 800 pixels wide (inner),
plus the border. Of course, if you simply want the table to conform to
the dimensions of the table content, then specifying a width isn't
necessary at all.

I've been under the impression that with html, border, cellpadding, and
cellspacing values are in pixels.

Wasn't there an older version of Navigator or Explorer that would add a
a value of 1 or 2 to cellpadding and/or cellspacing if a value of 0
wasn't specified ? At any rate, even if redundant, it might be a good
idea to specify values of 0 if that's what you want.

Later, Art.
 
K

kchayka

Sparticus said:
1.) If I make a table... with border="1"
(which I don't think is 1 pixel... but just size 1)

The border width really is 1 pixel. There is a separate border around
each cell, plus the outside of the table. It looks wider because of
cellspacing, which usually defaults to about 2 pixels, making the border
appear to be about 4 pixels wide.

If you really want a 1-pixel border, look up border-collapse:
3.) I normally always set my cellspacing and cellpadding to zero, but
if I don't, how does that affect the answers to the other questions?

<URL:http://www.w3.org/TR/html401/struct/tables.html#adef-cellspacing>
There is also a diagram there that may help.
 

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

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top