Jump to content

Padding is different on DIV vs table


Eiolon

Recommended Posts

Here is my CSS:

 


div.header {
width:900px;
background-color:#363E44;
padding:12px;
font-family:Arial, Helvetica, sans-serif;
font-size:13px;
color:#FFFFFF;
font-weight:bold;
}

table.data {
width:900px;
padding:12px;
border-collapse:collapse;
}

table.data th {
background-color:#EEEEEE;
padding:12px;
font-family:Arial, Helvetica, sans-serif;
font-size:11px;
font-weight:bold;
color:#000000;
}

table.data td {
background-color:#FFFFFF;
padding:12px;
font-family:Arial, Helvetica, sans-serif;
font-size:11px;
color:#000000
}

Link to comment
Share on other sites

The table is not inside the div.  The div is above it.  They are completely separate elements.

Sorry I read that but forgot about it when I was pondering the problem.

 

I would think they should be the same width, 924pixals.

 

Do you have firefire foxes firebug or can you use chrome to see if something else is a problem?

Link to comment
Share on other sites

The table has nothing to do with it. The box model says the total width of a box object is the width + right padding + left padding + right border + left border + right margin + left margin.

To see it in your example kill the table and add a second div. Just duplicate the css for the second one, but make back ground color different and remove the padding.

 

<style type="text/css">

div.header {
width:900px;
background-color:#363E44;
padding:12px;
font-family:Arial, Helvetica, sans-serif;
font-size:13px;
color:#FFFFFF;
font-weight:bold;
}
div.foot {
width:900px;
background-color:pink;
//padding:12px;
font-family:Arial, Helvetica, sans-serif;
font-size:13px;
color:#FFFFFF;
font-weight:bold;
}

</style>
</head>
<body>
<div class="header">
some thing here
</div>

<div class="foot">
some thing there
</div>

</body>
</html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.