Why is it that 100% width looks like 95%?

G

Guest

Why is it that when I put one HTML element in another, say a table in a page,
set the outer element's margin and padding to 0 and the inner element's width
to 100%, the inner element's right edge does NOT rest at the outer element's
right edge? If you set the width of the inner element to 105%, it looks
right. Huh? What am I missing? TIA.
 
J

Joshua Mitts

Is there an extra space or return in the HTML file? Sometimes spaces between
the ending tags of the control can cause that problem. For example, you want
the following:

</table></body>

NOT </table>
</body>

Same with your <tr> and <td> tags as well.
 
D

Damien

Joshua said:
Is there an extra space or return in the HTML file? Sometimes spaces between
the ending tags of the control can cause that problem. For example, you want
the following:

</table></body>

NOT </table>
</body>

Same with your <tr> and <td> tags as well.

Apologies, I cannot see the original post, only this answer. In short,
the answer is "because browsers are odd". Even when (if?) you manage to
get everything laid out exactly how you want it in e.g. Internet
Explorer, you'll find it renders differently in Opera and Firefox. That
doesn't stop the bloody analysts in my shop insisting that everything
has to be "just so". I gradually guide them towards making the user
experience good, and the layout reasonable.

(Worst experience was one analyst who didn't want any scrollbars, so
had designed every webpage to sit on one page of the spec. Portrait.)

But to try to answer the original question:
1) Do you have enough content to fill the inner element? Sometimes if
you only have a single line of text, the element will get shortened
anyway.
2) Try turning on borders on everything - this can often expose that
the element you believe is responsible for layout problems isn't
3) Is the table well-formed? Are the number of rows/columns consistent
(can especially turn up when using rowspan/colspans > 1)

Damien
 

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,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top