DOCTYPE Strict uses "correct" box model - so why is 100% width now useless?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Consider this simple HTML:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 STRICT//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml"; >
<head>
<title>Strict kills my widths!</title>
</head>
<body>
<table style="width:400px; table-layout:fixed;">
<colgroup>
<col style="width:50%;"/ >
<col style="width:50%;"/ >
</colgroup>
<tr>
<td>
<input type="text" style="width:100%;" />
</td>
<td>
<input type="text" style="width:100%;" />
</td>
</tr>
</table>
</body>
</html>

Both text boxes have their right edges clipped off. Sure, the "Proper"
box model says that width is the width of the content, excluding the
padding and border (and margin, of course.) Wonderful. So now, with
all standard text boxes (and many other controls) having things like
padding and borders, what good is a percentage width?

I could (and do, for lack of a better workaround) use a slightly
smaller width, like 98%, but that has to be adjusted depending on the
width of the table and how many columns it has - smaller tables require
even more reduction in percentage width for the text boxes to fit.

I know the geniuses in the W3C think that their box model is the best,
but if you draw a box (essentially a border) and then write some text
in the middle of it with some space between the edge of the box and the
text, then ask any kid to measure the width of the box, he'll measure
from border to border, INCLUDING padding!

I know, I should stop whining and just stop using STRICT, right? Well,
I could, but that's a step backwards and there are other parts of the
strict doctype that are very appealing.

There's got to be a viable solution to this. Sure, 100% minus padding
minus border is the real answer, but since that's not possible (without
using dynamic properties) to put specify such a formula as width, how
can I solve this issue?

I FEEL LIKE I'M TAKING CRAZY PILLS!

.



Relevant Pages

  • Re: css table borders and spacing
    ... In the following html page, I would like for the table with Sublink1, ... you also get an unwanted border at the bottom of the first three boxes. ... margin: 0; ... padding: 0; ...
    (alt.html)
  • Crippled or missing borders in IE 7
    ... My problem is best explained by the html below. ... BORDER: red 10px solid; ... padding: 2px; ...
    (alt.html)
  • Re: Ruby path for SVN log XML -> HTML
    ... to HTML? ... border: 1px solid red; ... padding: 0 2em; ... if changed_path.is_a?# known bug of Ruby bindings for 1.3.0 ...
    (comp.lang.ruby)
  • border on 100% height body creates scroll
    ... I'm trying to figure out why the following creates a vertical scroll ... I expand html and body to height ... Essentially what I'd like to know why adding a border increases the ... padding: 0px; ...
    (comp.infosystems.www.authoring.stylesheets)
  • Re: CSS padding - 1px top & bottom is a lot more than 0px
    ... the expression collapsing margins means that ... As the margins are outside the padding and border, as I see it, ... padding and border do not come between the margins of adjacent boxes, ...
    (uk.net.web.authoring)