ブラウザが使用しているボックス モデルによって異なります。次の 2 つの可能性があります。
content-box: 要素の幅には、パディングとボーダーのプロパティは含まれません。これは、互換モードの IE を除くすべてのデフォルト モデルです。
border-box: 要素の幅にはパディングとボーダーが含まれます。
新しいブラウザーでは、box-sizing属性を使用してどちらを使用するかを選択できます。
したがって、モデルで提供したコードを考えると、content-boxの幅は次のdivようになります。
400 # from width
+ 20 # from padding-left
+ 10 # from padding-right
+ 4 # from the left and right borders
+ 20 # from the left and right margins
-----------------------------------------
Physical width = 454
Content width = 400
モデルはのborder-box幅を次のように設定divします。
366 # the declared width is shrunk by the amount of padding and border
+ 20 # from padding-left
+ 10 # from padding-right
+ 4 # from the left and right borders
+ 20 # from the left and right margins
-----------------------------------------
Physical width = 420
Content width = 366
詳細については、このテーマに関する Quirk's Mode の優れた記事を参照してください。