2 replies [Last post]
toothyXdip
toothyXdip's picture
Offline
Regular
Last seen: 14 years 16 weeks ago
Joined: 2007-12-30
Posts: 12
Points: 0

ok i was looking at a websites source and i was wondering why they had this in the beginning of the html:

and this for the css at the top:

#wrap { width: 1000px; margin-left: 5%; border: 1px solid #CCCCCC; } #main { text-align: center; padding: 15px; background-color: #a0cb7b; }

the div end at the same spot and start at the same spot why didnt they just put the css from main or wrap into the css of wrap or main?

chikoppi
Offline
Enthusiast
Last seen: 11 years 29 weeks ago
Timezone: GMT-6
Joined: 2006-06-25
Posts: 85
Points: 2

Could be a number of

Could be a number of reasons, I suppose.

I would have done it this way to avoid the box-model problem. The outer div has a fixed width and no padding while the inner div has auto-width plus padding. This will display the same whether in IE or FF without additional fixes.

Had the CSS added the padding to the "wrap" div it would have been 1000px wide (width includes padding) in IE but 1030px wide (width does not include padding) in other browsers.

toothyXdip
toothyXdip's picture
Offline
Regular
Last seen: 14 years 16 weeks ago
Joined: 2007-12-30
Posts: 12
Points: 0

Oh so the wrap is padding

Oh so the wrap is padding the actually main so the width and the padding wouldnt be together and screw up? Like padding something within the main div.